use of com.google.example.library.v1.BookName 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 com.google.example.library.v1.BookName in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method moveBookExceptionTest.
@Test
public void moveBookExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockLibraryService.addException(exception);
try {
BookName name = BookName.of("[SHELF]", "[BOOK]");
ShelfName otherShelfName = ShelfName.of("[SHELF_ID]");
client.moveBook(name, otherShelfName);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.example.library.v1.BookName 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()));
}
use of com.google.example.library.v1.BookName in project gapic-generator-java by googleapis.
the class SyncMoveBookBooknameShelfname method syncMoveBookBooknameShelfname.
public static void syncMoveBookBooknameShelfname() throws Exception {
// It may require modifications to work in your environment.
try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
BookName name = BookName.of("[SHELF]", "[BOOK]");
ShelfName otherShelfName = ShelfName.of("[SHELF_ID]");
Book response = libraryServiceClient.moveBook(name, otherShelfName);
}
}
use of com.google.example.library.v1.BookName in project gapic-generator-java by googleapis.
the class SyncMoveBookBooknameString method syncMoveBookBooknameString.
public static void syncMoveBookBooknameString() throws Exception {
// It may require modifications to work in your environment.
try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
BookName name = BookName.of("[SHELF]", "[BOOK]");
String otherShelfName = ShelfName.of("[SHELF_ID]").toString();
Book response = libraryServiceClient.moveBook(name, otherShelfName);
}
}
Aggregations