| SimpleValidationInterceptor | Line # 14 | 6 | 4 | 100% |
1.0
|
| (3) | |||
| Result | |||
|
0.72727275
|
com.atlassian.xwork.interceptors.TestSimpleValidationInterceptor.testInvokesIfNoErrors
com.atlassian.xwork.interceptors.TestSimpleValidationInterceptor.testInvokesIfNoErrors
|
1 PASS | |
|
0.72727275
|
com.atlassian.xwork.interceptors.TestSimpleValidationInterceptor.testReturnsInputIfNoErrors
com.atlassian.xwork.interceptors.TestSimpleValidationInterceptor.testReturnsInputIfNoErrors
|
1 PASS | |
|
0.45454547
|
com.atlassian.xwork.interceptors.TestSimpleValidationInterceptor.testNonValidatingAction
com.atlassian.xwork.interceptors.TestSimpleValidationInterceptor.testNonValidatingAction
|
1 PASS | |
| 1 | package com.atlassian.xwork.interceptors; | |
| 2 | ||
| 3 | import com.opensymphony.xwork.interceptor.Interceptor; | |
| 4 | import com.opensymphony.xwork.ActionInvocation; | |
| 5 | import com.opensymphony.xwork.Action; | |
| 6 | import com.opensymphony.xwork.ValidationAware; | |
| 7 | import com.opensymphony.xwork.Validateable; | |
| 8 | ||
| 9 | /** | |
| 10 | * Very simple validation interceptor. If an action implements both Validateable | |
| 11 | * and ValidationAware, the interceptor will call the actions Validateable#validate() method, | |
| 12 | * and abort processing of the action (returning INPUT) if the validation results in errors. | |
| 13 | */ | |
| 14 | public class SimpleValidationInterceptor implements Interceptor | |
| 15 | { | |
| 16 | 3 |
public String intercept(ActionInvocation invocation) throws Exception |
| 17 | { | |
| 18 | 3 | Action action = invocation.getAction(); |
| 19 | 3 | if (action instanceof ValidationAware && action instanceof Validateable) |
| 20 | { | |
| 21 | 2 | ((Validateable)action).validate(); |
| 22 | 2 | if (((ValidationAware)action).hasErrors()) |
| 23 | { | |
| 24 | 1 | return Action.INPUT; |
| 25 | } | |
| 26 | } | |
| 27 | ||
| 28 | 2 | return invocation.invoke(); |
| 29 | } | |
| 30 | ||
| 31 | ///CLOVER:OFF | |
| 32 |
public void destroy() |
|
| 33 | { | |
| 34 | } | |
| 35 | ||
| 36 |
public void init() |
|
| 37 | { | |
| 38 | } | |
| 39 | } | |
|
||||||||||