Search in sources :

Example 61 with Book

use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.

the class LibraryServiceClientTest method createBookTest.

@Test
public void createBookTest() throws Exception {
    Book expectedResponse = Book.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).setAuthor("author-1406328437").setTitle("title110371416").setRead(true).build();
    mockLibraryService.addResponse(expectedResponse);
    ShelfName parent = ShelfName.of("[SHELF_ID]");
    Book book = Book.newBuilder().build();
    Book actualResponse = client.createBook(parent, book);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateBookRequest actualRequest = ((CreateBookRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(book, actualRequest.getBook());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : CreateBookRequest(com.google.example.library.v1.CreateBookRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Book(com.google.example.library.v1.Book) ShelfName(com.google.example.library.v1.ShelfName) Test(org.junit.Test)

Example 62 with Book

use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.

the class LibraryServiceClientTest method getBookTest2.

@Test
public void getBookTest2() 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";
    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, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : GetBookRequest(com.google.example.library.v1.GetBookRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Book(com.google.example.library.v1.Book) Test(org.junit.Test)

Example 63 with Book

use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.

the class LibraryServiceClientTest method moveBookTest4.

@Test
public void moveBookTest4() 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";
    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, actualRequest.getName());
    Assert.assertEquals(otherShelfName, actualRequest.getOtherShelfName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : MoveBookRequest(com.google.example.library.v1.MoveBookRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Book(com.google.example.library.v1.Book) Test(org.junit.Test)

Example 64 with Book

use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.

the class LibraryServiceClientTest method createBookTest2.

@Test
public void createBookTest2() throws Exception {
    Book expectedResponse = Book.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).setAuthor("author-1406328437").setTitle("title110371416").setRead(true).build();
    mockLibraryService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    Book book = Book.newBuilder().build();
    Book actualResponse = client.createBook(parent, book);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateBookRequest actualRequest = ((CreateBookRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(book, actualRequest.getBook());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : CreateBookRequest(com.google.example.library.v1.CreateBookRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Book(com.google.example.library.v1.Book) Test(org.junit.Test)

Example 65 with Book

use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.

the class LibraryServiceClientTest method deleteBookTest.

@Test
public void deleteBookTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockLibraryService.addResponse(expectedResponse);
    BookName name = BookName.of("[SHELF]", "[BOOK]");
    client.deleteBook(name);
    List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteBookRequest actualRequest = ((DeleteBookRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) BookName(com.google.example.library.v1.BookName) DeleteBookRequest(com.google.example.library.v1.DeleteBookRequest) Test(org.junit.Test)

Aggregations

Book (com.google.example.library.v1.Book)33 Test (org.junit.Test)25 LibraryServiceClient (com.google.cloud.example.library.v1.LibraryServiceClient)22 Book (student_arturs_melnikovs.lesson_10.level_02.Book)16 BookName (com.google.example.library.v1.BookName)12 AbstractMessage (com.google.protobuf.AbstractMessage)12 ShelfName (com.google.example.library.v1.ShelfName)9 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 MoveBookRequest (com.google.example.library.v1.MoveBookRequest)6 DeleteBookRequest (com.google.example.library.v1.DeleteBookRequest)5 Scanner (java.util.Scanner)5 CreateBookRequest (com.google.example.library.v1.CreateBookRequest)4 GetBookRequest (com.google.example.library.v1.GetBookRequest)4 Page (org.apache.wicket.Page)4 Book (org.apache.wicket.core.util.tester.apps_1.Book)4 WebPage (org.apache.wicket.markup.html.WebPage)4 AccessDeniedPage (org.apache.wicket.markup.html.pages.AccessDeniedPage)4 DummyPage (org.apache.wicket.resource.DummyPage)4 Book (org.apache.wicket.util.tester.apps_1.Book)4