DeletedOnGreaterThenCreatedOnConstraintValidator implements
        Validator<DeletedOnGreaterThenCreatedOnConstraint> { @Override public boolean isValid(Object value) { if (value instanceof History) { History history = (History) value; Date deletedOn = history.getDeletedOn(); Date createdOn = history.getCreatedOn(); return deletedOn != null ? deletedOn.compareTo(createdOn) > 0 : true; } return false; }  @Override void initialize(DeletedOnGreaterThenCreatedOnConstraint parameters); @Override boolean isValid(Object value);  }
@Test public void isValidParametarNotFile() { assertFalse("string object is valid.", validator .isValid("a string object")); }
@Test public void isValidNullDeletedOn() { assertTrue("not valid when deleted on is null.", validator .isValid(new History())); }
@Test public void isValid() { History history = new History(); history.setCreatedOn(CREATED_ON); history.setDeletedOn(DELETED_ON); assertTrue("not valid when deleted on is greater then created on.", validator.isValid(history)); }
@Test public void isValidCreatedOnEqualsDeletedOn() { History history = new History(); history.setCreatedOn(CREATED_ON); history.setDeletedOn(CREATED_ON); assertFalse("valid when created on equals deleted on.", validator .isValid(history)); }
@Test public void isValidDeletedOnBeforeCreatedOnCreatedOn() { History history = new History(); history.setCreatedOn(CREATED_ON); history.setDeletedOn(DELETED_ON_BEFORE_CREATED_ON); assertFalse("valid when deleted on before created on.", validator .isValid(history)); }