use of com.google.logging.v2.CreateLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class LoggingImplTest method testCreateMetricAsync.
@Test
public void testCreateMetricAsync() throws ExecutionException, InterruptedException {
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.createAsync(METRIC_INFO).get();
assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), metric);
}
use of com.google.logging.v2.CreateLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.
the class MetricsClientTest method createLogMetricTest.
@Test
@SuppressWarnings("all")
public void createLogMetricTest() {
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);
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[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, actualRequest.getParentAsParentNameOneof());
Assert.assertEquals(metric, actualRequest.getMetric());
}
use of com.google.logging.v2.CreateLogMetricRequest 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);
}
Aggregations