Search in sources :

Example 1 with ListInstanceConfigsPagedResponse

use of com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstanceConfigsPagedResponse in project java-spanner by googleapis.

the class InstanceAdminClientTest method listInstanceConfigsTest.

@Test
public void listInstanceConfigsTest() throws Exception {
    InstanceConfig responsesElement = InstanceConfig.newBuilder().build();
    ListInstanceConfigsResponse expectedResponse = ListInstanceConfigsResponse.newBuilder().setNextPageToken("").addAllInstanceConfigs(Arrays.asList(responsesElement)).build();
    mockInstanceAdmin.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListInstanceConfigsPagedResponse pagedListResponse = client.listInstanceConfigs(parent);
    List<InstanceConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInstanceConfigsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstanceConfigsRequest actualRequest = ((ListInstanceConfigsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) InstanceConfig(com.google.spanner.admin.instance.v1.InstanceConfig) ProjectName(com.google.spanner.admin.instance.v1.ProjectName) ListInstanceConfigsPagedResponse(com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstanceConfigsPagedResponse) ListInstanceConfigsRequest(com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest) ListInstanceConfigsResponse(com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse) Test(org.junit.Test)

Example 2 with ListInstanceConfigsPagedResponse

use of com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstanceConfigsPagedResponse in project java-spanner by googleapis.

the class InstanceAdminClientTest method listInstanceConfigsTest2.

@Test
public void listInstanceConfigsTest2() throws Exception {
    InstanceConfig responsesElement = InstanceConfig.newBuilder().build();
    ListInstanceConfigsResponse expectedResponse = ListInstanceConfigsResponse.newBuilder().setNextPageToken("").addAllInstanceConfigs(Arrays.asList(responsesElement)).build();
    mockInstanceAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListInstanceConfigsPagedResponse pagedListResponse = client.listInstanceConfigs(parent);
    List<InstanceConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInstanceConfigsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstanceConfigsRequest actualRequest = ((ListInstanceConfigsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) InstanceConfig(com.google.spanner.admin.instance.v1.InstanceConfig) ListInstanceConfigsPagedResponse(com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstanceConfigsPagedResponse) ListInstanceConfigsRequest(com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest) ByteString(com.google.protobuf.ByteString) ListInstanceConfigsResponse(com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse) Test(org.junit.Test)

Aggregations

ListInstanceConfigsPagedResponse (com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstanceConfigsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 InstanceConfig (com.google.spanner.admin.instance.v1.InstanceConfig)2 ListInstanceConfigsRequest (com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest)2 ListInstanceConfigsResponse (com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse)2 Test (org.junit.Test)2 ByteString (com.google.protobuf.ByteString)1 ProjectName (com.google.spanner.admin.instance.v1.ProjectName)1