use of com.google.logging.v2.GetLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class MetricsClientTest method getLogMetricTest.
@Test
@SuppressWarnings("all")
public void getLogMetricTest() {
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 actualResponse = client.getLogMetric(metricName);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetLogMetricRequest actualRequest = (GetLogMetricRequest) actualRequests.get(0);
Assert.assertEquals(metricName, actualRequest.getMetricNameAsMetricNameOneof());
}
use of com.google.logging.v2.GetLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testGetMetricAsync_Null.
@Test
public void testGetMetricAsync_Null() throws ExecutionException, InterruptedException {
ApiFuture<LogMetric> response = ApiFutures.immediateFuture(null);
GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build();
EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
assertNull(logging.getMetricAsync(METRIC_NAME).get());
}
use of com.google.logging.v2.GetLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testGetMetric_Null.
@Test
public void testGetMetric_Null() {
ApiFuture<LogMetric> response = ApiFutures.immediateFuture(null);
GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build();
EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
assertNull(logging.getMetric(METRIC_NAME));
}
use of com.google.logging.v2.GetLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testGetMetricAsync.
@Test
public void testGetMetricAsync() throws ExecutionException, InterruptedException {
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.getMetricAsync(METRIC_NAME).get();
assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink);
}
use of com.google.logging.v2.GetLogMetricRequest 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