@Test
public void multipleSchemaDepViolation() {

    Schema billingAddressSchema = new StringSchema();
    Schema billingNameSchema = StringSchema.builder().minLength(4).build();
    ObjectSchema subject = ObjectSchema.builder()
            .addPropertySchema("name", new StringSchema())
            .addPropertySchema("credit_card", NumberSchema.builder().build())
            .schemaDependency("credit_card", ObjectSchema.builder()
                    .addPropertySchema("billing_address", billingAddressSchema)
                    .addRequiredProperty("billing_address")
                    .addPropertySchema("billing_name", billingNameSchema)
                    .build())
            .schemaDependency("name", ObjectSchema.builder()
                    .addRequiredProperty("age")
                    .build())
            .build();
    try {
        subject.validate(OBJECTS.get("schemaDepViolation"));
        fail("did not throw ValidationException");
    } catch (ValidationException e) {
        ValidationException creditCardFailure = e.getCausingExceptions().get(0);
        ValidationException ageFailure = e.getCausingExceptions().get(1);
        // due to schemaDeps being stored in (unsorted) HashMap, the exceptions may need to be swapped
        if (creditCardFailure.getCausingExceptions().isEmpty()) {
            ValidationException tmp = creditCardFailure;
            creditCardFailure = ageFailure;
            ageFailure = tmp;
        }
        ValidationException billingAddressFailure = creditCardFailure.getCausingExceptions().get(0);
        assertEquals("#/billing_address", billingAddressFailure.getPointerToViolation());
        assertEquals(billingAddressSchema, billingAddressFailure.getViolatedSchema());
        ValidationException billingNameFailure = creditCardFailure
                .getCausingExceptions().get(1);
        assertEquals("#/billing_name", billingNameFailure.getPointerToViolation());
        assertEquals(billingNameSchema, billingNameFailure.getViolatedSchema());
        assertEquals("#", ageFailure.getPointerToViolation());
        assertEquals("#: required key [age] not found", ageFailure.getMessage());
    }
}