use of com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogsPagedResponse in project google-cloud-java by GoogleCloudPlatform.
the class LoggingClientTest method listLogsTest.
@Test
@SuppressWarnings("all")
public void listLogsTest() {
String nextPageToken = "";
String logNamesElement = "logNamesElement-1079688374";
List<String> logNames = Arrays.asList(logNamesElement);
ListLogsResponse expectedResponse = ListLogsResponse.newBuilder().setNextPageToken(nextPageToken).addAllLogNames(logNames).build();
mockLoggingServiceV2.addResponse(expectedResponse);
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
ListLogsPagedResponse pagedListResponse = client.listLogs(parent);
List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getLogNamesList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockLoggingServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListLogsRequest actualRequest = (ListLogsRequest) actualRequests.get(0);
Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
}
Aggregations