[hibernate-commits] Hibernate SVN: r16006 - in validator/trunk/hibernate-validator/src: main/java/org/hibernate/validation/engine/groups and 2 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Feb 20 04:12:06 EST 2009


Author: hardy.ferentschik
Date: 2009-02-20 04:12:05 -0500 (Fri, 20 Feb 2009)
New Revision: 16006

Added:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Billable.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/BuyInOneClick.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CreditCard.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/User.java
Removed:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/group/
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
Modified:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/Group.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Address.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence1.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence2.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCode.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceChecker.java
Log:
Some directory refactoring

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java	2009-02-20 02:28:00 UTC (rev 16005)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -35,9 +35,9 @@
 import javax.validation.Validator;
 import javax.validation.groups.Default;
 
-import org.hibernate.validation.engine.group.Group;
-import org.hibernate.validation.engine.group.GroupChain;
-import org.hibernate.validation.engine.group.GroupChainGenerator;
+import org.hibernate.validation.engine.groups.Group;
+import org.hibernate.validation.engine.groups.GroupChain;
+import org.hibernate.validation.engine.groups.GroupChainGenerator;
 import org.hibernate.validation.util.PropertyIterator;
 import org.hibernate.validation.util.ReflectionHelper;
 
@@ -103,7 +103,7 @@
 				object, messageInterpolator, constraintValidatorFactory
 		);
 
-		// if no group is specified use the default
+		// if no groups is specified use the default
 		if ( groups.length == 0 ) {
 			groups = DEFAULT_GROUP_ARRAY;
 		}
@@ -264,13 +264,13 @@
 		final Class<T> beanType = ( Class<T> ) object.getClass();
 
 		Set<MetaConstraint> metaConstraints = new HashSet<MetaConstraint>();
-		getMetaConstraintsForPath( beanType, propertyIter, metaConstraints );
+		collectMetaConstraintsForPath( beanType, propertyIter, metaConstraints );
 
 		if ( metaConstraints.size() == 0 ) {
 			return;
 		}
 
-		// if no group is specified use the default
+		// if no groups is specified use the default
 		if ( groups.length == 0 ) {
 			groups = DEFAULT_GROUP_ARRAY;
 		}
@@ -312,13 +312,13 @@
 
 	private <T> void validateValue(Class<T> beanType, Object value, PropertyIterator propertyIter, List<ConstraintViolationImpl<T>> failingConstraintViolations, Class<?>... groups) {
 		Set<MetaConstraint> metaConstraints = new HashSet<MetaConstraint>();
-		getMetaConstraintsForPath( beanType, propertyIter, metaConstraints );
+		collectMetaConstraintsForPath( beanType, propertyIter, metaConstraints );
 
 		if ( metaConstraints.size() == 0 ) {
 			return;
 		}
 
-		// if no group is specified use the default
+		// if no groups is specified use the default
 		if ( groups.length == 0 ) {
 			groups = DEFAULT_GROUP_ARRAY;
 		}
@@ -361,7 +361,7 @@
 	 * @param propertyIter an instance of <code>PropertyIterator</code>
 	 * @param metaConstraints Set of <code>MetaConstraint</code>s to collect all matching constraints.
 	 */
-	private void getMetaConstraintsForPath(Class<?> clazz, PropertyIterator propertyIter, Set<MetaConstraint> metaConstraints) {
+	private void collectMetaConstraintsForPath(Class<?> clazz, PropertyIterator propertyIter, Set<MetaConstraint> metaConstraints) {
 		propertyIter.split();
 
 		if ( !propertyIter.hasNext() ) {
@@ -384,7 +384,7 @@
 							continue;
 						}
 					}
-					getMetaConstraintsForPath( ( Class<?> ) type, propertyIter, metaConstraints );
+					collectMetaConstraintsForPath( ( Class<?> ) type, propertyIter, metaConstraints );
 				}
 			}
 		}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups (from rev 15999, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/group)

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/Group.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/group/Group.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/Group.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
 /*
 * JBoss, Home of Professional Open Source
 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.hibernate.validation.engine.group;
+package org.hibernate.validation.engine.groups;
 
 /**
  * Encapsulates a single group.
@@ -78,7 +78,7 @@
 	@Override
 	public String toString() {
 		return "Group{" +
-				"group=" + group +
+				"groups=" + group +
 				", sequence=" + sequence +
 				'}';
 	}

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/group/GroupChain.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -1,99 +0,0 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.engine.group;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An instance of <code>GroupExecutionChain</code> defines the order in to validate groups during the validation process.
- *
- * @author Hardy Ferentschik
- */
-public class GroupChain {
-
-	private List<Group> groupList = new ArrayList<Group>();
-
-	private int nextGroupPointer = 0;
-
-
-	/**
-	 * @return Returns <code>true</code> if there is another group in the chain <code>false</code> otherwise.
-	 */
-	public boolean hasNext() {
-		return nextGroupPointer <= groupList.size();
-	}
-
-	/**
-	 * @return Returns the next group in the chain or <code>null</code> if there is none.
-	 */
-	public Group next() {
-		if ( hasNext() ) {
-			return groupList.get( nextGroupPointer++ );
-		}
-		else {
-			return null;
-		}
-	}
-
-	/**
-	 * @return The number of groups in this chain.
-	 */
-	public int size() {
-		return groupList.size();
-	}
-
-	public boolean containsSequence(Class<?> groupSequence) {
-		boolean result = false;
-		for ( Group group : groupList ) {
-			if ( groupSequence.getName().equals( group.getSequence() ) ) {
-				result = true;
-				break;
-			}
-		}
-		return result;
-	}
-
-	void insertGroup(Group group) {
-		if ( nextGroupPointer != 0 ) {
-			throw new RuntimeException( "Trying to modify the GroupChain while iterating." );
-		}
-
-		if ( !groupList.contains( group ) ) {
-			groupList.add( group );
-		}
-	}
-
-	void insertSequence(List<Group> groups) {
-		if ( groups == null || groups.size() == 0 ) {
-			return;
-		}
-
-		if ( !containsSequence( groups.get( 0 ).getSequence() ) ) {
-			groupList.addAll( groups );
-		}
-	}
-
-	@Override
-	public String toString() {
-		return "GroupChain{" +
-				"groupList=" + groupList +
-				", nextGroupPointer=" + nextGroupPointer +
-				'}';
-	}
-}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java (from rev 16002, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/group/GroupChain.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -0,0 +1,99 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine.groups;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An instance of <code>GroupExecutionChain</code> defines the order in to validate groups during the validation process.
+ *
+ * @author Hardy Ferentschik
+ */
+public class GroupChain {
+
+	private List<Group> groupList = new ArrayList<Group>();
+
+	private int nextGroupPointer = 0;
+
+
+	/**
+	 * @return Returns <code>true</code> if there is another group in the chain <code>false</code> otherwise.
+	 */
+	public boolean hasNext() {
+		return nextGroupPointer < groupList.size();
+	}
+
+	/**
+	 * @return Returns the next group in the chain or <code>null</code> if there is none.
+	 */
+	public Group next() {
+		if ( hasNext() ) {
+			return groupList.get( nextGroupPointer++ );
+		}
+		else {
+			return null;
+		}
+	}
+
+	/**
+	 * @return The number of groups in this chain.
+	 */
+	public int size() {
+		return groupList.size();
+	}
+
+	public boolean containsSequence(Class<?> groupSequence) {
+		boolean result = false;
+		for ( Group group : groupList ) {
+			if ( groupSequence.getName().equals( group.getSequence() ) ) {
+				result = true;
+				break;
+			}
+		}
+		return result;
+	}
+
+	void insertGroup(Group group) {
+		if ( nextGroupPointer != 0 ) {
+			throw new RuntimeException( "Trying to modify the GroupChain while iterating." );
+		}
+
+		if ( !groupList.contains( group ) ) {
+			groupList.add( group );
+		}
+	}
+
+	void insertSequence(List<Group> groups) {
+		if ( groups == null || groups.size() == 0 ) {
+			return;
+		}
+
+		if ( !containsSequence( groups.get( 0 ).getSequence() ) ) {
+			groupList.addAll( groups );
+		}
+	}
+
+	@Override
+	public String toString() {
+		return "GroupChain{" +
+				"groupList=" + groupList +
+				", nextGroupPointer=" + nextGroupPointer +
+				'}';
+	}
+}
\ No newline at end of file

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/group/GroupChainGenerator.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -1,95 +0,0 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.engine.group;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.validation.GroupSequence;
-import javax.validation.ValidationException;
-
-/**
- * Used to determine the execution order.
- *
- * @author Hardy Ferentschik
- */
-public class GroupChainGenerator {
-
-	private final Map<Class<?>, List<Group>> resolvedSequences = new HashMap<Class<?>, List<Group>>();
-
-	public GroupChain getGroupChainFor(Set<Class<?>> groups) {
-		if ( groups == null || groups.size() == 0 ) {
-			throw new IllegalArgumentException( "At least one group has to be specified." );
-		}
-
-		for ( Class<?> clazz : groups ) {
-			if ( !clazz.isInterface() ) {
-				throw new ValidationException( "A group has to be an interface. " + clazz.getName() + " is not." );
-			}
-		}
-
-		GroupChain chain = new GroupChain();
-		for ( Class<?> clazz : groups ) {
-			if ( clazz.getAnnotation( GroupSequence.class ) == null ) { // normal clazz
-				Group group = new Group( clazz );
-				chain.insertGroup( group );
-			}
-			else {
-				insertSequence( clazz, chain );
-			}
-		}
-
-		return chain;
-	}
-
-	private void insertSequence(Class<?> clazz, GroupChain chain) {
-		List<Group> sequence;
-		if ( resolvedSequences.containsKey( clazz ) ) {
-			sequence = resolvedSequences.get( clazz );
-		}
-		else {
-			sequence = resolveSequence( clazz, new ArrayList<Class<?>>() );
-		}
-		chain.insertSequence( sequence );
-	}
-
-	private List<Group> resolveSequence(Class<?> group, List<Class<?>> processedSequences) {
-		if ( processedSequences.contains( group ) ) {
-			throw new ValidationException( "Cyclic dependecy in group definition" );
-		}
-		else {
-			processedSequences.add( group );
-		}
-		List<Group> resolvedGroupSequence = new ArrayList<Group>();
-		GroupSequence sequenceAnnotation = group.getAnnotation( GroupSequence.class );
-		Class<?>[] sequenceArray = sequenceAnnotation.value();
-		for ( Class clazz : sequenceArray ) {
-			if ( clazz.getAnnotation( GroupSequence.class ) == null ) {
-				resolvedGroupSequence.add( new Group( clazz, group ) );
-			}
-			else {
-				List<Group> tmpSequence = resolveSequence( clazz, processedSequences );
-				resolvedGroupSequence.addAll( tmpSequence );
-			}
-		}
-		resolvedSequences.put( group, resolvedGroupSequence );
-		return resolvedGroupSequence;
-	}
-}

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java (from rev 16002, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/group/GroupChainGenerator.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -0,0 +1,95 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine.groups;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.validation.GroupSequence;
+import javax.validation.ValidationException;
+
+/**
+ * Used to determine the execution order.
+ *
+ * @author Hardy Ferentschik
+ */
+public class GroupChainGenerator {
+
+	private final Map<Class<?>, List<Group>> resolvedSequences = new HashMap<Class<?>, List<Group>>();
+
+	public GroupChain getGroupChainFor(Collection<Class<?>> groups) {
+		if ( groups == null || groups.size() == 0 ) {
+			throw new IllegalArgumentException( "At least one groups has to be specified." );
+		}
+
+		for ( Class<?> clazz : groups ) {
+			if ( !clazz.isInterface() ) {
+				throw new ValidationException( "A groups has to be an interface. " + clazz.getName() + " is not." );
+			}
+		}
+
+		GroupChain chain = new GroupChain();
+		for ( Class<?> clazz : groups ) {
+			if ( clazz.getAnnotation( GroupSequence.class ) == null ) { // normal clazz
+				Group group = new Group( clazz );
+				chain.insertGroup( group );
+			}
+			else {
+				insertSequence( clazz, chain );
+			}
+		}
+
+		return chain;
+	}
+
+	private void insertSequence(Class<?> clazz, GroupChain chain) {
+		List<Group> sequence;
+		if ( resolvedSequences.containsKey( clazz ) ) {
+			sequence = resolvedSequences.get( clazz );
+		}
+		else {
+			sequence = resolveSequence( clazz, new ArrayList<Class<?>>() );
+		}
+		chain.insertSequence( sequence );
+	}
+
+	private List<Group> resolveSequence(Class<?> group, List<Class<?>> processedSequences) {
+		if ( processedSequences.contains( group ) ) {
+			throw new ValidationException( "Cyclic dependecy in groups definition" );
+		}
+		else {
+			processedSequences.add( group );
+		}
+		List<Group> resolvedGroupSequence = new ArrayList<Group>();
+		GroupSequence sequenceAnnotation = group.getAnnotation( GroupSequence.class );
+		Class<?>[] sequenceArray = sequenceAnnotation.value();
+		for ( Class clazz : sequenceArray ) {
+			if ( clazz.getAnnotation( GroupSequence.class ) == null ) {
+				resolvedGroupSequence.add( new Group( clazz, group ) );
+			}
+			else {
+				List<Group> tmpSequence = resolveSequence( clazz, processedSequences );
+				resolvedGroupSequence.addAll( tmpSequence );
+			}
+		}
+		resolvedSequences.put( group, resolvedGroupSequence );
+		return resolvedGroupSequence;
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups (from rev 15999, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group)

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Address.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/Address.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Address.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -1,4 +1,4 @@
-package org.hibernate.validation.engine.group;
+package org.hibernate.validation.engine.groups;
 
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Billable.java (from rev 16002, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/Billable.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Billable.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Billable.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -0,0 +1,9 @@
+package org.hibernate.validation.engine.groups;
+
+/**
+ * Validation group checking whether user is billable.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface Billable {
+}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/BuyInOneClick.java (from rev 16002, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/BuyInOneClick.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/BuyInOneClick.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/BuyInOneClick.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -0,0 +1,9 @@
+package org.hibernate.validation.engine.groups;
+
+/**
+ * Customer can buy without being harrassed by the checking-out process.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface BuyInOneClick {
+}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CreditCard.java (from rev 16002, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/CreditCard.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CreditCard.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CreditCard.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -0,0 +1,34 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine.groups;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class CreditCard {
+
+	private String number;
+
+	public String getNumber() {
+		return number;
+	}
+
+	public void setNumber(String number) {
+		this.number = number;
+	}
+}

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/CyclicGroupSequence.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.hibernate.validation.engine.group;
+package org.hibernate.validation.engine.groups;
 
 import javax.validation.GroupSequence;
 

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence1.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/CyclicGroupSequence1.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence1.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.hibernate.validation.engine.group;
+package org.hibernate.validation.engine.groups;
 
 import javax.validation.GroupSequence;
 

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence2.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/CyclicGroupSequence2.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence2.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.hibernate.validation.engine.group;
+package org.hibernate.validation.engine.groups;
 
 import javax.validation.GroupSequence;
 

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/GroupChainGeneratorTest.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -1,115 +0,0 @@
-// $Id:$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.engine.group;
-
-import java.util.HashSet;
-import java.util.Set;
-import javax.validation.ValidationException;
-import javax.validation.groups.Default;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.hibernate.validation.eg.groups.First;
-import org.hibernate.validation.eg.groups.Last;
-import org.hibernate.validation.eg.groups.Second;
-
-/**
- * @author Hardy Ferentschik
- */
-public class GroupChainGeneratorTest {
-
-	GroupChainGenerator generator;
-
-	@Before
-	public void init() {
-		generator = new GroupChainGenerator();
-	}
-
-	@Test(expected = ValidationException.class)
-	public void testGroupChainForNonInterface() {
-		Set<Class<?>> groups = new HashSet<Class<?>>();
-		groups.add( String.class );
-		generator.getGroupChainFor( groups );
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testGroupChainForNull() {
-		generator.getGroupChainFor( null );
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testGroupChainForEmptySet() {
-		generator.getGroupChainFor( new HashSet<Class<?>>() );
-	}
-
-	@Test(expected = ValidationException.class)
-	public void testCyclicGroupSequences() {
-		Set<Class<?>> groups = new HashSet<Class<?>>();
-		groups.add( CyclicGroupSequence1.class );
-		generator.getGroupChainFor( groups );
-	}
-
-	@Test(expected = ValidationException.class)
-	public void testCyclicGroupSequence() {
-		Set<Class<?>> groups = new HashSet<Class<?>>();
-		groups.add( CyclicGroupSequence.class );
-		generator.getGroupChainFor( groups );
-	}
-
-	@Test
-	public void testGroupDuplicates() {
-		Set<Class<?>> groups = new HashSet<Class<?>>();
-		groups.add( First.class );
-		groups.add( Second.class );
-		groups.add( Last.class );
-		GroupChain chain = generator.getGroupChainFor( groups );
-		assertEquals( "Wrong number of groups", 3, chain.size() );
-
-		groups.clear();
-		groups.add( First.class );
-		groups.add( First.class );
-		chain = generator.getGroupChainFor( groups );
-		assertEquals( "Wrong number of groups", 1, chain.size() );
-
-		groups.clear();
-		groups.add( First.class );
-		groups.add( Last.class );
-		groups.add( First.class );
-		chain = generator.getGroupChainFor( groups );
-		assertEquals( "Wrong number of groups", 2, chain.size() );
-	}
-
-	@Test
-	public void testSequenceResolution() {
-		Set<Class<?>> groups = new HashSet<Class<?>>();
-		groups.add( Address.Complete.class );
-		GroupChain chain = generator.getGroupChainFor( groups );
-		assertEquals( "Wrong number of groups", 2, chain.size() );
-
-		assertTrue( "Should have more groups", chain.hasNext() );
-		assertEquals( "Wrong group", Default.class, chain.next().getGroup() );
-
-		assertTrue( "Should have more groups", chain.hasNext() );
-		assertEquals( "Wrong group", Address.HighLevelCoherence.class, chain.next().getGroup() );
-
-		assertTrue( "There should be no more groups", chain.hasNext() );
-	}
-}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java (from rev 16002, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/GroupChainGeneratorTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -0,0 +1,117 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine.groups;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.validation.ValidationException;
+import javax.validation.groups.Default;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.hibernate.validation.eg.groups.First;
+import org.hibernate.validation.eg.groups.Last;
+import org.hibernate.validation.eg.groups.Second;
+
+import static junit.framework.Assert.assertFalse;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class GroupChainGeneratorTest {
+
+	GroupChainGenerator generator;
+
+	@Before
+	public void init() {
+		generator = new GroupChainGenerator();
+	}
+
+	@Test(expected = ValidationException.class)
+	public void testGroupChainForNonInterface() {
+		Set<Class<?>> groups = new HashSet<Class<?>>();
+		groups.add( String.class );
+		generator.getGroupChainFor( groups );
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testGroupChainForNull() {
+		generator.getGroupChainFor( null );
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testGroupChainForEmptySet() {
+		generator.getGroupChainFor( new HashSet<Class<?>>() );
+	}
+
+	@Test(expected = ValidationException.class)
+	public void testCyclicGroupSequences() {
+		Set<Class<?>> groups = new HashSet<Class<?>>();
+		groups.add( CyclicGroupSequence1.class );
+		generator.getGroupChainFor( groups );
+	}
+
+	@Test(expected = ValidationException.class)
+	public void testCyclicGroupSequence() {
+		Set<Class<?>> groups = new HashSet<Class<?>>();
+		groups.add( CyclicGroupSequence.class );
+		generator.getGroupChainFor( groups );
+	}
+
+	@Test
+	public void testGroupDuplicates() {
+		Set<Class<?>> groups = new HashSet<Class<?>>();
+		groups.add( First.class );
+		groups.add( Second.class );
+		groups.add( Last.class );
+		GroupChain chain = generator.getGroupChainFor( groups );
+		assertEquals( "Wrong number of groups", 3, chain.size() );
+
+		groups.clear();
+		groups.add( First.class );
+		groups.add( First.class );
+		chain = generator.getGroupChainFor( groups );
+		assertEquals( "Wrong number of groups", 1, chain.size() );
+
+		groups.clear();
+		groups.add( First.class );
+		groups.add( Last.class );
+		groups.add( First.class );
+		chain = generator.getGroupChainFor( groups );
+		assertEquals( "Wrong number of groups", 2, chain.size() );
+	}
+
+	@Test
+	public void testSequenceResolution() {
+		Set<Class<?>> groups = new HashSet<Class<?>>();
+		groups.add( Address.Complete.class );
+		GroupChain chain = generator.getGroupChainFor( groups );
+		assertEquals( "Wrong number of groups", 2, chain.size() );
+
+		assertTrue( "Should have more groups", chain.hasNext() );
+		assertEquals( "Wrong groups", Default.class, chain.next().getGroup() );
+
+		assertTrue( "Should have more groups", chain.hasNext() );
+		assertEquals( "Wrong groups", Address.HighLevelCoherence.class, chain.next().getGroup() );
+
+		assertFalse( "There should be no more groups", chain.hasNext() );
+	}
+}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/GroupTest.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -1,181 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,  
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.engine.group;
-
-import java.util.HashSet;
-import java.util.Set;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-import javax.validation.groups.Default;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-import org.hibernate.validation.eg.Animal;
-import org.hibernate.validation.eg.Author;
-import org.hibernate.validation.eg.Book;
-import org.hibernate.validation.eg.DefaultAlias;
-import org.hibernate.validation.eg.Dictonary;
-import org.hibernate.validation.eg.groups.First;
-import org.hibernate.validation.eg.groups.Last;
-import org.hibernate.validation.eg.groups.Second;
-import org.hibernate.validation.util.TestUtil;
-
-/**
- * Tests for the implementation of <code>Validator</code>.
- *
- * @author Hardy Ferentschik
- */
-public class GroupTest {
-
-	@Test
-	public void testGroups() {
-		Validator validator = TestUtil.getValidator();
-
-		Author author = new Author();
-		author.setLastName( "" );
-		author.setFirstName( "" );
-		Book book = new Book();
-		book.setTitle( "" );
-		book.setAuthor( author );
-
-		Set<ConstraintViolation<Book>> constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
-		assertEquals( "Wrong number of constraints", 3, constraintViolations.size() );
-
-		author.setFirstName( "Gavin" );
-		author.setLastName( "King" );
-
-		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
-		ConstraintViolation constraintViolation = constraintViolations.iterator().next();
-		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
-		assertEquals( "Wrong message", "may not be empty", constraintViolation.getMessage() );
-		assertEquals( "Wrong root entity", book, constraintViolation.getRootBean() );
-		assertEquals( "Wrong value", book.getTitle(), constraintViolation.getInvalidValue() );
-		assertEquals( "Wrong propertyName", "title", constraintViolation.getPropertyPath() );
-
-		book.setTitle( "Hibernate Persistence with JPA" );
-		book.setSubtitle( "Revised Edition of Hibernate in Action" );
-
-		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
-		constraintViolation = constraintViolations.iterator().next();
-		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
-		assertEquals( "Wrong message", "length must be between 0 and 30", constraintViolation.getMessage() );
-		assertEquals( "Wrong root entity", book, constraintViolation.getRootBean() );
-		assertEquals( "Wrong value", book.getSubtitle(), constraintViolation.getInvalidValue() );
-		assertEquals( "Wrong propertyName", "subtitle", constraintViolation.getPropertyPath() );
-
-		book.setSubtitle( "Revised Edition" );
-		author.setCompany( "JBoss a divison of RedHat" );
-
-		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
-		constraintViolation = constraintViolations.iterator().next();
-		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
-		assertEquals( "Wrong message", "length must be between 0 and 20", constraintViolation.getMessage() );
-		assertEquals( "Wrong root entity", book, constraintViolation.getRootBean() );
-		assertEquals( "Wrong value", author.getCompany(), constraintViolation.getInvalidValue() );
-		assertEquals( "Wrong propertyName", "author.company", constraintViolation.getPropertyPath() );
-
-		author.setCompany( "JBoss" );
-
-		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
-		assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
-	}
-
-	@Test
-	public void testDefaultGroupSequence() {
-		Validator validator = TestUtil.getValidator();
-
-		Author author = new Author();
-		author.setLastName( "" );
-		author.setFirstName( "" );
-		Book book = new Book();
-		book.setAuthor( author );
-
-		Set<ConstraintViolation<Book>> constraintViolations = validator.validate( book, Default.class );
-		assertEquals( "Wrong number of constraints", 2, constraintViolations.size() );
-
-		author.setFirstName( "Gavin" );
-		author.setLastName( "King" );
-
-		constraintViolations = validator.validate( book, Default.class );
-		ConstraintViolation constraintViolation = constraintViolations.iterator().next();
-		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
-		assertEquals( "Wrong message", "may not be null", constraintViolation.getMessage() );
-		assertEquals( "Wrong root entity", book, constraintViolation.getRootBean() );
-		assertEquals( "Wrong value", book.getTitle(), constraintViolation.getInvalidValue() );
-		assertEquals( "Wrong propertyName", "title", constraintViolation.getPropertyPath() );
-
-		book.setTitle( "Hibernate Persistence with JPA" );
-		book.setSubtitle( "Revised Edition of Hibernate in Action" );
-
-		constraintViolations = validator.validate( book, Default.class );
-		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
-
-		book.setSubtitle( "Revised Edition" );
-		author.setCompany( "JBoss a divison of RedHat" );
-
-		constraintViolations = validator.validate( book, Default.class );
-		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
-
-		author.setCompany( "JBoss" );
-
-		constraintViolations = validator.validate( book, Default.class );
-		assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
-	}
-
-	@Test
-	public void testGroupSequences() {
-		Validator validator = TestUtil.getValidator();
-
-		Dictonary dictonary = new Dictonary();
-		dictonary.setTitle( "English - German" );
-		Author author = new Author();
-		author.setLastName( "-" );
-		author.setFirstName( "-" );
-		author.setCompany( "Langenscheidt Publ." );
-		dictonary.setAuthor( author );
-
-		Set<ConstraintViolation<Dictonary>> constraintViolations = validator.validate( dictonary, DefaultAlias.class );
-		assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
-	}
-
-	@Test
-	public void testValidationFailureInMultipleGroups() {
-		Validator validator = TestUtil.getValidator();
-		Animal elepfant = new Animal();
-		elepfant.setName( "" );
-		elepfant.setDomain( Animal.Domain.EUKARYOTA );
-
-		Set<ConstraintViolation<Animal>> constraintViolations = validator.validate( elepfant, First.class, Second.class );
-		assertEquals(
-				"The should be two invalid constraints since the same propertyName gets validated in both groups",
-				1,
-				constraintViolations.size()
-		);
-
-		ConstraintViolation constraintViolation = constraintViolations.iterator().next();
-		Set<Class<?>> expected = new HashSet<Class<?>>();
-		expected.add( First.class );
-		expected.add( Second.class );
-		assertEquals(
-				"The constraint should be invalid for both groups",
-				expected,
-				constraintViolation.getGroups()
-		);
-	}
-}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java (from rev 16002, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/GroupTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -0,0 +1,218 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,  
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine.groups;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.groups.Default;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+import org.hibernate.validation.eg.Animal;
+import org.hibernate.validation.eg.Author;
+import org.hibernate.validation.eg.Book;
+import org.hibernate.validation.eg.DefaultAlias;
+import org.hibernate.validation.eg.Dictonary;
+import org.hibernate.validation.eg.groups.First;
+import org.hibernate.validation.eg.groups.Last;
+import org.hibernate.validation.eg.groups.Second;
+import org.hibernate.validation.util.TestUtil;
+
+/**
+ * Tests for the group and group sequence feature.
+ *
+ * @author Hardy Ferentschik
+ */
+public class GroupTest {
+
+	@Test
+	public void testGroups() {
+		Validator validator = TestUtil.getValidator();
+
+		Author author = new Author();
+		author.setLastName( "" );
+		author.setFirstName( "" );
+		Book book = new Book();
+		book.setTitle( "" );
+		book.setAuthor( author );
+
+		Set<ConstraintViolation<Book>> constraintViolations = validator.validate(
+				book, First.class, Second.class, Last.class
+		);
+		assertEquals( "Wrong number of constraints", 3, constraintViolations.size() );
+
+		author.setFirstName( "Gavin" );
+		author.setLastName( "King" );
+
+		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
+		ConstraintViolation constraintViolation = constraintViolations.iterator().next();
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+		assertEquals( "Wrong message", "may not be empty", constraintViolation.getMessage() );
+		assertEquals( "Wrong root entity", book, constraintViolation.getRootBean() );
+		assertEquals( "Wrong value", book.getTitle(), constraintViolation.getInvalidValue() );
+		assertEquals( "Wrong propertyName", "title", constraintViolation.getPropertyPath() );
+
+		book.setTitle( "Hibernate Persistence with JPA" );
+		book.setSubtitle( "Revised Edition of Hibernate in Action" );
+
+		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
+		constraintViolation = constraintViolations.iterator().next();
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+		assertEquals( "Wrong message", "length must be between 0 and 30", constraintViolation.getMessage() );
+		assertEquals( "Wrong root entity", book, constraintViolation.getRootBean() );
+		assertEquals( "Wrong value", book.getSubtitle(), constraintViolation.getInvalidValue() );
+		assertEquals( "Wrong propertyName", "subtitle", constraintViolation.getPropertyPath() );
+
+		book.setSubtitle( "Revised Edition" );
+		author.setCompany( "JBoss a divison of RedHat" );
+
+		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
+		constraintViolation = constraintViolations.iterator().next();
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+		assertEquals( "Wrong message", "length must be between 0 and 20", constraintViolation.getMessage() );
+		assertEquals( "Wrong root entity", book, constraintViolation.getRootBean() );
+		assertEquals( "Wrong value", author.getCompany(), constraintViolation.getInvalidValue() );
+		assertEquals( "Wrong propertyName", "author.company", constraintViolation.getPropertyPath() );
+
+		author.setCompany( "JBoss" );
+
+		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
+		assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
+	}
+
+	@Test
+	public void testGroupSequence() {
+		Validator validator = TestUtil.getValidator();
+
+		Author author = new Author();
+		author.setLastName( "" );
+		author.setFirstName( "" );
+		Book book = new Book();
+		book.setAuthor( author );
+
+		Set<ConstraintViolation<Book>> constraintViolations = validator.validate( book, Book.All.class );
+		assertEquals( "Wrong number of constraints", 2, constraintViolations.size() );
+
+		author.setFirstName( "Gavin" );
+		author.setLastName( "King" );
+
+		constraintViolations = validator.validate( book, Book.All.class );
+		ConstraintViolation constraintViolation = constraintViolations.iterator().next();
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+		assertEquals( "Wrong message", "may not be null", constraintViolation.getMessage() );
+		assertEquals( "Wrong root entity", book, constraintViolation.getRootBean() );
+		assertEquals( "Wrong value", book.getTitle(), constraintViolation.getInvalidValue() );
+		assertEquals( "Wrong propertyName", "title", constraintViolation.getPropertyPath() );
+
+		book.setTitle( "Hibernate Persistence with JPA" );
+		book.setSubtitle( "Revised Edition of Hibernate in Action" );
+
+		constraintViolations = validator.validate( book, Book.All.class );
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+
+		book.setSubtitle( "Revised Edition" );
+		author.setCompany( "JBoss a divison of RedHat" );
+
+		constraintViolations = validator.validate( book, Book.All.class );
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+
+		author.setCompany( "JBoss" );
+
+		constraintViolations = validator.validate( book, Book.All.class );
+		assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
+	}
+
+	@Test
+	public void testGroupSequences() {
+		Validator validator = TestUtil.getValidator();
+
+		Dictonary dictonary = new Dictonary();
+		dictonary.setTitle( "English - German" );
+		Author author = new Author();
+		author.setLastName( "-" );
+		author.setFirstName( "-" );
+		author.setCompany( "Langenscheidt Publ." );
+		dictonary.setAuthor( author );
+
+		Set<ConstraintViolation<Dictonary>> constraintViolations = validator.validate( dictonary, DefaultAlias.class );
+		assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
+	}
+
+	@Test
+	public void testValidationFailureInMultipleGroups() {
+		Validator validator = TestUtil.getValidator();
+		Animal elepfant = new Animal();
+		elepfant.setName( "" );
+		elepfant.setDomain( Animal.Domain.EUKARYOTA );
+
+		Set<ConstraintViolation<Animal>> constraintViolations = validator.validate(
+				elepfant, First.class, Second.class
+		);
+		assertEquals(
+				"The should be two invalid constraints since the same propertyName gets validated in both groups",
+				1,
+				constraintViolations.size()
+		);
+
+		ConstraintViolation constraintViolation = constraintViolations.iterator().next();
+		Set<Class<?>> expected = new HashSet<Class<?>>();
+		expected.add( First.class );
+		expected.add( Second.class );
+		assertEquals(
+				"The constraint should be invalid for both groups",
+				expected,
+				constraintViolation.getGroups()
+		);
+	}
+
+	@Test
+	public void testValidateAgainstDifferentGroups() {
+		User user = new User();
+
+		// all fields per default null. Depending on the validation groups there should be  a different amount
+		// of constraint failures.
+		Validator validator = TestUtil.getValidator();
+
+		Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
+		assertEquals( "Wrong number of constraints", 2, constraintViolations.size() );
+
+		constraintViolations = validator.validate( user, Default.class );
+		assertEquals( "Wrong number of constraints", 2, constraintViolations.size() );
+
+		constraintViolations = validator.validate( user, Billable.class );
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+
+		constraintViolations = validator.validate( user, BuyInOneClick.class );
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+
+		constraintViolations = validator.validate( user, BuyInOneClick.class, Billable.class );
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+
+		constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class );
+		assertEquals( "Wrong number of constraints", 3, constraintViolations.size() );
+
+		constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class, Billable.class );
+		assertEquals( "Wrong number of constraints", 3, constraintViolations.size() );
+
+		constraintViolations = validator.validate( user, BuyInOneClick.class, BuyInOneClick.class );
+		assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+	}
+}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/User.java (from rev 16002, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/User.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/User.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/User.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -0,0 +1,43 @@
+package org.hibernate.validation.engine.groups;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+
+/**
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public class User {
+	@NotNull
+	private String firstname;
+
+	@NotNull(groups = Default.class)
+	private String lastname;
+
+	@NotNull(groups = { Billable.class, BuyInOneClick.class })
+	private CreditCard defaultCreditCard;
+
+	public String getFirstname() {
+		return firstname;
+	}
+
+	public void setFirstname(String firstname) {
+		this.firstname = firstname;
+	}
+
+	public String getLastname() {
+		return lastname;
+	}
+
+	public void setLastname(String lastname) {
+		this.lastname = lastname;
+	}
+
+	public CreditCard getDefaultCreditCard() {
+		return defaultCreditCard;
+	}
+
+	public void setDefaultCreditCard(CreditCard defaultCreditCard) {
+		this.defaultCreditCard = defaultCreditCard;
+	}
+}
\ No newline at end of file

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCode.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/ZipCode.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCode.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -1,4 +1,4 @@
-package org.hibernate.validation.engine.group;
+package org.hibernate.validation.engine.groups;
 
 /**
  * @author Emmanuel Bernard

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceChecker.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/group/ZipCodeCoherenceChecker.java	2009-02-19 01:11:40 UTC (rev 15999)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceChecker.java	2009-02-20 09:12:05 UTC (rev 16006)
@@ -1,4 +1,4 @@
-package org.hibernate.validation.engine.group;
+package org.hibernate.validation.engine.groups;
 
 import java.lang.annotation.Target;
 import java.lang.annotation.Retention;




More information about the hibernate-commits mailing list