Search in sources :

Example 6 with ListInstancesResponse

use of com.google.cloud.redis.v1beta1.ListInstancesResponse in project gapic-generator-java 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)

Example 7 with ListInstancesResponse

use of com.google.cloud.redis.v1beta1.ListInstancesResponse in project google-cloud-java by GoogleCloudPlatform.

the class GrpcSpannerRpc method listInstances.

@Override
public Paginated<Instance> listInstances(int pageSize, @Nullable String pageToken, @Nullable String filter) throws SpannerException {
    ListInstancesRequest.Builder request = ListInstancesRequest.newBuilder().setParent(projectName()).setPageSize(pageSize);
    if (pageToken != null) {
        request.setPageToken(pageToken);
    }
    if (filter != null) {
        request.setFilter(filter);
    }
    ListInstancesResponse response = get(doUnaryCall(InstanceAdminGrpc.METHOD_LIST_INSTANCES, request.build(), projectName(), null));
    return new Paginated<>(response.getInstancesList(), response.getNextPageToken());
}
Also used : ListInstancesResponse(com.google.spanner.admin.instance.v1.ListInstancesResponse) ListInstancesRequest(com.google.spanner.admin.instance.v1.ListInstancesRequest)

Example 8 with ListInstancesResponse

use of com.google.cloud.redis.v1beta1.ListInstancesResponse in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method listInstancesTest2.

@Test
public void listInstancesTest2() throws Exception {
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().addAllInstances(new ArrayList<Instance>()).addAllFailedLocations(new ArrayList<String>()).setNextPageToken("nextPageToken-1386094857").build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListInstancesResponse actualResponse = client.listInstances(parent);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.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 : ListInstancesResponse(com.google.bigtable.admin.v2.ListInstancesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesRequest(com.google.bigtable.admin.v2.ListInstancesRequest) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 9 with ListInstancesResponse

use of com.google.cloud.redis.v1beta1.ListInstancesResponse in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method listInstancesTest.

@Test
public void listInstancesTest() throws Exception {
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().addAllInstances(new ArrayList<Instance>()).addAllFailedLocations(new ArrayList<String>()).setNextPageToken("nextPageToken-1386094857").build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListInstancesResponse actualResponse = client.listInstances(parent);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListInstancesResponse(com.google.bigtable.admin.v2.ListInstancesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.bigtable.admin.v2.ProjectName) ListInstancesRequest(com.google.bigtable.admin.v2.ListInstancesRequest) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 10 with ListInstancesResponse

use of com.google.cloud.redis.v1beta1.ListInstancesResponse in project java-redis by googleapis.

the class CloudRedisClientTest method listInstancesTest.

@Test
public void listInstancesTest() throws Exception {
    Instance responsesElement = Instance.newBuilder().build();
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
    mockCloudRedis.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    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.toString(), 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)8 Test (org.junit.Test)8 ListInstancesPagedResponse (com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse)4 ListInstancesRequest (com.google.spanner.admin.instance.v1.ListInstancesRequest)4 ListInstancesResponse (com.google.spanner.admin.instance.v1.ListInstancesResponse)4 ByteString (com.google.protobuf.ByteString)3 ListInstancesRequest (com.google.bigtable.admin.v2.ListInstancesRequest)2 ListInstancesResponse (com.google.bigtable.admin.v2.ListInstancesResponse)2 ListInstancesPagedResponse (com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstancesPagedResponse)2 Instance (com.google.spanner.admin.instance.v1.Instance)2 ArrayList (java.util.ArrayList)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 ProjectName (com.google.bigtable.admin.v2.ProjectName)1 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)1 Instance (com.google.cloud.redis.v1beta1.Instance)1 ListInstancesRequest (com.google.cloud.redis.v1beta1.ListInstancesRequest)1 ListInstancesResponse (com.google.cloud.redis.v1beta1.ListInstancesResponse)1 ProjectName (com.google.spanner.admin.instance.v1.ProjectName)1