use of com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogMetricsPagedResponse in project google-cloud-java by GoogleCloudPlatform.
the class MetricsClientTest method listLogMetricsTest.
@Test
@SuppressWarnings("all")
public void listLogMetricsTest() {
String nextPageToken = "";
LogMetric metricsElement = LogMetric.newBuilder().build();
List<LogMetric> metrics = Arrays.asList(metricsElement);
ListLogMetricsResponse expectedResponse = ListLogMetricsResponse.newBuilder().setNextPageToken(nextPageToken).addAllMetrics(metrics).build();
mockMetricsServiceV2.addResponse(expectedResponse);
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[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<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListLogMetricsRequest actualRequest = (ListLogMetricsRequest) actualRequests.get(0);
Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
}
Aggregations