use of com.google.firestore.admin.v1.FieldName in project java-firestore by googleapis.
the class FirestoreAdminClientTest method getFieldTest.
@Test
public void getFieldTest() throws Exception {
Field expectedResponse = Field.newBuilder().setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()).setIndexConfig(Field.IndexConfig.newBuilder().build()).build();
mockFirestoreAdmin.addResponse(expectedResponse);
FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]");
Field actualResponse = client.getField(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetFieldRequest actualRequest = ((GetFieldRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.FieldName in project java-firestore by googleapis.
the class FirestoreAdminClientTest method getFieldExceptionTest.
@Test
public void getFieldExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockFirestoreAdmin.addException(exception);
try {
FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]");
client.getField(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations