Search in sources :

Example 1 with CreateShelfRequest

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

the class AsyncCreateShelf method asyncCreateShelf.

public static void asyncCreateShelf() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        CreateShelfRequest request = CreateShelfRequest.newBuilder().setShelf(Shelf.newBuilder().build()).build();
        ApiFuture<Shelf> future = libraryServiceClient.createShelfCallable().futureCall(request);
        // Do something.
        Shelf response = future.get();
    }
}
Also used : LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) Shelf(com.google.example.library.v1.Shelf) CreateShelfRequest(com.google.example.library.v1.CreateShelfRequest)

Example 2 with CreateShelfRequest

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

the class LibraryServiceClientTest method createShelfTest.

@Test
public void createShelfTest() throws Exception {
    Shelf expectedResponse = Shelf.newBuilder().setName(ShelfName.of("[SHELF_ID]").toString()).setTheme("theme110327241").build();
    mockLibraryService.addResponse(expectedResponse);
    Shelf shelf = Shelf.newBuilder().build();
    Shelf actualResponse = client.createShelf(shelf);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateShelfRequest actualRequest = ((CreateShelfRequest) actualRequests.get(0));
    Assert.assertEquals(shelf, actualRequest.getShelf());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Shelf(com.google.example.library.v1.Shelf) CreateShelfRequest(com.google.example.library.v1.CreateShelfRequest) Test(org.junit.Test)

Aggregations

CreateShelfRequest (com.google.example.library.v1.CreateShelfRequest)2 Shelf (com.google.example.library.v1.Shelf)2 LibraryServiceClient (com.google.cloud.example.library.v1.LibraryServiceClient)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 Test (org.junit.Test)1