Search in sources :

Example 1 with ListShelvesPagedResponse

use of com.google.cloud.example.library.v1.LibraryServiceClient.ListShelvesPagedResponse in project gapic-generator-java by googleapis.

the class LibraryServiceClientTest method listShelvesTest.

@Test
public void listShelvesTest() throws Exception {
    Shelf responsesElement = Shelf.newBuilder().build();
    ListShelvesResponse expectedResponse = ListShelvesResponse.newBuilder().setNextPageToken("").addAllShelves(Arrays.asList(responsesElement)).build();
    mockLibraryService.addResponse(expectedResponse);
    ListShelvesRequest request = ListShelvesRequest.newBuilder().setPageSize(883849137).setPageToken("pageToken873572522").build();
    ListShelvesPagedResponse pagedListResponse = client.listShelves(request);
    List<Shelf> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getShelvesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListShelvesRequest actualRequest = ((ListShelvesRequest) actualRequests.get(0));
    Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
    Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Shelf(com.google.example.library.v1.Shelf) ListShelvesResponse(com.google.example.library.v1.ListShelvesResponse) ListShelvesRequest(com.google.example.library.v1.ListShelvesRequest) ListShelvesPagedResponse(com.google.cloud.example.library.v1.LibraryServiceClient.ListShelvesPagedResponse) Test(org.junit.Test)

Aggregations

ListShelvesPagedResponse (com.google.cloud.example.library.v1.LibraryServiceClient.ListShelvesPagedResponse)1 ListShelvesRequest (com.google.example.library.v1.ListShelvesRequest)1 ListShelvesResponse (com.google.example.library.v1.ListShelvesResponse)1 Shelf (com.google.example.library.v1.Shelf)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 Test (org.junit.Test)1