Search in sources :

Example 1 with GetShelfRequest

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

the class LibraryServiceClientTest method getShelfTest2.

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

Example 2 with GetShelfRequest

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

the class AsyncGetShelf method asyncGetShelf.

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

Example 3 with GetShelfRequest

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

the class SyncGetShelf method syncGetShelf.

public static void syncGetShelf() throws Exception {
    // It may require modifications to work in your environment.
    try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
        GetShelfRequest request = GetShelfRequest.newBuilder().setName(ShelfName.of("[SHELF_ID]").toString()).build();
        Shelf response = libraryServiceClient.getShelf(request);
    }
}
Also used : LibraryServiceClient(com.google.cloud.example.library.v1.LibraryServiceClient) GetShelfRequest(com.google.example.library.v1.GetShelfRequest) Shelf(com.google.example.library.v1.Shelf)

Example 4 with GetShelfRequest

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

the class LibraryServiceClientTest method getShelfTest.

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

Aggregations

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