use of com.google.example.library.v1.Shelf in project gapic-generator-java by googleapis.
the class LibraryServiceClient method deleteShelf.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a shelf. Returns NOT_FOUND if the shelf does not exist.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
* String name = ShelfName.of("[SHELF_ID]").toString();
* libraryServiceClient.deleteShelf(name);
* }
* }</pre>
*
* @param name The name of the shelf to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteShelf(String name) {
DeleteShelfRequest request = DeleteShelfRequest.newBuilder().setName(name).build();
deleteShelf(request);
}
use of com.google.example.library.v1.Shelf in project gapic-generator-java by googleapis.
the class LibraryServiceClient method deleteShelf.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a shelf. Returns NOT_FOUND if the shelf does not exist.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
* ShelfName name = ShelfName.of("[SHELF_ID]");
* libraryServiceClient.deleteShelf(name);
* }
* }</pre>
*
* @param name The name of the shelf to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteShelf(ShelfName name) {
DeleteShelfRequest request = DeleteShelfRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteShelf(request);
}
use of com.google.example.library.v1.Shelf 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 com.google.example.library.v1.Shelf in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method getShelfTest2.
@Test
public void getShelfTest2() throws Exception {
Shelf expectedResponse = Shelf.newBuilder().setName(ShelfName.of("[SHELF_ID]").toString()).setTheme("theme110327241").build();
mockLibraryService.addResponse(expectedResponse);
String name = "name3373707";
Shelf actualResponse = client.getShelf(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetShelfRequest actualRequest = ((GetShelfRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.example.library.v1.Shelf 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()));
}
Aggregations