use of com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogEntriesPagedResponse in project google-cloud-java by GoogleCloudPlatform.
the class LoggingClientTest method listLogEntriesTest.
@Test
@SuppressWarnings("all")
public void listLogEntriesTest() {
String nextPageToken = "";
LogEntry entriesElement = LogEntry.newBuilder().build();
List<LogEntry> entries = Arrays.asList(entriesElement);
ListLogEntriesResponse expectedResponse = ListLogEntriesResponse.newBuilder().setNextPageToken(nextPageToken).addAllEntries(entries).build();
mockLoggingServiceV2.addResponse(expectedResponse);
List<String> resourceNames = new ArrayList<>();
String filter = "filter-1274492040";
String orderBy = "orderBy1234304744";
ListLogEntriesPagedResponse pagedListResponse = client.listLogEntries(resourceNames, filter, orderBy);
List<LogEntry> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEntriesList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockLoggingServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListLogEntriesRequest actualRequest = (ListLogEntriesRequest) actualRequests.get(0);
Assert.assertEquals(resourceNames, actualRequest.getResourceNamesList());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertEquals(orderBy, actualRequest.getOrderBy());
}
Aggregations