use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method getBookTest.
@Test
public void getBookTest() 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]");
Book actualResponse = client.getBook(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetBookRequest actualRequest = ((GetBookRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method moveBookTest3.
@Test
public void moveBookTest3() throws Exception {
Book expectedResponse = Book.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).setAuthor("author-1406328437").setTitle("title110371416").setRead(true).build();
mockLibraryService.addResponse(expectedResponse);
String name = "name3373707";
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, actualRequest.getName());
Assert.assertEquals(otherShelfName.toString(), actualRequest.getOtherShelfName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method deleteBookExceptionTest.
@Test
public void deleteBookExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockLibraryService.addException(exception);
try {
BookName name = BookName.of("[SHELF]", "[BOOK]");
client.deleteBook(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method moveBookExceptionTest2.
@Test
public void moveBookExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockLibraryService.addException(exception);
try {
BookName name = BookName.of("[SHELF]", "[BOOK]");
String otherShelfName = "otherShelfName-1942963547";
client.moveBook(name, otherShelfName);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.example.library.v1.Book in project java_1_wednesday_2022 by AlexJavaGuru.
the class SearchCriteriaTest method testOrCriteria1.
private void testOrCriteria1() {
SearchCriteria searchCriteria = new OrSearchCriteria(new AuthorSearchCriteria("1"), new TitleSearchCriteria("1"));
Book book = new Book("2", "1");
checkResult(searchCriteria.test(book));
}
Aggregations