Search in sources :

Example 1 with ListIndexesPagedResponse

use of com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listIndexesTest.

@Test
public void listIndexesTest() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.firestore.admin.v1.Index) CollectionGroupName(com.google.firestore.admin.v1.CollectionGroupName) ListIndexesRequest(com.google.firestore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Example 2 with ListIndexesPagedResponse

use of com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listIndexesTest2.

@Test
public void listIndexesTest2() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.firestore.admin.v1.Index) ListIndexesRequest(com.google.firestore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Aggregations

ListIndexesPagedResponse (com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse)2 Index (com.google.firestore.admin.v1.Index)2 ListIndexesRequest (com.google.firestore.admin.v1.ListIndexesRequest)2 ListIndexesResponse (com.google.firestore.admin.v1.ListIndexesResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 CollectionGroupName (com.google.firestore.admin.v1.CollectionGroupName)1