### Question:
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value);  }### Answer:
@Test public void testReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertTrue("Reference entity validation failed", spySchema.validate(REFERENCE_FIELDNAME, UUID, errors, repo)); }
@Test public void testInvalidReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertFalse("Invalid Reference entity validation failed", spySchema.validate(REFERENCE_FIELDNAME, "45679", errors, repo)); }
@Test public void testNullReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertFalse("Null reference should not be valid", spySchema.validate(REFERENCE_FIELDNAME, null, errors, repo)); }
@Test public void testNonStringReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertFalse("Non-string reference should not be valid", spySchema.validate(REFERENCE_FIELDNAME, new Integer(0), errors, repo)); }
@Test public void testEmptyStringReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertFalse("Non-string reference should not be valid", spySchema.validate(REFERENCE_FIELDNAME, "", errors, repo)); }