bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1765896 - in /bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr: ComposedConstraintsTest.java example/FrenchAddress.java
Date Thu, 20 Oct 2016 22:21:15 GMT
Author: mbenson
Date: Thu Oct 20 22:21:14 2016
New Revision: 1765896

URL: http://svn.apache.org/viewvc?rev=1765896&view=rev
Log:
elaborate on composed constraint tests to verify that BVAL-105 is fixed

Modified:
    bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ComposedConstraintsTest.java
    bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/FrenchAddress.java

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ComposedConstraintsTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ComposedConstraintsTest.java?rev=1765896&r1=1765895&r2=1765896&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ComposedConstraintsTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ComposedConstraintsTest.java Thu
Oct 20 22:21:14 2016
@@ -67,36 +67,36 @@ public class ComposedConstraintsTest ext
     @Test
     public void testValidateComposed() {
         FrenchAddress adr = new FrenchAddress();
-        Set<ConstraintViolation<FrenchAddress>> findings = validator.validate(adr);
-        assertEquals(1, findings.size()); // with @ReportAsSingleConstraintViolation
 
-        ConstraintViolation<FrenchAddress> finding = findings.iterator().next();
-        assertEquals("Wrong zipcode", finding.getMessage());
+        {
+            Set<ConstraintViolation<FrenchAddress>> findings = validator.validate(adr);
+            assertEquals(1, findings.size()); // with @ReportAsSingleConstraintViolation
+            ConstraintViolation<FrenchAddress> finding = findings.iterator().next();
+            assertEquals("Wrong zipcode", finding.getMessage());
+        }
 
         adr.setZipCode("1234567");
-        findings = validator.validate(adr);
-        assertEquals(0, findings.size());
+        assertTrue(validator.validate(adr).isEmpty());
 
         adr.setZipCode("1234567234567");
-        findings = validator.validate(adr);
-        assertTrue(findings.size() > 0); // too long
+        assertEquals(1, validator.validate(adr).size());
+
+        adr.setZipCode2(null);
+        assertEquals(2, validator.validate(adr).size());
     }
 
     @Test
     public void testOverridesAttributeConstraintIndex() {
-        CompanyAddress adr = new CompanyAddress("invalid-string");
-        Set<ConstraintViolation<CompanyAddress>> findings = validator.validate(adr);
+        Set<ConstraintViolation<CompanyAddress>> findings = validator.validate(new
CompanyAddress("invalid-string"));
         assertEquals(2, findings.size()); // without @ReportAsSingleConstraintViolation
         assertNotNull(TestUtils.getViolationWithMessage(findings, "Not COMPANY"));
         assertNotNull(TestUtils.getViolationWithMessage(findings, "Not an email"));
 
-        adr =  new CompanyAddress("JOHN_DO@WEB.DE");
-        findings = validator.validate(adr);
+        findings = validator.validate(new CompanyAddress("JOHN_DO@WEB.DE"));
         assertEquals(1, findings.size());
         assertNotNull(TestUtils.getViolationWithMessage(findings, "Not COMPANY"));
 
-        adr =  new CompanyAddress("JOHN_DO@COMPANY.DE");
-        findings = validator.validate(adr);
+        findings = validator.validate(new CompanyAddress("JOHN_DO@COMPANY.DE"));
         assertTrue(findings.isEmpty());
     }
 

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/FrenchAddress.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/FrenchAddress.java?rev=1765896&r1=1765895&r2=1765896&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/FrenchAddress.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/FrenchAddress.java Thu Oct
20 22:21:14 2016
@@ -27,13 +27,16 @@ public class FrenchAddress {
     @FrenchZipCode(size = 7)
     String zipCode;
 
+    @FrenchZipCode
+    String zipCode2 = "123456";
+
     public FrenchAddress() {
     }
 
     public FrenchAddress(String zipCode) {
         this.zipCode = zipCode;
     }
-    
+
     public String getZipCode() {
         return zipCode;
     }
@@ -42,7 +45,12 @@ public class FrenchAddress {
         this.zipCode = zipCode;
     }
 
-    @FrenchZipCode
-    String zipCode2 = "123456";
+    public String getZipCode2() {
+        return zipCode2;
+    }
+
+    public void setZipCode2(String zipCode2) {
+        this.zipCode2 = zipCode2;
+    }
 
 }



Mime
View raw message