Search in sources :

Example 1 with MoveBookRequest

use of com.google.example.library.v1.MoveBookRequest 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()));
}
Also used : MoveBookRequest(com.google.example.library.v1.MoveBookRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Book(com.google.example.library.v1.Book) BookName(com.google.example.library.v1.BookName) ShelfName(com.google.example.library.v1.ShelfName) Test(org.junit.Test)

Example 2 with MoveBookRequest

use of com.google.example.library.v1.MoveBookRequest 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()));
}
Also used : MoveBookRequest(com.google.example.library.v1.MoveBookRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Book(com.google.example.library.v1.Book) BookName(com.google.example.library.v1.BookName) Test(org.junit.Test)

Example 3 with MoveBookRequest

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

the class AsyncMoveBook method asyncMoveBook.

public static void asyncMoveBook() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        MoveBookRequest request = MoveBookRequest.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).setOtherShelfName(ShelfName.of("[SHELF_ID]").toString()).build();
        ApiFuture<Book> future = libraryServiceClient.moveBookCallable().futureCall(request);
        // Do something.
        Book response = future.get();
    }
}
Also used : MoveBookRequest(com.google.example.library.v1.MoveBookRequest) LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) Book(com.google.example.library.v1.Book)

Example 4 with MoveBookRequest

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

the class SyncMoveBook method syncMoveBook.

public static void syncMoveBook() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        MoveBookRequest request = MoveBookRequest.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).setOtherShelfName(ShelfName.of("[SHELF_ID]").toString()).build();
        Book response = libraryServiceClient.moveBook(request);
    }
}
Also used : MoveBookRequest(com.google.example.library.v1.MoveBookRequest) LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) Book(com.google.example.library.v1.Book)

Example 5 with MoveBookRequest

use of com.google.example.library.v1.MoveBookRequest 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)

Aggregations

Book (com.google.example.library.v1.Book)6 MoveBookRequest (com.google.example.library.v1.MoveBookRequest)6 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 LibraryServiceClient (com.google.cloud.example.library.v1.LibraryServiceClient)2 BookName (com.google.example.library.v1.BookName)2 ShelfName (com.google.example.library.v1.ShelfName)2