use of com.google.logging.v2.UpdateLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class MetricsClientTest method updateLogMetricTest.
@Test
@SuppressWarnings("all")
public void updateLogMetricTest() {
String name = "name3373707";
String description = "description-1724546052";
String filter = "filter-1274492040";
LogMetric expectedResponse = LogMetric.newBuilder().setName(name).setDescription(description).setFilter(filter).build();
mockMetricsServiceV2.addResponse(expectedResponse);
MetricNameOneof metricName = MetricNameOneof.from(MetricName.create("[PROJECT]", "[METRIC]"));
LogMetric metric = LogMetric.newBuilder().build();
LogMetric actualResponse = client.updateLogMetric(metricName, metric);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateLogMetricRequest actualRequest = (UpdateLogMetricRequest) actualRequests.get(0);
Assert.assertEquals(metricName, actualRequest.getMetricNameAsMetricNameOneof());
Assert.assertEquals(metric, actualRequest.getMetric());
}
use of com.google.logging.v2.UpdateLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testUpdateMetric.
@Test
public void testUpdateMetric() {
LogMetric sinkPb = METRIC_INFO.toPb();
ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb);
UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).setMetric(sinkPb).build();
EasyMock.expect(loggingRpcMock.update(request)).andReturn(response);
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
Metric sink = logging.update(METRIC_INFO);
assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink);
}
use of com.google.logging.v2.UpdateLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testUpdateMetricAsync.
@Test
public void testUpdateMetricAsync() throws ExecutionException, InterruptedException {
LogMetric sinkPb = METRIC_INFO.toPb();
ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb);
UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).setMetric(sinkPb).build();
EasyMock.expect(loggingRpcMock.update(request)).andReturn(response);
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
Metric sink = logging.updateAsync(METRIC_INFO).get();
assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink);
}
Aggregations