Author: epbernard
Date: 2009-05-05 06:12:04 -0400 (Tue, 05 May 2009)
New Revision: 16508
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java
Log:
add tests related to sequences and graphs
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Child.java 2009-05-05
10:12:04 UTC (rev 16508)
@@ -0,0 +1,19 @@
+package org.hibernate.validation.engine.graphnavigation;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Child {
+ private String name;
+
+ @NotNull(groups = ChildFirst.class)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ChildFirst.java 2009-05-05
10:12:04 UTC (rev 16508)
@@ -0,0 +1,7 @@
+package org.hibernate.validation.engine.graphnavigation;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public interface ChildFirst {
+}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java 2009-05-04
17:06:34 UTC (rev 16507)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java 2009-05-05
10:12:04 UTC (rev 16508)
@@ -22,6 +22,7 @@
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
+import javax.validation.Validation;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -111,4 +112,14 @@
constraintViolations = validator.validate( john );
assertEquals( constraintViolations.size(), 0, "Wrong number of constraints"
);
}
+
+ @Test
+ public void testFullGraphValidationBeforeNextGroupInSequence() {
+ Parent p = new Parent();
+ p.setChild( new Child() );
+ Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
+ Set<ConstraintViolation<Parent>> errors = validator.validate( p,
ProperOrder.class );
+ assertEquals( 1, errors.size() );
+ assertEquals( "child.name", errors.iterator().next().getPropertyPath() );
+ }
}
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Parent.java 2009-05-05
10:12:04 UTC (rev 16508)
@@ -0,0 +1,30 @@
+package org.hibernate.validation.engine.graphnavigation;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.Valid;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Parent {
+ private String name;
+ private Child child;
+
+ @NotNull(groups = ParentSecond.class)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Valid
+ public Child getChild() {
+ return child;
+ }
+
+ public void setChild(Child child) {
+ this.child = child;
+ }
+}
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ParentSecond.java 2009-05-05
10:12:04 UTC (rev 16508)
@@ -0,0 +1,7 @@
+package org.hibernate.validation.engine.graphnavigation;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public interface ParentSecond {
+}
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/ProperOrder.java 2009-05-05
10:12:04 UTC (rev 16508)
@@ -0,0 +1,10 @@
+package org.hibernate.validation.engine.graphnavigation;
+
+import javax.validation.GroupSequence;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@GroupSequence( {ChildFirst.class, ParentSecond.class } )
+public interface ProperOrder {
+}
Show replies by date