struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [5/8] struts git commit: WW-3952 Updates test to include credit card validation
Date Mon, 24 Apr 2017 08:12:25 GMT
WW-3952 Updates test to include credit card validation


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/eb4fcb4a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/eb4fcb4a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/eb4fcb4a

Branch: refs/heads/master
Commit: eb4fcb4afc79dac03f6ed0780211f98e72a09851
Parents: 0813eaa
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Wed Apr 19 18:07:38 2017 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Wed Apr 19 18:07:38 2017 +0200

----------------------------------------------------------------------
 ...nnotationValidationConfigurationBuilderTest.java | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/eb4fcb4a/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
b/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
index da6df01..1bc0564 100644
--- a/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
@@ -17,6 +17,7 @@ import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 import com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator;
 import com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator;
+import com.opensymphony.xwork2.validator.validators.CreditCardValidator;
 import com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator;
 import com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator;
 import com.opensymphony.xwork2.validator.validators.EmailValidator;
@@ -50,7 +51,7 @@ public class AnnotationValidationConfigurationBuilderTest extends XWorkTestCase
         List<Validator> validators = manager.getValidators(AnnotationValidationAction.class,
null);
 
         // then
-        assertEquals(validators.size(), 16);
+        assertEquals(validators.size(), 17);
         for (Validator validator : validators) {
             validate(validator);
         }
@@ -89,6 +90,8 @@ public class AnnotationValidationConfigurationBuilderTest extends XWorkTestCase
             validateDoubleRangeFieldValidator((DoubleRangeFieldValidator) validator);
         } else if (validator.getValidatorType().equals("email")) {
             validateEmailValidator((EmailValidator) validator);
+        } else if (validator.getValidatorType().equals("creditcard")) {
+            validateCreditCardValidator((CreditCardValidator) validator);
         } else if (validator.getValidatorType().equals("expression")) {
             validateExpressionValidator((ExpressionValidator) validator);
         } else if (validator.getValidatorType().equals("fieldexpression")) {
@@ -203,6 +206,17 @@ public class AnnotationValidationConfigurationBuilderTest extends XWorkTestCase
         assertEquals(true, validator.isTrimed());
     }
 
+    private void validateCreditCardValidator(CreditCardValidator validator) {
+        assertEquals("foo", validator.getFieldName());
+        assertEquals(CreditCardValidator.CREDIT_CARD_PATTERN, validator.getRegex());
+        assertEquals("Foo isn't a valid credit card!", validator.getDefaultMessage());
+        assertEquals("creditCard.key", validator.getMessageKey());
+        assertTrue(Arrays.equals(new String[]{"one", "two", "three"}, validator.getMessageParameters()));
+        assertEquals(true, validator.isShortCircuit());
+        assertEquals(false, validator.isCaseSensitive());
+        assertEquals(true, validator.isTrimed());
+    }
+
     private void validateDoubleRangeFieldValidator(DoubleRangeFieldValidator validator) {
         assertEquals("foo", validator.getFieldName());
         assertEquals("double.key", validator.getMessageKey());


Mime
View raw message