use of com.google.cloud.example.library.v1.LibraryServiceClient.ListBooksPagedResponse in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method listBooksTest2.
@Test
public void listBooksTest2() throws Exception {
Book responsesElement = Book.newBuilder().build();
ListBooksResponse expectedResponse = ListBooksResponse.newBuilder().setNextPageToken("").addAllBooks(Arrays.asList(responsesElement)).build();
mockLibraryService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListBooksPagedResponse pagedListResponse = client.listBooks(parent);
List<Book> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getBooksList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBooksRequest actualRequest = ((ListBooksRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.example.library.v1.LibraryServiceClient.ListBooksPagedResponse in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method listBooksTest.
@Test
public void listBooksTest() throws Exception {
Book responsesElement = Book.newBuilder().build();
ListBooksResponse expectedResponse = ListBooksResponse.newBuilder().setNextPageToken("").addAllBooks(Arrays.asList(responsesElement)).build();
mockLibraryService.addResponse(expectedResponse);
ShelfName parent = ShelfName.of("[SHELF_ID]");
ListBooksPagedResponse pagedListResponse = client.listBooks(parent);
List<Book> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getBooksList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBooksRequest actualRequest = ((ListBooksRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations