Search in sources :

Example 1 with ListSinksPagedResponse

use of com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClientTest method listSinksTest.

@Test
@SuppressWarnings("all")
public void listSinksTest() {
    String nextPageToken = "";
    LogSink sinksElement = LogSink.newBuilder().build();
    List<LogSink> sinks = Arrays.asList(sinksElement);
    ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken(nextPageToken).addAllSinks(sinks).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
    ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
    List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSinksRequest actualRequest = (ListSinksRequest) actualRequests.get(0);
    Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
}
Also used : LogSink(com.google.logging.v2.LogSink) ListSinksResponse(com.google.logging.v2.ListSinksResponse) ListSinksPagedResponse(com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse) ParentNameOneof(com.google.logging.v2.ParentNameOneof) ListSinksRequest(com.google.logging.v2.ListSinksRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

ListSinksPagedResponse (com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse)1 ListSinksRequest (com.google.logging.v2.ListSinksRequest)1 ListSinksResponse (com.google.logging.v2.ListSinksResponse)1 LogSink (com.google.logging.v2.LogSink)1 ParentNameOneof (com.google.logging.v2.ParentNameOneof)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Test (org.junit.Test)1