use of org.pgr112.solutions.sol4.Book in project gapic-generator-java by googleapis.
the class SyncUpdateBook method syncUpdateBook.
public static void syncUpdateBook() throws Exception {
// It may require modifications to work in your environment.
try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
UpdateBookRequest request = UpdateBookRequest.newBuilder().setBook(Book.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
Book response = libraryServiceClient.updateBook(request);
}
}
use of org.pgr112.solutions.sol4.Book in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method updateBookTest.
@Test
public void updateBookTest() throws Exception {
Book expectedResponse = Book.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).setAuthor("author-1406328437").setTitle("title110371416").setRead(true).build();
mockLibraryService.addResponse(expectedResponse);
Book book = Book.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Book actualResponse = client.updateBook(book, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateBookRequest actualRequest = ((UpdateBookRequest) actualRequests.get(0));
Assert.assertEquals(book, actualRequest.getBook());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.pgr112.solutions.sol4.Book 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 org.pgr112.solutions.sol4.Book in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method moveBookTest.
@Test
public void moveBookTest() throws Exception {
Book expectedResponse = Book.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).setAuthor("author-1406328437").setTitle("title110371416").setRead(true).build();
mockLibraryService.addResponse(expectedResponse);
BookName name = BookName.of("[SHELF]", "[BOOK]");
ShelfName otherShelfName = ShelfName.of("[SHELF_ID]");
Book actualResponse = client.moveBook(name, otherShelfName);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
Assert.assertEquals(1, actualRequests.size());
MoveBookRequest actualRequest = ((MoveBookRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(otherShelfName.toString(), actualRequest.getOtherShelfName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.pgr112.solutions.sol4.Book in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method moveBookTest2.
@Test
public void moveBookTest2() throws Exception {
Book expectedResponse = Book.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).setAuthor("author-1406328437").setTitle("title110371416").setRead(true).build();
mockLibraryService.addResponse(expectedResponse);
BookName name = BookName.of("[SHELF]", "[BOOK]");
String otherShelfName = "otherShelfName-1942963547";
Book actualResponse = client.moveBook(name, otherShelfName);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
Assert.assertEquals(1, actualRequests.size());
MoveBookRequest actualRequest = ((MoveBookRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(otherShelfName, actualRequest.getOtherShelfName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations