Search in sources :

Example 1 with ValidationErrors

use of com.braintreegateway.ValidationErrors in project camel by apache.

the class CustomerGatewayIntegrationTest method testWrongCustomerCreateRequest.

@Test
public void testWrongCustomerCreateRequest() throws Exception {
    // Create customer
    Result<Customer> createResult = requestBody("direct://CREATE_IN_BODY", new CustomerRequest().firstName("user").lastName(UUID.randomUUID().toString()).company("Apache").email("wrongEmail").website("http://user.braintree.camel"), Result.class);
    assertNotNull(createResult);
    assertFalse(createResult.isSuccess());
    final ValidationErrors errors = createResult.getErrors();
    assertNotNull(errors);
    assertNotNull(errors.getAllDeepValidationErrors());
    ValidationError invalidMailError = null;
    for (ValidationError error : errors.getAllDeepValidationErrors()) {
        if (error.getCode() == ValidationErrorCode.CUSTOMER_EMAIL_FORMAT_IS_INVALID) {
            invalidMailError = error;
            break;
        }
    }
    assertNotNull(invalidMailError);
}
Also used : CustomerRequest(com.braintreegateway.CustomerRequest) Customer(com.braintreegateway.Customer) ValidationErrors(com.braintreegateway.ValidationErrors) ValidationError(com.braintreegateway.ValidationError) Test(org.junit.Test)

Aggregations

Customer (com.braintreegateway.Customer)1 CustomerRequest (com.braintreegateway.CustomerRequest)1 ValidationError (com.braintreegateway.ValidationError)1 ValidationErrors (com.braintreegateway.ValidationErrors)1 Test (org.junit.Test)1