/** * * * <pre> * The new logs-based metric, which must not have an identifier that * already exists. * </pre> * * <code>.google.logging.v2.LogMetric metric = 2;</code> */ public com.google.logging.v2.LogMetricOrBuilder getMetricOrBuilder() { return getMetric(); }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getParentBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); } if (metric_ != null) { output.writeMessage(2, getMetric()); } unknownFields.writeTo(output); }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getParentBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); } if (metric_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getMetric()); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + PARENT_FIELD_NUMBER; hash = (53 * hash) + getParent().hashCode(); if (hasMetric()) { hash = (37 * hash) + METRIC_FIELD_NUMBER; hash = (53 * hash) + getMetric().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.logging.v2.CreateLogMetricRequest)) { return super.equals(obj); } com.google.logging.v2.CreateLogMetricRequest other = (com.google.logging.v2.CreateLogMetricRequest) obj; boolean result = true; result = result && getParent().equals(other.getParent()); result = result && (hasMetric() == other.hasMetric()); if (hasMetric()) { result = result && getMetric().equals(other.getMetric()); } result = result && unknownFields.equals(other.unknownFields); return result; }
public Builder mergeFrom(com.google.logging.v2.CreateLogMetricRequest other) { if (other == com.google.logging.v2.CreateLogMetricRequest.getDefaultInstance()) return this; if (!other.getParent().isEmpty()) { parent_ = other.parent_; onChanged(); } if (other.hasMetric()) { mergeMetric(other.getMetric()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@Test @SuppressWarnings("all") public void createLogMetricTest() { MetricName name = ProjectMetricName.of("[PROJECT]", "[METRIC]"); String description = "description-1724546052"; String filter = "filter-1274492040"; String valueExtractor = "valueExtractor2047672534"; LogMetric expectedResponse = LogMetric.newBuilder() .setName(name.toString()) .setDescription(description) .setFilter(filter) .setValueExtractor(valueExtractor) .build(); mockMetricsServiceV2.addResponse(expectedResponse); ParentName parent = ProjectName.of("[PROJECT]"); LogMetric metric = LogMetric.newBuilder().build(); LogMetric actualResponse = client.createLogMetric(parent, metric); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateLogMetricRequest actualRequest = (CreateLogMetricRequest) actualRequests.get(0); Assert.assertEquals(parent, ParentNames.parse(actualRequest.getParent())); Assert.assertEquals(metric, actualRequest.getMetric()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }