use of com.google.example.library.v1.ListShelvesRequest in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method listShelvesExceptionTest.
@Test
public void listShelvesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockLibraryService.addException(exception);
try {
ListShelvesRequest request = ListShelvesRequest.newBuilder().setPageSize(883849137).setPageToken("pageToken873572522").build();
client.listShelves(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.example.library.v1.ListShelvesRequest in project gapic-generator-java by googleapis.
the class AsyncListShelvesPaged method asyncListShelvesPaged.
public static void asyncListShelvesPaged() throws Exception {
// It may require modifications to work in your environment.
try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
ListShelvesRequest request = ListShelvesRequest.newBuilder().setPageSize(883849137).setPageToken("pageToken873572522").build();
while (true) {
ListShelvesResponse response = libraryServiceClient.listShelvesCallable().call(request);
for (Shelf element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
}
use of com.google.example.library.v1.ListShelvesRequest in project gapic-generator-java by googleapis.
the class AsyncListShelves method asyncListShelves.
public static void asyncListShelves() throws Exception {
// It may require modifications to work in your environment.
try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
ListShelvesRequest request = ListShelvesRequest.newBuilder().setPageSize(883849137).setPageToken("pageToken873572522").build();
ApiFuture<Shelf> future = libraryServiceClient.listShelvesPagedCallable().futureCall(request);
// Do something.
for (Shelf element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
}
use of com.google.example.library.v1.ListShelvesRequest in project gapic-generator-java by googleapis.
the class LibraryServiceClientTest method listShelvesTest.
@Test
public void listShelvesTest() throws Exception {
Shelf responsesElement = Shelf.newBuilder().build();
ListShelvesResponse expectedResponse = ListShelvesResponse.newBuilder().setNextPageToken("").addAllShelves(Arrays.asList(responsesElement)).build();
mockLibraryService.addResponse(expectedResponse);
ListShelvesRequest request = ListShelvesRequest.newBuilder().setPageSize(883849137).setPageToken("pageToken873572522").build();
ListShelvesPagedResponse pagedListResponse = client.listShelves(request);
List<Shelf> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getShelvesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockLibraryService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListShelvesRequest actualRequest = ((ListShelvesRequest) actualRequests.get(0));
Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations