Search in sources :

Example 1 with ListFieldsResponse

use of com.google.firestore.admin.v1.ListFieldsResponse in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listFieldsTest2.

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

Example 2 with ListFieldsResponse

use of com.google.firestore.admin.v1.ListFieldsResponse in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listFieldsTest.

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

Aggregations

ListFieldsPagedResponse (com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse)2 Field (com.google.firestore.admin.v1.Field)2 ListFieldsRequest (com.google.firestore.admin.v1.ListFieldsRequest)2 ListFieldsResponse (com.google.firestore.admin.v1.ListFieldsResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 CollectionGroupName (com.google.firestore.admin.v1.CollectionGroupName)1