Example usage for org.springframework.validation BindingResultUtils getRequiredBindingResult

List of usage examples for org.springframework.validation BindingResultUtils getRequiredBindingResult

Introduction

In this page you can find the example usage for org.springframework.validation BindingResultUtils getRequiredBindingResult.

Prototype

public static BindingResult getRequiredBindingResult(Map<?, ?> model, String name) 

Source Link

Document

Find a required BindingResult for the given name in the given model.

Usage

From source file:org.springframework.test.web.portlet.server.result.ModelResultMatchers.java

public PortletResultMatcher attributeHasErrors(final String... names) {
    return new PortletResultMatcher() {
        public void match(PortletMvcResult portletMvcResult) throws Exception {
            Map<String, Object> model = getModel(portletMvcResult);
            for (String name : names) {
                BindingResult result = BindingResultUtils.getRequiredBindingResult(model, name);
                assertTrue("No errors for attribute: " + name, result.hasErrors());
            }//from   w  ww . j  a  v  a 2  s .co m
        }
    };
}

From source file:org.springframework.test.web.portlet.server.result.ModelResultMatchers.java

public PortletResultMatcher attributeHasNoErrors(final String... names) {
    return new PortletResultMatcher() {
        public void match(PortletMvcResult PortletMvcResult) throws Exception {
            Map<String, Object> model = getModel(PortletMvcResult);
            for (String name : names) {
                BindingResult result = BindingResultUtils.getRequiredBindingResult(model, name);
                assertTrue("No errors for attribute: " + name, !result.hasErrors());
            }/*from   ww  w  .j  a v a2  s .co  m*/
        }
    };
}

From source file:org.springframework.test.web.portlet.server.result.ModelResultMatchers.java

public PortletResultMatcher attributeHasFieldErrors(final String name, final String... fieldNames) {
    return new PortletResultMatcher() {
        public void match(PortletMvcResult PortletMvcResult) throws Exception {
            Map<String, Object> model = getModel(PortletMvcResult);
            BindingResult result = BindingResultUtils.getRequiredBindingResult(model, name);
            assertTrue("No errors for attribute: '" + name + "'", result.hasErrors());
            for (final String fieldName : fieldNames) {
                assertTrue("No errors for field: '" + fieldName + "' of attribute: " + name,
                        result.hasFieldErrors(fieldName));
            }/*from  w w w  .j ava  2  s  .  co  m*/
        }
    };
}