Search in sources :

Example 11 with ListLogEntriesResponse

use of com.google.logging.v2.ListLogEntriesResponse in project google-cloud-java by GoogleCloudPlatform.

the class LoggingImplTest method testListLogEntries.

@Test
public void testListLogEntries() {
    String cursor = "cursor";
    EasyMock.replay(rpcFactoryMock);
    logging = options.getService();
    ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder().addProjectIds(PROJECT).build();
    List<LogEntry> entriesList = ImmutableList.of(LOG_ENTRY1, LOG_ENTRY2);
    ListLogEntriesResponse response = ListLogEntriesResponse.newBuilder().setNextPageToken(cursor).addAllEntries(Lists.transform(entriesList, LogEntry.toPbFunction(PROJECT))).build();
    ApiFuture<ListLogEntriesResponse> futureResponse = ApiFutures.immediateFuture(response);
    EasyMock.expect(loggingRpcMock.list(request)).andReturn(futureResponse);
    EasyMock.replay(loggingRpcMock);
    Page<LogEntry> page = logging.listLogEntries();
    assertEquals(cursor, page.getNextPageToken());
    assertArrayEquals(entriesList.toArray(), Iterables.toArray(page.getValues(), LogEntry.class));
}
Also used : ListLogEntriesResponse(com.google.logging.v2.ListLogEntriesResponse) ListLogEntriesRequest(com.google.logging.v2.ListLogEntriesRequest) Test(org.junit.Test)

Aggregations

ListLogEntriesRequest (com.google.logging.v2.ListLogEntriesRequest)10 ListLogEntriesResponse (com.google.logging.v2.ListLogEntriesResponse)10 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)3 LogEntry (com.google.logging.v2.LogEntry)2 List (java.util.List)2 AsyncPage (com.google.api.gax.paging.AsyncPage)1 ListLogEntriesPagedResponse (com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogEntriesPagedResponse)1 ImmutableList (com.google.common.collect.ImmutableList)1 ByteString (com.google.protobuf.ByteString)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1