Search in sources :

Example 1 with ListIndexesPagedResponse

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()));
}
Also used : ListIndexesResponse(com.google.datastore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.datastore.admin.v1.Index) ListIndexesRequest(com.google.datastore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Aggregations

ListIndexesPagedResponse (com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse)1 Index (com.google.datastore.admin.v1.Index)1 ListIndexesRequest (com.google.datastore.admin.v1.ListIndexesRequest)1 ListIndexesResponse (com.google.datastore.admin.v1.ListIndexesResponse)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 Test (org.junit.Test)1