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()));
}
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()));
}
Aggregations