Search in sources :

Example 1 with ListLogsRequest

use of com.google.logging.v2.ListLogsRequest 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());
}
Also used : ListLogsResponse(com.google.logging.v2.ListLogsResponse) ParentNameOneof(com.google.logging.v2.ParentNameOneof) ListLogsRequest(com.google.logging.v2.ListLogsRequest) ListLogsPagedResponse(com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogsPagedResponse) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

ListLogsPagedResponse (com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogsPagedResponse)1 ListLogsRequest (com.google.logging.v2.ListLogsRequest)1 ListLogsResponse (com.google.logging.v2.ListLogsResponse)1 ParentNameOneof (com.google.logging.v2.ParentNameOneof)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Test (org.junit.Test)1