forked from apache/struts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests for AppendingValidatorContext and nested visitor conversion val…
…idation
- Loading branch information
1 parent
2b8a805
commit 46f7f6c
Showing
3 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...test/java/com/opensymphony/xwork2/validator/validators/AppendingValidatorContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.opensymphony.xwork2.validator.validators; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.opensymphony.xwork2.XWorkTestCase; | ||
import com.opensymphony.xwork2.validator.DelegatingValidatorContext; | ||
import com.opensymphony.xwork2.validator.ValidatorContext; | ||
import com.opensymphony.xwork2.validator.VisitorValidatorTestAction; | ||
import com.opensymphony.xwork2.validator.validators.VisitorFieldValidator.AppendingValidatorContext; | ||
|
||
public class AppendingValidatorContextTest extends XWorkTestCase { | ||
|
||
private static final String FIRST_NAME = "first"; | ||
private static final String SECOND_NAME = "second"; | ||
private static final String FIELD_NAME = "fieldName"; | ||
private static final String FULL_FIELD_NAME = FIRST_NAME + "." + SECOND_NAME + "." + FIELD_NAME; | ||
|
||
private VisitorValidatorTestAction action; | ||
private VisitorFieldValidator.AppendingValidatorContext validatorContext; | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
action = new VisitorValidatorTestAction(); | ||
ValidatorContext vc1 = new DelegatingValidatorContext(action); | ||
|
||
VisitorFieldValidator.AppendingValidatorContext vc2 = new AppendingValidatorContext( | ||
vc1, "value", FIRST_NAME, ""); | ||
validatorContext = new AppendingValidatorContext(vc2, "value", SECOND_NAME, ""); | ||
} | ||
|
||
public void testGetFullFieldName() throws Exception { | ||
String fullFieldName = validatorContext.getFullFieldName(FIELD_NAME); | ||
assertEquals(FULL_FIELD_NAME, fullFieldName); | ||
} | ||
|
||
public void testAddFieldError() throws Exception { | ||
validatorContext.addFieldError(FIELD_NAME, "fieldError"); | ||
assertTrue(action.hasFieldErrors()); | ||
|
||
Map<String, List<String>> fieldErrors = action.getFieldErrors(); | ||
assertEquals(1, fieldErrors.size()); | ||
assertTrue(fieldErrors.containsKey(FULL_FIELD_NAME)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters