use of com.google.logging.v2.LogMetric 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.LogMetric 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);
}
use of com.google.logging.v2.LogMetric in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testCreateMetric.
@Test
public void testCreateMetric() {
LogMetric metricPb = METRIC_INFO.toPb();
ApiFuture<LogMetric> response = ApiFutures.immediateFuture(metricPb);
CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder().setParent(PROJECT_PB).setMetric(metricPb).build();
EasyMock.expect(loggingRpcMock.create(request)).andReturn(response);
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
Metric metric = logging.create(METRIC_INFO);
assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), metric);
}
use of com.google.logging.v2.LogMetric in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testGetMetric.
@Test
public void testGetMetric() {
LogMetric sinkPb = METRIC_INFO.toPb();
ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb);
GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build();
EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
Metric sink = logging.getMetric(METRIC_NAME);
assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink);
}
Aggregations