Search in sources :

Example 51 with ValidationAware

use of com.opensymphony.xwork2.interceptor.ValidationAware in project struts by apache.

the class OValValidationInterceptorTest method testSimpleFieldsXML.

public void testSimpleFieldsXML() throws Exception {
    ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleFieldsXML", null, null);
    baseActionProxy.execute();
    Map<String, List<String>> fieldErrors = ((ValidationAware) baseActionProxy.getAction()).getFieldErrors();
    assertNotNull(fieldErrors);
    assertEquals(2, fieldErrors.size());
    assertValue(fieldErrors, "firstName", Collections.singletonList("firstName cannot be null"));
    assertValue(fieldErrors, "lastName", Collections.singletonList("lastName cannot be null"));
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) List(java.util.List) ValidationAware(com.opensymphony.xwork2.interceptor.ValidationAware)

Example 52 with ValidationAware

use of com.opensymphony.xwork2.interceptor.ValidationAware in project struts by apache.

the class OValValidationInterceptorTest method testProgrammaticValidationDontInvokeProgrammatic.

public void testProgrammaticValidationDontInvokeProgrammatic() throws Exception {
    ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleFieldNoProgrammatic", null, null);
    SimpleField action = (SimpleField) baseActionProxy.getAction();
    baseActionProxy.execute();
    Map<String, List<String>> fieldErrors = ((ValidationAware) baseActionProxy.getAction()).getFieldErrors();
    assertNotNull(fieldErrors);
    assertEquals(1, fieldErrors.size());
    assertValue(fieldErrors, "name", Collections.singletonList("name cannot be null"));
    assertFalse(action.isValidateCalled());
    assertFalse(action.isValidateExecuteCalled());
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) List(java.util.List) ValidationAware(com.opensymphony.xwork2.interceptor.ValidationAware)

Aggregations

ValidationAware (com.opensymphony.xwork2.interceptor.ValidationAware)42 ActionProxy (com.opensymphony.xwork2.ActionProxy)38 List (java.util.List)28 HashMap (java.util.HashMap)23 Map (java.util.Map)8 ValueStack (com.opensymphony.xwork2.util.ValueStack)6 Collection (java.util.Collection)5 ModelDrivenAction (org.apache.struts.beanvalidation.actions.ModelDrivenAction)5 ActionContext (com.opensymphony.xwork2.ActionContext)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 ValidationAwareSupport (com.opensymphony.xwork2.ValidationAwareSupport)2 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)2 ConversionData (com.opensymphony.xwork2.conversion.impl.ConversionData)2 ClearableValueStack (com.opensymphony.xwork2.util.ClearableValueStack)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 ValidateGroupAction (org.apache.struts.beanvalidation.actions.ValidateGroupAction)2 HttpParameters (org.apache.struts2.dispatcher.HttpParameters)2 Parameter (org.apache.struts2.dispatcher.Parameter)2 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)1 ActionProxyFactory (com.opensymphony.xwork2.ActionProxyFactory)1