Search in sources :

Example 6 with ListInstancesPagedResponse

use of com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse 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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesPagedResponse(com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)6 Test (org.junit.Test)6 ListInstancesPagedResponse (com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse)4 ListInstancesPagedResponse (com.google.cloud.redis.v1.CloudRedisClient.ListInstancesPagedResponse)2