Code example for MapBindingResult

Methods: hasErrors

0
	public void validate_shouldFailIfEndDateIsBeforeStartDate() throws Exception {
		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<String, String>();
		MapBindingResult errors = new MapBindingResult(map, Relationship.class.getName());
		new RelationshipValidator().validate(relationship, errors);
		Assert.assertEquals(true, errors.hasErrors());
	} 
	 
	/** 
	 * @see {@link RelationshipValidator#validate(Object,Errors)} 
	 */ 
	@Test
	@Verifies(value = "Should pass if end date is after the start date", method = "validate(Relationship)") 
	public void validate_shouldPassIfEndDateIsAfterStartDate() throws Exception {
		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<String, String>();
Contextual code suggestions in your IDE  Get Codota for Java