ValidatingVisitor extends Visitor { @Override void visit(Schema schema) { if (Boolean.FALSE.equals(schema.isNullable()) && isNull(subject)) { failureReporter.failure("value cannot be null", "nullable"); } readWriteValidator.validate(schema, subject); super.visit(schema); } ValidatingVisitor(Object subject, ValidationFailureReporter failureReporter, ReadWriteValidator readWriteValidator,
            ValidationListener validationListener);   }
@Test public void triggersCombinedSchemaEvents() { ValidationListener listener = mock(ValidationListener.class); StringSchema stringSchema = StringSchema.builder().requiresString(true).build(); EmptySchema emptySchema = EmptySchema.builder().build(); ObjectSchema objectSchema = ObjectSchema.builder().requiresObject(true).build(); CombinedSchema combinedSchema = CombinedSchema.builder().criterion(CombinedSchema.ONE_CRITERION) .subschema(stringSchema) .subschema(emptySchema) .subschema(objectSchema) .build(); ValidationFailureReporter reporter = new CollectingFailureReporter(combinedSchema); JSONObject instance = new JSONObject(); new ValidatingVisitor(instance, reporter, ReadWriteValidator.NONE, listener).visit(combinedSchema); ValidationException exc = new InternalValidationException(stringSchema, String.class, instance); verify(listener).combinedSchemaMismatch(new CombinedSchemaMismatchEvent(combinedSchema, stringSchema, instance, exc)); verify(listener).combinedSchemaMatch(new CombinedSchemaMatchEvent(combinedSchema, emptySchema, instance)); verify(listener).combinedSchemaMatch(new CombinedSchemaMatchEvent(combinedSchema, objectSchema, instance)); }