use of com.google.bigtable.admin.v2.ListInstancesResponse in project java-spanner by googleapis.
the class InstanceAdminClientTest method listInstancesTest.
@Test
public void listInstancesTest() throws Exception {
Instance responsesElement = Instance.newBuilder().build();
ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
mockInstanceAdmin.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
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 = mockInstanceAdmin.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()));
}
Aggregations