use of com.google.cloud.logging.v2.MetricsClient.ListLogMetricsPagedResponse in project java-logging by googleapis.
the class MetricsClientTest method listLogMetricsTest2.
@Test
public void listLogMetricsTest2() throws Exception {
LogMetric responsesElement = LogMetric.newBuilder().build();
ListLogMetricsResponse expectedResponse = ListLogMetricsResponse.newBuilder().setNextPageToken("").addAllMetrics(Arrays.asList(responsesElement)).build();
mockMetricsServiceV2.addResponse(expectedResponse);
String parent = "parent-995424086";
ListLogMetricsPagedResponse pagedListResponse = client.listLogMetrics(parent);
List<LogMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getMetricsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockMetricsServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListLogMetricsRequest actualRequest = ((ListLogMetricsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.logging.v2.MetricsClient.ListLogMetricsPagedResponse in project java-logging by googleapis.
the class MetricsClientTest method listLogMetricsTest.
@Test
public void listLogMetricsTest() throws Exception {
LogMetric responsesElement = LogMetric.newBuilder().build();
ListLogMetricsResponse expectedResponse = ListLogMetricsResponse.newBuilder().setNextPageToken("").addAllMetrics(Arrays.asList(responsesElement)).build();
mockMetricsServiceV2.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListLogMetricsPagedResponse pagedListResponse = client.listLogMetrics(parent);
List<LogMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getMetricsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockMetricsServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListLogMetricsRequest actualRequest = ((ListLogMetricsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations