Search in sources :

Example 1 with ListLogEntriesPagedResponse

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());
}
Also used : ListLogEntriesResponse(com.google.logging.v2.ListLogEntriesResponse) ArrayList(java.util.ArrayList) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) LogEntry(com.google.logging.v2.LogEntry) ListLogEntriesPagedResponse(com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogEntriesPagedResponse) ListLogEntriesRequest(com.google.logging.v2.ListLogEntriesRequest) Test(org.junit.Test)

Aggregations

ListLogEntriesPagedResponse (com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogEntriesPagedResponse)1 ListLogEntriesRequest (com.google.logging.v2.ListLogEntriesRequest)1 ListLogEntriesResponse (com.google.logging.v2.ListLogEntriesResponse)1 LogEntry (com.google.logging.v2.LogEntry)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1