/** * @throws ParseException * @see RelationshipValidator#validate(Object,Errors) */ @Test public void validate_shouldFailIfEndDateIsBeforeStartDate() throws ParseException { Relationship relationship = new Relationship(1); relationship.setStartDate(Context.getDateFormat().parse("18/02/2012")); relationship.setEndDate(Context.getDateFormat().parse("18/02/2001")); Map<String, String> map = new HashMap<>(); MapBindingResult errors = new MapBindingResult(map, Relationship.class.getName()); new RelationshipValidator().validate(relationship, errors); Assert.assertEquals(true, errors.hasErrors()); }
/** * @throws ParseException * @see RelationshipValidator#validate(Object,Errors) */ @Test public void validate_shouldPassIfEndDateIsAfterStartDate() throws ParseException { Relationship relationship = new Relationship(1); relationship.setStartDate(Context.getDateFormat().parse("18/02/2012")); relationship.setEndDate(Context.getDateFormat().parse("18/03/2012")); Map<String, String> map = new HashMap<>(); MapBindingResult errors = new MapBindingResult(map, Relationship.class.getName()); new RelationshipValidator().validate(relationship, errors); Assert.assertFalse(errors.hasErrors()); }
r.setRelationshipType(rt); r.setStartDate(df.parse("1980-01-01")); r.setEndDate(df.parse("2010-01-01")); personService.saveRelationship(r); rels.add(r); r.setRelationshipType(rt); r.setStartDate(df.parse("1990-01-01")); r.setEndDate(df.parse("2010-01-01")); personService.saveRelationship(r); rels.add(r); r.setRelationshipType(rt); r.setStartDate(df.parse("1980-01-01")); r.setEndDate(df.parse("1990-01-01")); personService.saveRelationship(r); rels.add(r); r.setPersonB(personB); r.setRelationshipType(rt); r.setEndDate(df.parse("1980-01-01")); personService.saveRelationship(r); rels.add(r); r.setPersonB(personB); r.setRelationshipType(rt); r.setEndDate(df.parse("1990-01-01")); personService.saveRelationship(r); rels.add(r);