Spring Framework MapBindingResult - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MapBindingResult class.

This code example shows how to use the following methods:hasErrors
	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>();
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:reject
					throw new IllegalStateException("view expression must resolve to a View or String"); 
				} 
			} 
		} 
		catch (Exception e) { 
			MapBindingResult errors = new MapBindingResult(new HashMap<String, Object>(), "dummy"); 
			PrintWriter stackTrace = new PrintWriter(new StringWriter()); 
			e.printStackTrace(stackTrace); 
			errors.reject(errorCode, new Object[] { e, e.getMessage(), stackTrace.toString() }, 
					"A Spring Integration handler raised an exception while handling an HTTP request.  The exception is of type " 
							+ e.getClass() + " and it has a message: (" + e.getMessage() + ")"); 
			modelAndView.addObject(errorsKey, errors); 
		} 
		return modelAndView; 
	} 
 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    @Mock 
    private TeamRepository teamRepository;
 
    @Before 
    public void setup() { 
        bindingResult = new MapBindingResult(new HashMap<>(), "postForm");
        principal = () -> "12345";
 
        controller = new BlogAdminController(blogService, teamRepository, dateFactory); 
    } 
 
    @Test
    public void dashboardShowsUsersPosts() { 
        controller = new BlogAdminController(blogService, teamRepository, dateFactory);
 
        Page<Post> drafts = new PageImpl<>(
                Arrays.asList(new Post("draft post", "body", PostCategory.ENGINEERING)),
                PageableFactory.forDashboard(), 1); 
        Page<Post> scheduled = new PageImpl<>(
                Arrays.asList(new Post("scheduled post", "body", PostCategory.ENGINEERING)),
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java