use of com.google.cloud.redis.v1beta1.ListInstancesRequest in project java-redis by googleapis.
the class CloudRedisClientTest method listInstancesTest2.
@Test
public void listInstancesTest2() throws Exception {
Instance responsesElement = Instance.newBuilder().build();
ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
mockCloudRedis.addResponse(expectedResponse);
String parent = "parent-995424086";
ListInstancesPagedResponse pagedListResponse = client.listInstances(parent);
List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockCloudRedis.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.ListInstancesRequest in project java-notebooks by googleapis.
the class ITNotebookServiceClientTest method testListInstances.
@Test
public void testListInstances() {
ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(PARENT).build();
for (Instance element : client.listInstances(request).iterateAll()) {
if (element.getName().equals(NOTEBOOK_INSTANCE_ID)) {
assertEquals(expectedNotebookInstance.getContainerImage(), element.getContainerImage());
assertEquals(expectedNotebookInstance.getName(), element.getName());
assertEquals(expectedNotebookInstance.getMachineType(), element.getMachineType());
assertEquals(expectedNotebookInstance.getNetwork(), element.getNetwork());
assertEquals(expectedNotebookInstance.getSubnet(), element.getSubnet());
}
}
}
use of com.google.cloud.redis.v1beta1.ListInstancesRequest in project gapic-generator-java by googleapis.
the class AsyncListInstances method asyncListInstances.
public static void asyncListInstances() throws Exception {
// It may require modifications to work in your environment.
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();
ApiFuture<Instance> future = cloudRedisClient.listInstancesPagedCallable().futureCall(request);
// Do something.
for (Instance element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
}
Aggregations