use of com.google.firestore.admin.v1.Field in project java-firestore by googleapis.
the class FirestoreAdminClientTest method updateFieldTest.
@Test
public void updateFieldTest() throws Exception {
Field expectedResponse = Field.newBuilder().setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()).setIndexConfig(Field.IndexConfig.newBuilder().build()).build();
Operation resultOperation = Operation.newBuilder().setName("updateFieldTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockFirestoreAdmin.addResponse(resultOperation);
Field field = Field.newBuilder().build();
Field actualResponse = client.updateFieldAsync(field).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateFieldRequest actualRequest = ((UpdateFieldRequest) actualRequests.get(0));
Assert.assertEquals(field, actualRequest.getField());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.Field in project java-firestore by googleapis.
the class FirestoreAdminClientTest method updateFieldExceptionTest.
@Test
public void updateFieldExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockFirestoreAdmin.addException(exception);
try {
Field field = Field.newBuilder().build();
client.updateFieldAsync(field).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
use of com.google.firestore.admin.v1.Field 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.Field in project java-firestore by googleapis.
the class FirestoreAdminClientTest method getFieldTest2.
@Test
public void getFieldTest2() throws Exception {
Field expectedResponse = Field.newBuilder().setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()).setIndexConfig(Field.IndexConfig.newBuilder().build()).build();
mockFirestoreAdmin.addResponse(expectedResponse);
String name = "name3373707";
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, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.Field in project tapestry-5 by apache.
the class FormSupportImplTest method add_validation_when_client_validation_is_disabled.
@Test
public void add_validation_when_client_validation_is_disabled() {
Field barney = mockField();
ClientBehaviorSupport clientBehaviorSupport = mockClientBehaviorSupport();
replay();
FormSupportImpl support = new FormSupportImpl(null, null, null, false, null, null);
support.addValidation(barney, "required", "Who can live without Barney?", null);
verify();
}
Aggregations