/** * * * <pre> * The resource name of the project in which to create the metric: * "projects/[PROJECT_ID]" * The new metric must be provided in the request. * </pre> * * <code>string parent = 1;</code> */ public Builder clearParent() { parent_ = getDefaultInstance().getParent(); onChanged(); return this; } /**
@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())); }