use of com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse in project java-datastore by googleapis.
the class DatastoreAdminClientTest method listIndexesTest.
@Test
public void listIndexesTest() throws Exception {
Index responsesElement = Index.newBuilder().build();
ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
mockDatastoreAdmin.addResponse(expectedResponse);
ListIndexesRequest request = ListIndexesRequest.newBuilder().setProjectId("projectId-894832108").setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();
ListIndexesPagedResponse pagedListResponse = client.listIndexes(request);
List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDatastoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations