@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)); }
@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 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 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); }
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); }
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);  }