Hibernate SVN: r16159 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-15 11:39:59 -0400 (Sun, 15 Mar 2009)
New Revision: 16159
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java
Log:
BVAL-138 BVAL-139 Rework @OverrideAttribute, various typos
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java 2009-03-15 15:16:05 UTC (rev 16158)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java 2009-03-15 15:39:59 UTC (rev 16159)
@@ -30,19 +30,20 @@
*/
public interface ConstraintValidator<A extends Annotation, T> {
/**
- * Validator parameters for a given constraint declaration
- * Annotations parameters are passed as key/value into parameters
+ * Initialize the validator in preparation for isValid calls.
+ * The onstraint annotation for a given constraint declaration
+ * is passed.
* <p/>
* This method is guaranteed to be called before any of the other Constraint
* implementation methods
*
- * @param constraintAnnotation parameters for a given constraint declaration
+ * @param constraintAnnotation annotation instance for a given constraint declaration
*/
void initialize(A constraintAnnotation);
/**
* Implement the validation logic.
- * <code>value</code> state must not be changed by a Constraint implementation
+ * <code>value</code> state must not be altered.
*
* @param value object to validate
* @param constraintValidatorContext context in which the constraint is evaluated
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-03-15 15:16:05 UTC (rev 16158)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-03-15 15:39:59 UTC (rev 16159)
@@ -24,8 +24,8 @@
*/
public interface ConstraintValidatorContext {
/**
- * Disable default error message and default ConstraintViolation object generation.
- * Useful to set a different error message or generate an ConstraintViolation based on
+ * Disable the default error message and default ConstraintViolation object generation.
+ * Useful to set a different error message or generate a ConstraintViolation based on
* a different property
*
* @see #addError(String)
@@ -55,13 +55,21 @@
void addError(String message);
/**
- * Add a new error message to a given sub property <code>property</code>.
+ * Add a new error message to a given sub property <code>property</code>. The subproperty
+ * is relative to the path tot he bean or property hosting the constraint.
+ *
* This error message will be interpolated.
* <p/>
* If <code>isValid</code> returns <code>false</code>, a <code>ConstraintViolation</code> object will be built
* per error message including the default one unless {@link #disableDefaultError()}
* has been called.
* <p/>
+ * Aside from the error message and the property path, <code>ConstraintViolation</code> objects
+ * generated from such a call contain the same contextual information
+ * (root bean, leaf bean etc)
+ * <p/>
+ * This method can be called multiple times. One <code>ConstraintViolation</code> instance per
+ * call is created.
*
* @param message new uninterpolated error message.
* @param property property name the </code>ConstraintViolation</code> is targeting.
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java 2009-03-15 15:16:05 UTC (rev 16158)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java 2009-03-15 15:39:59 UTC (rev 16159)
@@ -40,11 +40,11 @@
/**
* Name of the Constraint attribute overridden.
- * Defaults to the name of the attribute hosting OverridesParameter.
+ * Defaults to the name of the attribute hosting OverridesAttribute.
*
* @return name of constraint attribute overridden.
*/
- String parameter();
+ String name();
/**
* The index of the targeted constraint declaration when using
@@ -56,7 +56,7 @@
*
* @return constraint declaration index if multivalued annotation is used
*/
- int index() default -1;
+ int constraintIndex() default -1;
/**
* Defines several @OverridesAttribute annotations on the same element
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-15 15:16:05 UTC (rev 16158)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-15 15:39:59 UTC (rev 16159)
@@ -244,13 +244,13 @@
private void addOverrideAttributes(Map<ClassIndexWrapper, Map<String, Object>> overrideParameters, Object value, OverridesAttribute... attributes) {
for ( OverridesAttribute attribute : attributes ) {
- ClassIndexWrapper wrapper = new ClassIndexWrapper( attribute.constraint(), attribute.index() );
+ ClassIndexWrapper wrapper = new ClassIndexWrapper( attribute.constraint(), attribute.constraintIndex() );
Map<String, Object> map = overrideParameters.get( wrapper );
if ( map == null ) {
map = new HashMap<String, Object>();
overrideParameters.put( wrapper, map );
}
- map.put( attribute.parameter(), value );
+ map.put( attribute.name(), value );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java 2009-03-15 15:16:05 UTC (rev 16158)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java 2009-03-15 15:39:59 UTC (rev 16159)
@@ -48,13 +48,13 @@
Class<?>[] groups() default { };
@OverridesAttribute.List({
- @OverridesAttribute(constraint = Size.class, parameter = "min"),
- @OverridesAttribute(constraint = Size.class, parameter = "max")
+ @OverridesAttribute(constraint = Size.class, name = "min"),
+ @OverridesAttribute(constraint = Size.class, name = "max")
}) int size() default 5;
@OverridesAttribute(constraint = Size.class,
- parameter = "message") String sizeMessage() default "A french zip code has a length of 5";
+ name = "message") String sizeMessage() default "A french zip code has a length of 5";
- @OverridesAttribute(constraint = Pattern.class, parameter = "regexp", index = 2) String regex() default "\\d*";
+ @OverridesAttribute(constraint = Pattern.class, name = "regexp", constraintIndex = 2) String regex() default "\\d*";
}
15 years, 9 months
Hibernate SVN: r16158 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-15 11:16:05 -0400 (Sun, 15 Mar 2009)
New Revision: 16158
Added:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java
Removed:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameters.java
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Constraint.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ReportAsSingleViolation.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java
Log:
BVAL-138 BVAL-139 Rework @OverrideAttribute, various typos
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/Constraint.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/Constraint.java 2009-03-13 09:51:14 UTC (rev 16157)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/Constraint.java 2009-03-15 15:16:05 UTC (rev 16158)
@@ -31,7 +31,7 @@
* A given constraint annotation should be annotated by a @Constraint
* annotation which refers to its list of constraint validation implementations.
*
- * @author Emmanuel Bernard (emmanuel at hibernate.org)
+ * @author Emmanuel Bernard
* @author Gavin King
* @author Hardy Ferentschik
*/
Copied: beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java (from rev 16157, beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java)
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java (rev 0)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java 2009-03-15 15:16:05 UTC (rev 16158)
@@ -0,0 +1,71 @@
+// $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 javax.validation;
+
+import java.lang.annotation.Annotation;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import java.lang.annotation.Documented;
+
+/**
+ * Mark an attribute as overriding the attribute of a composing constraint.
+ * Both attributes must share the same type.
+ *
+ * @author Emmanuel Bernard
+ */
+@Retention(RUNTIME)
+@Target({ METHOD })
+public @interface OverridesAttribute {
+ /**
+ * @return Constraint type the attribute is overriding
+ */
+ Class<? extends Annotation> constraint();
+
+ /**
+ * Name of the Constraint attribute overridden.
+ * Defaults to the name of the attribute hosting OverridesParameter.
+ *
+ * @return name of constraint attribute overridden.
+ */
+ String parameter();
+
+ /**
+ * The index of the targeted constraint declaration when using
+ * multiple constraints of the same type.
+ * The index represents the index of the constraint in the value() array.
+ *
+ * By default, no index is defined and the single constraint declaration
+ * is targeted
+ *
+ * @return constraint declaration index if multivalued annotation is used
+ */
+ int index() default -1;
+
+ /**
+ * Defines several @OverridesAttribute annotations on the same element
+ * @see {@link OverridesAttribute}
+ */
+ @Documented
+ @Target({ METHOD })
+ @Retention(RUNTIME)
+ public @interface List {
+ OverridesAttribute[] value();
+ }
+}
Property changes on: beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java 2009-03-13 09:51:14 UTC (rev 16157)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java 2009-03-15 15:16:05 UTC (rev 16158)
@@ -1,55 +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 javax.validation;
-
-import java.lang.annotation.Annotation;
-import static java.lang.annotation.ElementType.METHOD;
-import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
-
-/**
- * Mark a parameter as overriding the parameter of a composing constraint.
- * Both parameter must share the same type.
- *
- * @author Emmanuel Bernard
- */
-@Retention(RUNTIME)
-@Target({ METHOD })
-public @interface OverridesParameter {
- /**
- * @return Constraint type the parameter is overriding
- */
- Class<? extends Annotation> constraint();
-
- /**
- * @return name of constraint parameter overridden.
- * Defaults to the name of the parameter hosting the annotation.
- */
- String parameter();
-
- /**
- * @return The index of the targeted constraint declaration when using
- * multiple constraints of the same type.
- * The index represents the index of the constraint in the value() array.
- *
- * By default, no index is defined and the single constraint declaration
- * is targeted
- */
- int index() default -1;
-}
Deleted: beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameters.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameters.java 2009-03-13 09:51:14 UTC (rev 16157)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesParameters.java 2009-03-15 15:16:05 UTC (rev 16158)
@@ -1,34 +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 javax.validation;
-
-import java.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.METHOD;
-import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
-
-/**
- * @author Hardy Ferentschik
- */
-@Documented
-@Target({ METHOD })
-@Retention(RUNTIME)
-public @interface OverridesParameters {
- OverridesParameter[] value();
-}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ReportAsSingleViolation.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ReportAsSingleViolation.java 2009-03-13 09:51:14 UTC (rev 16157)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ReportAsSingleViolation.java 2009-03-15 15:16:05 UTC (rev 16158)
@@ -23,7 +23,7 @@
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
/**
- * A constraint annotation annotated with this annotation
+ * A constraint annotation hosting this annotation
* will return the composed annotation error report if any of the composing annotations
* fail. The error reports of each individual composing constraint is ignored.
*
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-13 09:51:14 UTC (rev 16157)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-03-15 15:16:05 UTC (rev 16158)
@@ -31,8 +31,7 @@
import javax.validation.Constraint;
import javax.validation.ConstraintDescriptor;
import javax.validation.ConstraintValidator;
-import javax.validation.OverridesParameter;
-import javax.validation.OverridesParameters;
+import javax.validation.OverridesAttribute;
import javax.validation.ReportAsSingleViolation;
import javax.validation.ValidationException;
import javax.validation.groups.Default;
@@ -227,31 +226,31 @@
private Map<ClassIndexWrapper, Map<String, Object>> parseOverrideParameters() {
Map<ClassIndexWrapper, Map<String, Object>> overrideParameters = new HashMap<ClassIndexWrapper, Map<String, Object>>();
for ( Method m : annotation.annotationType().getMethods() ) {
- if ( m.getAnnotation( OverridesParameter.class ) != null ) {
- addOverrideParameter(
- overrideParameters, getMethodValue( annotation, m ), m.getAnnotation( OverridesParameter.class )
+ if ( m.getAnnotation( OverridesAttribute.class ) != null ) {
+ addOverrideAttributes(
+ overrideParameters, getMethodValue( annotation, m ), m.getAnnotation( OverridesAttribute.class )
);
}
- else if ( m.getAnnotation( OverridesParameters.class ) != null ) {
- addOverrideParameter(
+ else if ( m.getAnnotation( OverridesAttribute.List.class ) != null ) {
+ addOverrideAttributes(
overrideParameters,
getMethodValue( annotation, m ),
- m.getAnnotation( OverridesParameters.class ).value()
+ m.getAnnotation( OverridesAttribute.List.class ).value()
);
}
}
return overrideParameters;
}
- private void addOverrideParameter(Map<ClassIndexWrapper, Map<String, Object>> overrideParameters, Object value, OverridesParameter... parameters) {
- for ( OverridesParameter parameter : parameters ) {
- ClassIndexWrapper wrapper = new ClassIndexWrapper( parameter.constraint(), parameter.index() );
+ private void addOverrideAttributes(Map<ClassIndexWrapper, Map<String, Object>> overrideParameters, Object value, OverridesAttribute... attributes) {
+ for ( OverridesAttribute attribute : attributes ) {
+ ClassIndexWrapper wrapper = new ClassIndexWrapper( attribute.constraint(), attribute.index() );
Map<String, Object> map = overrideParameters.get( wrapper );
if ( map == null ) {
map = new HashMap<String, Object>();
overrideParameters.put( wrapper, map );
}
- map.put( parameter.parameter(), value );
+ map.put( attribute.parameter(), value );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java 2009-03-13 09:51:14 UTC (rev 16157)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java 2009-03-15 15:16:05 UTC (rev 16158)
@@ -25,8 +25,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
-import javax.validation.OverridesParameter;
-import javax.validation.OverridesParameters;
+import javax.validation.OverridesAttribute;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.constraints.Pattern;
@@ -48,14 +47,14 @@
Class<?>[] groups() default { };
- @OverridesParameters({
- @OverridesParameter(constraint = Size.class, parameter = "min"),
- @OverridesParameter(constraint = Size.class, parameter = "max")
+ @OverridesAttribute.List({
+ @OverridesAttribute(constraint = Size.class, parameter = "min"),
+ @OverridesAttribute(constraint = Size.class, parameter = "max")
}) int size() default 5;
- @OverridesParameter(constraint = Size.class,
+ @OverridesAttribute(constraint = Size.class,
parameter = "message") String sizeMessage() default "A french zip code has a length of 5";
- @OverridesParameter(constraint = Pattern.class, parameter = "regexp", index = 2) String regex() default "\\d*";
+ @OverridesAttribute(constraint = Pattern.class, parameter = "regexp", index = 2) String regex() default "\\d*";
}
15 years, 9 months
Hibernate SVN: r16156 - in validator/trunk/hibernate-validator/src/test: java/org/hibernate/validation/eg and 7 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-13 05:46:38 -0400 (Fri, 13 Mar 2009)
New Revision: 16156
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Actor.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Address.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Boy.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/DefaultAlias.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Engine.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Order.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Person.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/FrenchAddress.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/GermanAddress.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Animal.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Author.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/UnconstraintEntity.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/MultipleMinMax.java
Removed:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Account.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Actor.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Address.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Customer.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/DefaultAlias.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Engine.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/FrenchAddress.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/GermanAddress.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/MultipleMinMax.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/All.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/First.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Last.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Second.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintHelperTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.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/validatorresolution/ValidatorResolutionTest.java
validator/trunk/hibernate-validator/src/test/resources/log4j.properties
Log:
refactored test entities
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -23,7 +23,6 @@
import java.util.Locale;
import java.util.Set;
import javax.validation.Configuration;
-import javax.validation.ConstraintDescriptor;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.ConstraintValidatorFactory;
@@ -46,7 +45,7 @@
import org.hibernate.validation.HibernateValidationProvider;
import org.hibernate.validation.constraints.NotNullValidator;
-import org.hibernate.validation.eg.Customer;
+import org.hibernate.validation.engine.metadata.Customer;
import org.hibernate.validation.engine.ConfigurationImpl;
import org.hibernate.validation.engine.ConstraintValidatorFactoryImpl;
import org.hibernate.validation.engine.HibernateValidatorConfiguration;
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Account.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Account.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Account.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,45 +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.eg;
-
-import javax.validation.Valid;
-
-/**
- * Class with no constraints but with a cascade @Valid annotation
- */
-public class Account {
- private String accountLogin;
- private Customer customer;
-
- public String getAccountLogin() {
- return accountLogin;
- }
-
- public void setAccountLogin(String accountLogin) {
- this.accountLogin = accountLogin;
- }
-
- @Valid
- public Customer getCustomer() {
- return customer;
- }
-
- public void setCustomer(Customer customer) {
- this.customer = customer;
- }
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Actor.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Actor.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Actor.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,89 +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.eg;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.validation.Valid;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Actor implements Person {
-
- private String firstName;
- private String middleName;
- private String lastName;
-
- @Valid
- private List<Actor> playedWith = new ArrayList<Actor>();
-
- public Actor() {
-
- }
-
- public Actor(String firstName, String lastName) {
- this.firstName = firstName;
- this.lastName = lastName;
- }
-
- public List<Actor> getPlayedWith() {
- return playedWith;
- }
-
- public void setPlayedWith(List<Actor> playedWith) {
- this.playedWith = playedWith;
- }
-
- public void addPlayedWith(Actor playedWith) {
- this.playedWith.add( playedWith );
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getMiddleName() {
- return middleName;
- }
-
- public void setMiddleName(String middleName) {
- this.middleName = middleName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- @Override
- public String toString() {
- return "Actor{" +
- "firstName='" + firstName + '\'' +
- ", middleName='" + middleName + '\'' +
- ", lastName='" + lastName + '\'' +
- '}';
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Address.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Address.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Address.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,74 +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.eg;
-
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.validation.constraints.Length;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Address {
- @NotNull
- @Length(max = 30)
- private String addressline1;
-
- @NotNull
- @Length(max = 30)
- private String addressline2;
-
- private String zipCode;
-
- private String city;
-
- public String getAddressline1() {
- return addressline1;
- }
-
- public void setAddressline1(String addressline1) {
- this.addressline1 = addressline1;
- }
-
- public String getAddressline2() {
- return addressline2;
- }
-
- public void setAddressline2(String addressline2) {
- this.addressline2 = addressline2;
- }
-
- public String getZipCode() {
- return zipCode;
- }
-
- public void setZipCode(String zipCode) {
- this.zipCode = zipCode;
- }
-
- @Length(max = 30)
- @NotNull
- public String getCity() {
- return city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-}
-
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,55 +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.eg;
-
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.eg.groups.First;
-import org.hibernate.validation.eg.groups.Second;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Animal {
- public enum Domain {
- PROKARYOTA, EUKARYOTA
- }
-
- @NotEmpty(groups = { First.class, Second.class })
- private String name;
-
- @NotNull(groups = First.class)
- private Domain domain;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Domain getDomain() {
- return domain;
- }
-
- public void setDomain(Domain domain) {
- this.domain = domain;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,65 +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.eg;
-
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.validation.constraints.Length;
-import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.eg.groups.First;
-import org.hibernate.validation.eg.groups.Last;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Author {
-
- @NotEmpty(groups = Last.class)
- private String firstName;
-
- @NotNull(groups = First.class)
- @NotEmpty(groups = First.class)
- private String lastName;
-
- @Length(max = 20, groups = Last.class)
- private String company;
-
- 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 String getCompany() {
- return company;
- }
-
- public void setCompany(String company) {
- this.company = company;
- }
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,72 +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.eg;
-
-import javax.validation.GroupSequence;
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.validation.constraints.Length;
-import org.hibernate.validation.constraints.NotEmpty;
-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 Book {
- @NotNull(groups = First.class)
- @NotEmpty(groups = First.class)
- private String title;
-
- @Length(max = 30, groups = Second.class)
- private String subtitle;
-
- @Valid
- @NotNull(groups = First.class)
- private Author author;
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getSubtitle() {
- return subtitle;
- }
-
- public void setSubtitle(String subtitle) {
- this.subtitle = subtitle;
- }
-
- public Author getAuthor() {
- return author;
- }
-
- public void setAuthor(Author author) {
- this.author = author;
- }
-
- @GroupSequence(value = { First.class, Second.class, Last.class })
- public interface All {
- }
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,65 +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.eg;
-
-import javax.validation.constraints.NotNull;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class Boy implements Person {
-
- private String firstName;
- private String middleName;
- private String lastName;
- private Integer age;
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getMiddleName() {
- return middleName;
- }
-
- public void setMiddleName(String middleName) {
- this.middleName = middleName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public void setAge(Integer age) {
- this.age = age;
- }
-
- @NotNull
- public Integer age() {
- return age;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Customer.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Customer.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Customer.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,67 +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.eg;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.validation.Valid;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Customer implements Person {
-
- private String firstName;
- private String middleName;
- private String lastName;
-
- @Valid
- private List<Order> orderList = new ArrayList<Order>();
-
- public void addOrder(Order order) {
- orderList.add( order );
- }
-
- public List<Order> getOrderList() {
- return orderList;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getMiddleName() {
- return middleName;
- }
-
- public void setMiddleName(String middleName) {
- this.middleName = middleName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/DefaultAlias.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/DefaultAlias.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/DefaultAlias.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,7 +0,0 @@
-package org.hibernate.validation.eg;
-
-/**
- * @author Emmanuel Bernard
- */
-public interface DefaultAlias {
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,59 +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.eg;
-
-import javax.validation.GroupSequence;
-import javax.validation.constraints.NotNull;
-import javax.validation.groups.Default;
-
-import org.hibernate.validation.constraints.NotEmpty;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Dictonary extends Book {
- @NotNull(groups = Translate.class)
- @NotEmpty(groups = Translate.class)
- private String translatesTo;
-
- @NotNull(groups = Translate.class)
- @NotEmpty(groups = Translate.class)
- private String translatesFrom;
-
- public String getTranslatesTo() {
- return translatesTo;
- }
-
- public void setTranslatesTo(String translatesTo) {
- this.translatesTo = translatesTo;
- }
-
- public String getTranslatesFrom() {
- return translatesFrom;
- }
-
- public void setTranslatesFrom(String translatesFrom) {
- this.translatesFrom = translatesFrom;
- }
-
- /**
- * Translator related constraints
- */
- public interface Translate {
- }
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Engine.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Engine.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Engine.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,41 +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.eg;
-
-import javax.validation.constraints.Pattern;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class Engine {
- @Pattern.List({
- @Pattern(regexp = "^[A-Z0-9-]+$",
- message = "must contain alphabetical characters only"),
- @Pattern(regexp = "^....-....-....$", message = "must match ....-....-....")
- })
- private String serialNumber;
-
- public String getSerialNumber() {
- return serialNumber;
- }
-
- public void setSerialNumber(String serialNumber) {
- this.serialNumber = serialNumber;
- }
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/FrenchAddress.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/FrenchAddress.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/FrenchAddress.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,32 +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.eg;
-
-import org.hibernate.validation.constraints.composition.FrenchZipcode;
-
-/**
- * @author Hardy Ferentschik
- */
-public class FrenchAddress extends Address {
-
- @FrenchZipcode
- public String getZipCode() {
- return super.getZipCode();
- }
-
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/GermanAddress.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/GermanAddress.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/GermanAddress.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,32 +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.eg;
-
-import org.hibernate.validation.constraints.composition.GermanZipcode;
-
-/**
- * @author Hardy Ferentschik
- */
-public class GermanAddress extends Address {
-
- @GermanZipcode
- public String getZipCode() {
- return super.getZipCode();
- }
-
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/MultipleMinMax.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/MultipleMinMax.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/MultipleMinMax.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,39 +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.eg;
-
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-
-/**
- * @author Hardy Ferentschik
- */
-public class MultipleMinMax {
- @Min(10l)
- @Max(20l)
- Number number;
-
- @Min(10l)
- @Max(20l)
- String stringNumber;
-
- public MultipleMinMax(String stringNumber, Number number) {
- this.stringNumber = stringNumber;
- this.number = number;
- }
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,36 +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.eg;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Order {
- @NotNull
- Integer orderNumber;
-
- public Integer getOrderNumber() {
- return orderNumber;
- }
-
- public void setOrderNumber(Integer orderNumber) {
- this.orderNumber = orderNumber;
- }
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,37 +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.eg;
-
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.validation.constraints.NotEmpty;
-
-/**
- * @author Hardy Ferentschik
- */
-public interface Person {
- @NotNull
- @NotEmpty
- String getFirstName();
-
- String getMiddleName();
-
- @NotNull
- @NotEmpty
- String getLastName();
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,26 +0,0 @@
-// : Person.java 69 2008-09-08 11:05:07Z hardy.ferentschik $
-/*
-* 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.eg;
-
-/**
- * Empty un-constraint test class.
- *
- * @author Hardy Ferentschik
- */
-public class UnconstraintEntity {
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/All.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/All.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/All.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,8 +0,0 @@
-package org.hibernate.validation.eg.groups;
-
-/**
- * Groups including all validations
- * @author Emmanuel Bernard
- */
-public interface All {
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/First.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/First.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/First.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,9 +0,0 @@
-package org.hibernate.validation.eg.groups;
-
-/**
- * Group executed first in the validation
- *
- * @author Emmanuel Bernard
- */
-public interface First {
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Last.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Last.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Last.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,9 +0,0 @@
-package org.hibernate.validation.eg.groups;
-
-/**
- * Group executed Last in the validation
- *
- * @author Emmanuel Bernard
- */
-public interface Last {
-}
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Second.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Second.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Second.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,9 +0,0 @@
-package org.hibernate.validation.eg.groups;
-
-/**
- * Group executed second during the validation
- *
- * @author Emmanuel Bernard
- */
-public interface Second {
-}
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Actor.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Actor.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Actor.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Actor.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,89 @@
+// $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;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.validation.Valid;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Actor implements Person {
+
+ private String firstName;
+ private String middleName;
+ private String lastName;
+
+ @Valid
+ private List<Actor> playedWith = new ArrayList<Actor>();
+
+ public Actor() {
+
+ }
+
+ public Actor(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public List<Actor> getPlayedWith() {
+ return playedWith;
+ }
+
+ public void setPlayedWith(List<Actor> playedWith) {
+ this.playedWith = playedWith;
+ }
+
+ public void addPlayedWith(Actor playedWith) {
+ this.playedWith.add( playedWith );
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Override
+ public String toString() {
+ return "Actor{" +
+ "firstName='" + firstName + '\'' +
+ ", middleName='" + middleName + '\'' +
+ ", lastName='" + lastName + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Actor.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Address.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Address.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Address.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Address.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,74 @@
+// $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;
+
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.validation.constraints.Length;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Address {
+ @NotNull
+ @Length(max = 30)
+ private String addressline1;
+
+ @NotNull
+ @Length(max = 30)
+ private String addressline2;
+
+ private String zipCode;
+
+ private String city;
+
+ public String getAddressline1() {
+ return addressline1;
+ }
+
+ public void setAddressline1(String addressline1) {
+ this.addressline1 = addressline1;
+ }
+
+ public String getAddressline2() {
+ return addressline2;
+ }
+
+ public void setAddressline2(String addressline2) {
+ this.addressline2 = addressline2;
+ }
+
+ public String getZipCode() {
+ return zipCode;
+ }
+
+ public void setZipCode(String zipCode) {
+ this.zipCode = zipCode;
+ }
+
+ @Length(max = 30)
+ @NotNull
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+}
+
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Address.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/All.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,8 @@
+package org.hibernate.validation.engine;
+
+/**
+ * Groups including all validations
+ * @author Emmanuel Bernard
+ */
+public interface All {
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,147 +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;
-
-import java.util.Set;
-import javax.validation.BeanDescriptor;
-import javax.validation.ConstraintDescriptor;
-import javax.validation.ElementDescriptor;
-import javax.validation.PropertyDescriptor;
-import javax.validation.Validator;
-
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-
-import org.hibernate.validation.eg.Account;
-import org.hibernate.validation.eg.Customer;
-import org.hibernate.validation.eg.Order;
-import org.hibernate.validation.eg.UnconstraintEntity;
-import org.hibernate.validation.util.TestUtil;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class BeanDescriptorImplTest {
-
- @Test
- public void testHasConstraintsAndIsBeanConstrained() {
- Validator validator = TestUtil.getValidator();
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
-
- assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
- assertTrue( "Bean should be constrainted due to @valid ", beanDescriptor.isBeanConstrained() );
-
- beanDescriptor = validator.getConstraintsForClass( Account.class );
- assertTrue(
- "Bean should be constrainted due to @valid", beanDescriptor.isBeanConstrained()
- );
- }
-
- @Test
- public void testUnconstraintClass() {
- Validator validator = TestUtil.getValidator();
- assertFalse(
- "There should be no constraints",
- validator.getConstraintsForClass( UnconstraintEntity.class ).hasConstraints()
- );
- }
-
- @Test
- public void testGetConstraintsForProperty() {
- Validator validator = TestUtil.getValidator();
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
- PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
- assertEquals(
- "There should be one constraint descriptor", 1, propertyDescriptor.getConstraintDescriptors().size()
- );
-
- assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( "foobar" ) );
-
- // TODO Is this corect or should we get a IllegalArgumentException
- assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( null ) );
-
- beanDescriptor = validator.getConstraintsForClass( Customer.class );
- propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
- assertEquals(
- "There should be no constraint descriptors", 0, propertyDescriptor.getConstraintDescriptors().size()
- );
- assertTrue( "The property should be cascaded", propertyDescriptor.isCascaded() );
- }
-
- /**
- * HV-95
- */
- @Test
- public void testGetConstrainedProperties() {
- Validator validator = TestUtil.getValidator();
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
- Set<String> constraintProperties = beanDescriptor.getConstrainedProperties();
- assertEquals( "There should be only one property", 1, constraintProperties.size() );
- assertTrue( "Wrong property", constraintProperties.contains( "orderNumber" ) );
-
- try {
- constraintProperties.add( "foobar" );
- fail( "Set should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
-
- }
-
- try {
- constraintProperties.remove( "orderNumber" );
- fail( "Set should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
-
- }
- }
-
- /**
- * HV-95
- */
- @Test
- public void testElementDescriptorImmutable() {
- Validator validator = TestUtil.getValidator();
- ElementDescriptor elementDescriptor = validator.getConstraintsForClass( Order.class )
- .getConstraintsForProperty( "orderNumber" );
- Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
- assertTrue( "There should be a ConstraintDescriptor", constraintDescriptors.size() == 1 );
- ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
-
- try {
- constraintDescriptors.add( descriptor );
- fail( "Set should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
-
- }
-
- try {
- constraintDescriptors.remove( descriptor );
- fail( "Set should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
-
- }
- }
-}
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Boy.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Boy.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Boy.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Boy.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,65 @@
+// $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;
+
+import javax.validation.constraints.NotNull;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Boy implements Person {
+
+ private String firstName;
+ private String middleName;
+ private String lastName;
+ private Integer age;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public void setAge(Integer age) {
+ this.age = age;
+ }
+
+ @NotNull
+ public Integer age() {
+ return age;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Boy.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -1,167 +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;
-
-import java.util.Set;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-
-import static org.junit.Assert.fail;
-import org.junit.Test;
-
-import org.hibernate.validation.eg.FrenchAddress;
-import org.hibernate.validation.eg.GermanAddress;
-import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
-import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
-import static org.hibernate.validation.util.TestUtil.getValidator;
-
-/**
- * Tests for composing constraints.
- *
- * @author Hardy Ferentschik
- */
-public class ConstraintCompositionTest {
-
- @Test
- public void testComposition() {
- Validator validator = getValidator();
-
- FrenchAddress address = new FrenchAddress();
- address.setAddressline1( "10 rue des Treuils" );
- address.setAddressline2( "BP 12 " );
- address.setCity( "Bordeaux" );
- Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
- assertNumberOfViolations( constraintViolations, 1 );
- assertConstraintViolation(
- constraintViolations.iterator().next(),
- "may not be null",
- FrenchAddress.class,
- null,
- "zipCode"
- );
-
-
- address.setZipCode( "abc" );
- constraintViolations = validator.validate( address );
- assertNumberOfViolations( constraintViolations, 3 );
- for ( ConstraintViolation violation : constraintViolations ) {
- if ( violation.getMessage().equals( "A french zip code has a length of 5" ) ) {
- assertConstraintViolation(
- violation,
- "A french zip code has a length of 5",
- FrenchAddress.class,
- "abc",
- "zipCode"
- );
- }
- else if ( violation.getMessage().equals( "must match \"d*\"" ) ) {
- assertConstraintViolation(
- violation,
- "must match \"d*\"",
- FrenchAddress.class,
- "abc",
- "zipCode"
- );
- }
- else if ( violation.getMessage().equals( "must match \".....\"" ) ) {
- assertConstraintViolation(
- violation,
- "must match \".....\"",
- FrenchAddress.class,
- "abc",
- "zipCode"
- );
- }
- else {
- fail( "Wrong violation found." );
- }
- }
-
-
- address.setZipCode( "123" );
- constraintViolations = validator.validate( address );
- assertNumberOfViolations( constraintViolations, 2 );
- for ( ConstraintViolation violation : constraintViolations ) {
- if ( violation.getMessage().equals( "A french zip code has a length of 5" ) ) {
- assertConstraintViolation(
- violation,
- "A french zip code has a length of 5",
- FrenchAddress.class,
- "123",
- "zipCode"
- );
- }
- else if ( violation.getMessage().equals( "must match \".....\"" ) ) {
- assertConstraintViolation(
- violation,
- "must match \".....\"",
- FrenchAddress.class,
- "123",
- "zipCode"
- );
- }
- else {
- fail( "Wrong violation found." );
- }
- }
-
- address.setZipCode( "33023" );
- constraintViolations = validator.validate( address );
- assertNumberOfViolations( constraintViolations, 0 );
- }
-
- @Test
- public void testNestedComposition() {
- Validator validator = getValidator();
-
- GermanAddress address = new GermanAddress();
- address.setAddressline1( "Rathausstrasse 5" );
- address.setAddressline2( "3ter Stock" );
- address.setCity( "Karlsruhe" );
- Set<ConstraintViolation<GermanAddress>> constraintViolations = validator.validate( address );
- assertNumberOfViolations( constraintViolations, 1 );
- assertConstraintViolation(
- constraintViolations.iterator().next(),
- "Falsche Postnummer.",
- GermanAddress.class,
- null,
- "zipCode"
- );
- }
-
- @Test
- public void testOnlySingleConstraintViolation() {
- Validator validator = getValidator();
-
- GermanAddress address = new GermanAddress();
- address.setAddressline1( "Rathausstrasse 5" );
- address.setAddressline2( "3ter Stock" );
- address.setCity( "Karlsruhe" );
- address.setZipCode( "abc" );
- // actually three composing constraints fail, but due to @ReportAsSingleViolation only one will be reported.
- Set<ConstraintViolation<GermanAddress>> constraintViolations = validator.validate( address );
- assertNumberOfViolations( constraintViolations, 1 );
- assertConstraintViolation(
- constraintViolations.iterator().next(),
- "Falsche Postnummer.",
- GermanAddress.class,
- "abc",
- "zipCode"
- );
- }
-}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintHelperTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintHelperTest.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintHelperTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -32,8 +32,8 @@
import org.hibernate.validation.constraints.invalidvalidators.NoGroups;
import org.hibernate.validation.constraints.invalidvalidators.NoMessage;
import org.hibernate.validation.constraints.invalidvalidators.ValidProperty;
-import org.hibernate.validation.eg.Engine;
-import org.hibernate.validation.eg.Order;
+import org.hibernate.validation.engine.Engine;
+import org.hibernate.validation.engine.Order;
import org.hibernate.validation.util.ReflectionHelper;
/**
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/DefaultAlias.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/DefaultAlias.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/DefaultAlias.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/DefaultAlias.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,7 @@
+package org.hibernate.validation.engine;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public interface DefaultAlias {
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/DefaultAlias.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Engine.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Engine.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Engine.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Engine.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,41 @@
+// $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;
+
+import javax.validation.constraints.Pattern;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Engine {
+ @Pattern.List({
+ @Pattern(regexp = "^[A-Z0-9-]+$",
+ message = "must contain alphabetical characters only"),
+ @Pattern(regexp = "^....-....-....$", message = "must match ....-....-....")
+ })
+ private String serialNumber;
+
+ public String getSerialNumber() {
+ return serialNumber;
+ }
+
+ public void setSerialNumber(String serialNumber) {
+ this.serialNumber = serialNumber;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Engine.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/First.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,9 @@
+package org.hibernate.validation.engine;
+
+/**
+ * Group executed first in the validation
+ *
+ * @author Emmanuel Bernard
+ */
+public interface First {
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Last.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,9 @@
+package org.hibernate.validation.engine;
+
+/**
+ * Group executed Last in the validation
+ *
+ * @author Emmanuel Bernard
+ */
+public interface Last {
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Order.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Order.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Order.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Order.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,36 @@
+// $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;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Order {
+ @NotNull
+ Integer orderNumber;
+
+ public Integer getOrderNumber() {
+ return orderNumber;
+ }
+
+ public void setOrderNumber(Integer orderNumber) {
+ this.orderNumber = orderNumber;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Order.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Person.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Person.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Person.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Person.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,37 @@
+// $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;
+
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.validation.constraints.NotEmpty;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Person {
+ @NotNull
+ @NotEmpty
+ String getFirstName();
+
+ String getMiddleName();
+
+ @NotNull
+ @NotEmpty
+ String getLastName();
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Person.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/groups/Second.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,9 @@
+package org.hibernate.validation.engine;
+
+/**
+ * Group executed second during the validation
+ *
+ * @author Emmanuel Bernard
+ */
+public interface Second {
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -32,16 +32,16 @@
import org.junit.Test;
import org.slf4j.Logger;
-import org.hibernate.validation.eg.Actor;
-import org.hibernate.validation.eg.Address;
-import org.hibernate.validation.eg.Boy;
-import org.hibernate.validation.eg.Customer;
-import org.hibernate.validation.eg.Engine;
-import org.hibernate.validation.eg.Order;
-import org.hibernate.validation.eg.Person;
-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.engine.Actor;
+import org.hibernate.validation.engine.Address;
+import org.hibernate.validation.engine.Boy;
+import org.hibernate.validation.engine.metadata.Customer;
+import org.hibernate.validation.engine.Engine;
+import org.hibernate.validation.engine.Order;
+import org.hibernate.validation.engine.Person;
+import org.hibernate.validation.engine.First;
+import org.hibernate.validation.engine.Last;
+import org.hibernate.validation.engine.Second;
import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.TestUtil;
import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintCompositionTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,167 @@
+// $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.constraintcomposition;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import static org.junit.Assert.fail;
+import org.junit.Test;
+
+import org.hibernate.validation.engine.constraintcomposition.FrenchAddress;
+import org.hibernate.validation.engine.constraintcomposition.GermanAddress;
+import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
+import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
+import static org.hibernate.validation.util.TestUtil.getValidator;
+
+/**
+ * Tests for composing constraints.
+ *
+ * @author Hardy Ferentschik
+ */
+public class ConstraintCompositionTest {
+
+ @Test
+ public void testComposition() {
+ Validator validator = getValidator();
+
+ FrenchAddress address = new FrenchAddress();
+ address.setAddressline1( "10 rue des Treuils" );
+ address.setAddressline2( "BP 12 " );
+ address.setCity( "Bordeaux" );
+ Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
+ assertNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ "may not be null",
+ FrenchAddress.class,
+ null,
+ "zipCode"
+ );
+
+
+ address.setZipCode( "abc" );
+ constraintViolations = validator.validate( address );
+ assertNumberOfViolations( constraintViolations, 3 );
+ for ( ConstraintViolation violation : constraintViolations ) {
+ if ( violation.getMessage().equals( "A french zip code has a length of 5" ) ) {
+ assertConstraintViolation(
+ violation,
+ "A french zip code has a length of 5",
+ FrenchAddress.class,
+ "abc",
+ "zipCode"
+ );
+ }
+ else if ( violation.getMessage().equals( "must match \"d*\"" ) ) {
+ assertConstraintViolation(
+ violation,
+ "must match \"d*\"",
+ FrenchAddress.class,
+ "abc",
+ "zipCode"
+ );
+ }
+ else if ( violation.getMessage().equals( "must match \".....\"" ) ) {
+ assertConstraintViolation(
+ violation,
+ "must match \".....\"",
+ FrenchAddress.class,
+ "abc",
+ "zipCode"
+ );
+ }
+ else {
+ fail( "Wrong violation found." );
+ }
+ }
+
+
+ address.setZipCode( "123" );
+ constraintViolations = validator.validate( address );
+ assertNumberOfViolations( constraintViolations, 2 );
+ for ( ConstraintViolation violation : constraintViolations ) {
+ if ( violation.getMessage().equals( "A french zip code has a length of 5" ) ) {
+ assertConstraintViolation(
+ violation,
+ "A french zip code has a length of 5",
+ FrenchAddress.class,
+ "123",
+ "zipCode"
+ );
+ }
+ else if ( violation.getMessage().equals( "must match \".....\"" ) ) {
+ assertConstraintViolation(
+ violation,
+ "must match \".....\"",
+ FrenchAddress.class,
+ "123",
+ "zipCode"
+ );
+ }
+ else {
+ fail( "Wrong violation found." );
+ }
+ }
+
+ address.setZipCode( "33023" );
+ constraintViolations = validator.validate( address );
+ assertNumberOfViolations( constraintViolations, 0 );
+ }
+
+ @Test
+ public void testNestedComposition() {
+ Validator validator = getValidator();
+
+ GermanAddress address = new GermanAddress();
+ address.setAddressline1( "Rathausstrasse 5" );
+ address.setAddressline2( "3ter Stock" );
+ address.setCity( "Karlsruhe" );
+ Set<ConstraintViolation<GermanAddress>> constraintViolations = validator.validate( address );
+ assertNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ "Falsche Postnummer.",
+ GermanAddress.class,
+ null,
+ "zipCode"
+ );
+ }
+
+ @Test
+ public void testOnlySingleConstraintViolation() {
+ Validator validator = getValidator();
+
+ GermanAddress address = new GermanAddress();
+ address.setAddressline1( "Rathausstrasse 5" );
+ address.setAddressline2( "3ter Stock" );
+ address.setCity( "Karlsruhe" );
+ address.setZipCode( "abc" );
+ // actually three composing constraints fail, but due to @ReportAsSingleViolation only one will be reported.
+ Set<ConstraintViolation<GermanAddress>> constraintViolations = validator.validate( address );
+ assertNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ "Falsche Postnummer.",
+ GermanAddress.class,
+ "abc",
+ "zipCode"
+ );
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/FrenchAddress.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/FrenchAddress.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/FrenchAddress.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/FrenchAddress.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,33 @@
+// $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.constraintcomposition;
+
+import org.hibernate.validation.constraints.composition.FrenchZipcode;
+import org.hibernate.validation.engine.Address;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class FrenchAddress extends Address {
+
+ @FrenchZipcode
+ public String getZipCode() {
+ return super.getZipCode();
+ }
+
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/FrenchAddress.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/GermanAddress.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/GermanAddress.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/GermanAddress.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/GermanAddress.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,33 @@
+// $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.constraintcomposition;
+
+import org.hibernate.validation.constraints.composition.GermanZipcode;
+import org.hibernate.validation.engine.Address;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class GermanAddress extends Address {
+
+ @GermanZipcode
+ public String getZipCode() {
+ return super.getZipCode();
+ }
+
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/GermanAddress.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Animal.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Animal.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Animal.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Animal.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,55 @@
+// $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 javax.validation.constraints.NotNull;
+
+import org.hibernate.validation.constraints.NotEmpty;
+import org.hibernate.validation.engine.First;
+import org.hibernate.validation.engine.Second;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Animal {
+ public enum Domain {
+ PROKARYOTA, EUKARYOTA
+ }
+
+ @NotEmpty(groups = { First.class, Second.class })
+ private String name;
+
+ @NotNull(groups = First.class)
+ private Domain domain;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Domain getDomain() {
+ return domain;
+ }
+
+ public void setDomain(Domain domain) {
+ this.domain = domain;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Animal.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Author.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Author.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Author.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Author.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,65 @@
+// $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 javax.validation.constraints.NotNull;
+
+import org.hibernate.validation.constraints.Length;
+import org.hibernate.validation.constraints.NotEmpty;
+import org.hibernate.validation.engine.First;
+import org.hibernate.validation.engine.Last;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Author {
+
+ @NotEmpty(groups = Last.class)
+ private String firstName;
+
+ @NotNull(groups = First.class)
+ @NotEmpty(groups = First.class)
+ private String lastName;
+
+ @Length(max = 20, groups = Last.class)
+ private String company;
+
+ 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 String getCompany() {
+ return company;
+ }
+
+ public void setCompany(String company) {
+ this.company = company;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Author.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Book.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,73 @@
+// $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 javax.validation.GroupSequence;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.validation.constraints.Length;
+import org.hibernate.validation.constraints.NotEmpty;
+import org.hibernate.validation.engine.First;
+import org.hibernate.validation.engine.Last;
+import org.hibernate.validation.engine.Second;
+import org.hibernate.validation.engine.groups.Author;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Book {
+ @NotNull(groups = First.class)
+ @NotEmpty(groups = First.class)
+ private String title;
+
+ @Length(max = 30, groups = Second.class)
+ private String subtitle;
+
+ @Valid
+ @NotNull(groups = First.class)
+ private Author author;
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getSubtitle() {
+ return subtitle;
+ }
+
+ public void setSubtitle(String subtitle) {
+ this.subtitle = subtitle;
+ }
+
+ public Author getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(Author author) {
+ this.author = author;
+ }
+
+ @GroupSequence(value = { First.class, Second.class, Last.class })
+ public interface All {
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,58 @@
+// $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 javax.validation.constraints.NotNull;
+
+import org.hibernate.validation.constraints.NotEmpty;
+import org.hibernate.validation.engine.groups.Book;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Dictonary extends Book {
+ @NotNull(groups = Translate.class)
+ @NotEmpty(groups = Translate.class)
+ private String translatesTo;
+
+ @NotNull(groups = Translate.class)
+ @NotEmpty(groups = Translate.class)
+ private String translatesFrom;
+
+ public String getTranslatesTo() {
+ return translatesTo;
+ }
+
+ public void setTranslatesTo(String translatesTo) {
+ this.translatesTo = translatesTo;
+ }
+
+ public String getTranslatesFrom() {
+ return translatesFrom;
+ }
+
+ public void setTranslatesFrom(String translatesFrom) {
+ this.translatesFrom = translatesFrom;
+ }
+
+ /**
+ * Translator related constraints
+ */
+ public interface Translate {
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 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/GroupChainGeneratorTest.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -28,9 +28,9 @@
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 org.hibernate.validation.engine.First;
+import org.hibernate.validation.engine.Last;
+import org.hibernate.validation.engine.Second;
/**
* @author Hardy Ferentschik
Modified: 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/GroupTest.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -29,14 +29,14 @@
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.engine.groups.Animal;
+import org.hibernate.validation.engine.groups.Author;
+import org.hibernate.validation.engine.groups.Book;
+import org.hibernate.validation.engine.DefaultAlias;
+import org.hibernate.validation.engine.First;
+import org.hibernate.validation.engine.groups.Dictonary;
+import org.hibernate.validation.engine.Last;
+import org.hibernate.validation.engine.Second;
import org.hibernate.validation.util.TestUtil;
import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Account.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,47 @@
+// $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.metadata;
+
+import javax.validation.Valid;
+
+import org.hibernate.validation.engine.metadata.Customer;
+
+/**
+ * Class with no constraints but with a cascade @Valid annotation
+ */
+public class Account {
+ private String accountLogin;
+ private Customer customer;
+
+ public String getAccountLogin() {
+ return accountLogin;
+ }
+
+ public void setAccountLogin(String accountLogin) {
+ this.accountLogin = accountLogin;
+ }
+
+ @Valid
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/BeanDescriptorImplTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,147 @@
+// $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.metadata;
+
+import java.util.Set;
+import javax.validation.BeanDescriptor;
+import javax.validation.ConstraintDescriptor;
+import javax.validation.ElementDescriptor;
+import javax.validation.PropertyDescriptor;
+import javax.validation.Validator;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import org.hibernate.validation.engine.metadata.Account;
+import org.hibernate.validation.engine.metadata.Customer;
+import org.hibernate.validation.engine.Order;
+import org.hibernate.validation.engine.metadata.UnconstraintEntity;
+import org.hibernate.validation.util.TestUtil;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class BeanDescriptorImplTest {
+
+ @Test
+ public void testHasConstraintsAndIsBeanConstrained() {
+ Validator validator = TestUtil.getValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
+
+ assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
+ assertTrue( "Bean should be constrainted due to @valid ", beanDescriptor.isBeanConstrained() );
+
+ beanDescriptor = validator.getConstraintsForClass( Account.class );
+ assertTrue(
+ "Bean should be constrainted due to @valid", beanDescriptor.isBeanConstrained()
+ );
+ }
+
+ @Test
+ public void testUnconstraintClass() {
+ Validator validator = TestUtil.getValidator();
+ assertFalse(
+ "There should be no constraints",
+ validator.getConstraintsForClass( UnconstraintEntity.class ).hasConstraints()
+ );
+ }
+
+ @Test
+ public void testGetConstraintsForProperty() {
+ Validator validator = TestUtil.getValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
+ assertEquals(
+ "There should be one constraint descriptor", 1, propertyDescriptor.getConstraintDescriptors().size()
+ );
+
+ assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( "foobar" ) );
+
+ // TODO Is this corect or should we get a IllegalArgumentException
+ assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( null ) );
+
+ beanDescriptor = validator.getConstraintsForClass( Customer.class );
+ propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
+ assertEquals(
+ "There should be no constraint descriptors", 0, propertyDescriptor.getConstraintDescriptors().size()
+ );
+ assertTrue( "The property should be cascaded", propertyDescriptor.isCascaded() );
+ }
+
+ /**
+ * HV-95
+ */
+ @Test
+ public void testGetConstrainedProperties() {
+ Validator validator = TestUtil.getValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ Set<String> constraintProperties = beanDescriptor.getConstrainedProperties();
+ assertEquals( "There should be only one property", 1, constraintProperties.size() );
+ assertTrue( "Wrong property", constraintProperties.contains( "orderNumber" ) );
+
+ try {
+ constraintProperties.add( "foobar" );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+
+ }
+
+ try {
+ constraintProperties.remove( "orderNumber" );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+
+ }
+ }
+
+ /**
+ * HV-95
+ */
+ @Test
+ public void testElementDescriptorImmutable() {
+ Validator validator = TestUtil.getValidator();
+ ElementDescriptor elementDescriptor = validator.getConstraintsForClass( Order.class )
+ .getConstraintsForProperty( "orderNumber" );
+ Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
+ assertTrue( "There should be a ConstraintDescriptor", constraintDescriptors.size() == 1 );
+ ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
+
+ try {
+ constraintDescriptors.add( descriptor );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+
+ }
+
+ try {
+ constraintDescriptors.remove( descriptor );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+
+ }
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Customer.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,70 @@
+// $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.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.validation.Valid;
+
+import org.hibernate.validation.engine.Person;
+import org.hibernate.validation.engine.Order;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Customer implements Person {
+
+ private String firstName;
+ private String middleName;
+ private String lastName;
+
+ @Valid
+ private List<Order> orderList = new ArrayList<Order>();
+
+ public void addOrder(Order order) {
+ orderList.add( order );
+ }
+
+ public List<Order> getOrderList() {
+ return orderList;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/UnconstraintEntity.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/UnconstraintEntity.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/UnconstraintEntity.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,26 @@
+// : Person.java 69 2008-09-08 11:05:07Z hardy.ferentschik $
+/*
+* 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.metadata;
+
+/**
+ * Empty un-constraint test class.
+ *
+ * @author Hardy Ferentschik
+ */
+public class UnconstraintEntity {
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/UnconstraintEntity.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/MultipleMinMax.java (from rev 16153, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/MultipleMinMax.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/MultipleMinMax.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/MultipleMinMax.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -0,0 +1,39 @@
+// $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.validatorresolution;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MultipleMinMax {
+ @Min(10l)
+ @Max(20l)
+ Number number;
+
+ @Min(10l)
+ @Max(20l)
+ String stringNumber;
+
+ public MultipleMinMax(String stringNumber, Number number) {
+ this.stringNumber = stringNumber;
+ this.number = number;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/MultipleMinMax.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java 2009-03-13 09:46:38 UTC (rev 16156)
@@ -29,7 +29,7 @@
import static org.junit.Assert.fail;
import org.junit.Test;
-import org.hibernate.validation.eg.MultipleMinMax;
+import org.hibernate.validation.engine.validatorresolution.MultipleMinMax;
import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
import static org.hibernate.validation.util.TestUtil.getValidator;
Modified: validator/trunk/hibernate-validator/src/test/resources/log4j.properties
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/log4j.properties 2009-03-13 09:27:14 UTC (rev 16155)
+++ validator/trunk/hibernate-validator/src/test/resources/log4j.properties 2009-03-13 09:46:38 UTC (rev 16156)
@@ -18,7 +18,7 @@
### set log levels - for more verbose logging change 'info' to 'debug' ###
-log4j.rootLogger=debug, stdout
+log4j.rootLogger=debug, stdout, socket
log4j.logger.org.hibernate.validation.engine.ValidatorImpl=trace
log4j.logger.org.hibernate.validation.engine.ConstraintTree=trace
15 years, 9 months
Hibernate SVN: r16155 - in validator/trunk/hibernate-validator: src/main/java/org/hibernate/validation/engine and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-13 05:27:14 -0400 (Fri, 13 Mar 2009)
New Revision: 16155
Modified:
validator/trunk/hibernate-validator/pom.xml
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
Log:
Now jtype is relocated to org.hibernate.validation.jtype using the share plugin. Relocation will prevent class conflicts in case another version of jtype is in the classpath.
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-03-13 09:00:59 UTC (rev 16154)
+++ validator/trunk/hibernate-validator/pom.xml 2009-03-13 09:27:14 UTC (rev 16155)
@@ -86,6 +86,12 @@
<include>com.googlecode.jtype:jtype</include>
</includes>
</artifactSet>
+ <relocations>
+ <relocation>
+ <pattern>com.googlecode.jtype</pattern>
+ <shadedPattern>org.hibernate.validation.jtype</shadedPattern>
+ </relocation>
+ </relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
</transformers>
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-03-13 09:00:59 UTC (rev 16154)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-03-13 09:27:14 UTC (rev 16155)
@@ -162,6 +162,8 @@
List<Type> suitableTypes = new ArrayList<Type>();
findSuitableValidatorTypes( type, validatorsTypes, suitableTypes );
+ // TODO - do we really have to take the actual value into consideration here as well? Or is it enough to
+ // work with the type the constraint was placed on?
if ( value != null ) {
findSuitableValidatorTypes( determineValueClass( value ), validatorsTypes, suitableTypes );
}
15 years, 9 months
Hibernate SVN: r16154 - in validator/trunk/hibernate-validator/src: test/resources and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-13 05:00:59 -0400 (Fri, 13 Mar 2009)
New Revision: 16154
Removed:
validator/trunk/hibernate-validator/src/test/resources/org/
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java
validator/trunk/hibernate-validator/src/test/resources/ValidationMessages_es.properties
Log:
Fixed broken tests after changes to message interpolation API
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java 2009-03-13 07:06:43 UTC (rev 16153)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java 2009-03-13 09:00:59 UTC (rev 16154)
@@ -40,7 +40,7 @@
int max() default Integer.MAX_VALUE;
- String message() default "{validator.length}";
+ String message() default "{constraint.length}";
Class<?>[] groups() default { };
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java 2009-03-13 07:06:43 UTC (rev 16153)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java 2009-03-13 09:00:59 UTC (rev 16154)
@@ -33,7 +33,7 @@
@Target({ METHOD, FIELD })
@Retention(RUNTIME)
public @interface NotEmpty {
- String message() default "{validator.notEmpty}";
+ String message() default "{constraint.notEmpty}";
Class<?>[] groups() default { };
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/resources/ValidationMessages_es.properties
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/ValidationMessages_es.properties 2009-03-13 07:06:43 UTC (rev 16153)
+++ validator/trunk/hibernate-validator/src/test/resources/ValidationMessages_es.properties 2009-03-13 09:00:59 UTC (rev 16154)
@@ -1 +1 @@
-validator.notNull=no puede ser null
\ No newline at end of file
+constraint.notNull=no puede ser null
\ No newline at end of file
15 years, 9 months
Hibernate SVN: r16153 - validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report.
by hibernate-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-13 03:06:43 -0400 (Fri, 13 Mar 2009)
New Revision: 16153
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
Log:
escape title string
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-03-12 21:33:48 UTC (rev 16152)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-03-13 07:06:43 UTC (rev 16153)
@@ -590,7 +590,7 @@
out.write(("<h4 class=\"sectionHeader\" id=\"" + sectionId + "\">Section " +
sectionId + " - " +
- auditParser.getSectionTitle(sectionId) + "</h4>\n").getBytes());
+ escape(auditParser.getSectionTitle(sectionId)) + "</h4>\n").getBytes());
for (AuditAssertion assertion : sectionAssertions) {
List<SpecReference> coverage = getCoverageForAssertion(sectionId, assertion.getId());
@@ -749,6 +749,11 @@
return result;
}
+ private String escape(String value)
+ {
+ return value.replaceAll("<", "<").replaceAll(">", ">");
+ }
+
private String parseStrikethrough(String text)
{
Matcher m = PATTERN_STRIKETHROUGH.matcher(text);
15 years, 9 months
Hibernate SVN: r16152 - validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-12 17:33:48 -0400 (Thu, 12 Mar 2009)
New Revision: 16152
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/AssertFalse.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/AssertTrue.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/NotNull.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Null.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java
validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages.properties
validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_de.properties
validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_fr.properties
Log:
BVAL-137 prefix for message template key is constraint. instead of validator.
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/AssertFalse.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/AssertFalse.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/AssertFalse.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -37,7 +37,7 @@
@Retention(RUNTIME)
@Documented
public @interface AssertFalse {
- String message() default "{validator.assertFalse}";
+ String message() default "{constraint.assertFalse}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/AssertTrue.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/AssertTrue.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/AssertTrue.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -37,7 +37,7 @@
@Retention(RUNTIME)
@Documented
public @interface AssertTrue {
- String message() default "{validator.assertTrue}";
+ String message() default "{constraint.assertTrue}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -47,7 +47,7 @@
@Retention(RUNTIME)
@Documented
public @interface Digits {
- String message() default "{validator.digits}";
+ String message() default "{constraint.digits}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -48,7 +48,7 @@
@Retention(RUNTIME)
@Documented
public @interface Future {
- String message() default "{validator.future}";
+ String message() default "{constraint.future}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -48,7 +48,7 @@
@Retention(RUNTIME)
@Documented
public @interface Max {
- String message() default "{validator.max}";
+ String message() default "{constraint.max}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -48,7 +48,7 @@
@Retention(RUNTIME)
@Documented
public @interface Min {
- String message() default "{validator.min}";
+ String message() default "{constraint.min}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/NotNull.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/NotNull.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/NotNull.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -35,7 +35,7 @@
@Retention(RUNTIME)
@Documented
public @interface NotNull {
- String message() default "{validator.notNull}";
+ String message() default "{constraint.notNull}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Null.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Null.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Null.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -35,7 +35,7 @@
@Retention(RUNTIME)
@Documented
public @interface Null {
- String message() default "{validator.null}";
+ String message() default "{constraint.null}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -48,7 +48,7 @@
@Retention(RUNTIME)
@Documented
public @interface Past {
- String message() default "{validator.past}";
+ String message() default "{constraint.past}";
Class<?>[] groups() default { };
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -34,7 +34,7 @@
/**
* error message template
*/
- String message() default "{validator.pattern}";
+ String message() default "{constraint.pattern}";
/**
* groups the constraint belongs to
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java 2009-03-12 21:20:47 UTC (rev 16151)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java 2009-03-12 21:33:48 UTC (rev 16152)
@@ -43,7 +43,7 @@
@Retention(RUNTIME)
@Documented
public @interface Size {
- String message() default "{validator.size}";
+ String message() default "{constraint.size}";
Class<?>[] groups() default {};
/**
Modified: validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages.properties
===================================================================
--- validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages.properties 2009-03-12 21:20:47 UTC (rev 16151)
+++ validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages.properties 2009-03-12 21:33:48 UTC (rev 16152)
@@ -1,14 +1,14 @@
# $Id$
-validator.notNull=may not be null
-validator.size=size must be between {min} and {max}
-validator.length=length must be between {min} and {max}
-validator.notEmpty=may not be empty
-validator.pattern=must match "{regexp}"
-validator.min=must be greater than or equal to {value}
-validator.max=must be less than or equal to {value}
-validator.null=must be null
-validator.past=must be in the past
-validator.future=must be in the future
-validator.assertTrue=must be true
-validator.assertFalse=must be false
-validator.digits=numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected)
+constraint.notNull=may not be null
+constraint.size=size must be between {min} and {max}
+constraint.length=length must be between {min} and {max}
+constraint.notEmpty=may not be empty
+constraint.pattern=must match "{regexp}"
+constraint.min=must be greater than or equal to {value}
+constraint.max=must be less than or equal to {value}
+constraint.null=must be null
+constraint.past=must be in the past
+constraint.future=must be in the future
+constraint.assertTrue=must be true
+constraint.assertFalse=must be false
+constraint.digits=numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected)
Modified: validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_de.properties
===================================================================
--- validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_de.properties 2009-03-12 21:20:47 UTC (rev 16151)
+++ validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_de.properties 2009-03-12 21:33:48 UTC (rev 16152)
@@ -1,14 +1,14 @@
# $Id$
-validator.notNull=kann nicht null sein
-validator.size=muss zwischen {min} und {max} liegen
-validator.length=muss zwischen {min} und {max} liegen
-validator.notEmpty=kann nicht leer sein
-validator.pattern=muss auf Ausdruck "{regexp}" passen
-validator.min=muss gr\u00F6ssergleich {value} sein
-validator.max=muss kleinergleich {value} sein
-validator.null=muss null sein
-validator.past=muss in der Vergangenheit liegen
-validator.future=muss in der Zukunft liegen
-validator.assertTrue=muss wahr sein
-validator.assertFalse=muss falsch sein
-validator.digits=numerischer Wert aus\u00DFerhalb erlaubten Wertebereichs (<{integer} Ziffern>.<{fraction} Ziffern> erwarted)
+constraint.notNull=kann nicht null sein
+constraint.size=muss zwischen {min} und {max} liegen
+constraint.length=muss zwischen {min} und {max} liegen
+constraint.notEmpty=kann nicht leer sein
+constraint.pattern=muss auf Ausdruck "{regexp}" passen
+constraint.min=muss gr\u00F6ssergleich {value} sein
+constraint.max=muss kleinergleich {value} sein
+constraint.null=muss null sein
+constraint.past=muss in der Vergangenheit liegen
+constraint.future=muss in der Zukunft liegen
+constraint.assertTrue=muss wahr sein
+constraint.assertFalse=muss falsch sein
+constraint.digits=numerischer Wert aus\u00DFerhalb erlaubten Wertebereichs (<{integer} Ziffern>.<{fraction} Ziffern> erwarted)
Modified: validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_fr.properties
===================================================================
--- validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_fr.properties 2009-03-12 21:20:47 UTC (rev 16151)
+++ validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_fr.properties 2009-03-12 21:33:48 UTC (rev 16152)
@@ -1,13 +1,13 @@
# $Id$
-validator.notNull=ne peut pas \u00EAtre nul
-validator.size=la taille doit \u00EAtre entre {min} et {max}
-validator.length=length must be between {min} and {max}
-validator.notEmpty=ne peut pas \u00EAtre vide
-validator.pattern=doit suivre "{regexp}"
-validator.min=doit \u00EAtre plus grand que {value}
-validator.max=doit \u00EAtre plus petit que {value}
-validator.null=doit \u00EAtre nul
-validator.past=doit \u00EAtre dans le pass\u00E9
-validator.future=doit \u00EAtre dans le futur
-validator.assertTrue=doit \u00EAtre vrai
-validator.assertFalse=doit \u00EAtre faux
+constraint.notNull=ne peut pas \u00EAtre nul
+constraint.size=la taille doit \u00EAtre entre {min} et {max}
+constraint.length=length must be between {min} and {max}
+constraint.notEmpty=ne peut pas \u00EAtre vide
+constraint.pattern=doit suivre "{regexp}"
+constraint.min=doit \u00EAtre plus grand que {value}
+constraint.max=doit \u00EAtre plus petit que {value}
+constraint.null=doit \u00EAtre nul
+constraint.past=doit \u00EAtre dans le pass\u00E9
+constraint.future=doit \u00EAtre dans le futur
+constraint.assertTrue=doit \u00EAtre vrai
+constraint.assertFalse=doit \u00EAtre faux
15 years, 9 months
Hibernate SVN: r16151 - beanvalidation/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-12 17:20:47 -0400 (Thu, 12 Mar 2009)
New Revision: 16151
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java
Log:
BVAL-136 Add Context object for MessageInterpolator
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java 2009-03-12 20:41:54 UTC (rev 16150)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java 2009-03-12 21:20:47 UTC (rev 16151)
@@ -32,25 +32,25 @@
* The locale is defaulted according to the <code>MessageInterpolator</code> implementation
* See the implementation documentation for more detail.
*
- * @param message The message to interpolate.
+ * @param messageTemplate The message to interpolate.
* @param context contextual information related to the interpolation
*
* @return Interpolated error message.
*/
- String interpolate(String message,
+ String interpolate(String messageTemplate,
Context context);
/**
* Interpolate the message from the constraint parameters and the actual validated object.
* The Locale used is provided as a parameter
*
- * @param message The message to interpolate.
+ * @param messageTemplate The message to interpolate.
* @param context contextual information related to the interpolation
* @param locale the locale targeted for the message
*
* @return Interpolated error message.
*/
- String interpolate(String message,
+ String interpolate(String messageTemplate,
Context context,
Locale locale);
15 years, 9 months
Hibernate SVN: r16150 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-12 16:41:54 -0400 (Thu, 12 Mar 2009)
New Revision: 16150
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MessageInterpolatorContext.java
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolator.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java
Log:
BVAL-136 Add Context object for MessageInterpolator
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java 2009-03-12 19:55:18 UTC (rev 16149)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java 2009-03-12 20:41:54 UTC (rev 16150)
@@ -33,28 +33,39 @@
* See the implementation documentation for more detail.
*
* @param message The message to interpolate.
- * @param constraintDescriptor The constraint descriptor.
- * @param value The object being validated
+ * @param context contextual information related to the interpolation
*
* @return Interpolated error message.
*/
String interpolate(String message,
- ConstraintDescriptor<?> constraintDescriptor,
- Object value);
+ Context context);
/**
* Interpolate the message from the constraint parameters and the actual validated object.
* The Locale used is provided as a parameter
*
* @param message The message to interpolate.
- * @param constraintDescriptor The constraint descriptor.
- * @param value The object being validated
+ * @param context contextual information related to the interpolation
* @param locale the locale targeted for the message
*
* @return Interpolated error message.
*/
String interpolate(String message,
- ConstraintDescriptor<?> constraintDescriptor,
- Object value,
+ Context context,
Locale locale);
+
+ /**
+ * Informations related to the interpolation context
+ */
+ static interface Context {
+ /**
+ * @return ConstraintDescriptor corresponding to the constraint being validated
+ */
+ ConstraintDescriptor<?> getConstraintDescriptor();
+
+ /**
+ * @return value being validated
+ */
+ Object getValidatedValue();
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-03-12 19:55:18 UTC (rev 16149)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-03-12 20:41:54 UTC (rev 16150)
@@ -85,7 +85,7 @@
/**
* The message resolver which should be used in this context.
*/
- private final MessageInterpolator messageResolver;
+ private final MessageInterpolator messageInterpolator;
/**
* The constraint factory which should be used in this context.
@@ -97,13 +97,13 @@
*/
private final TraversableResolver traversableResolver;
- public ExecutionContext(T object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver) {
- this( object, object, messageResolver, constraintValidatorFactory, traversableResolver );
+ public ExecutionContext(T object, MessageInterpolator messageInterpolator, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver) {
+ this( object, object, messageInterpolator, constraintValidatorFactory, traversableResolver );
}
- public ExecutionContext(T rootBean, Object object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver) {
+ public ExecutionContext(T rootBean, Object object, MessageInterpolator messageInterpolator, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver) {
this.rootBean = rootBean;
- this.messageResolver = messageResolver;
+ this.messageInterpolator = messageInterpolator;
this.constraintValidatorFactory = constraintValidatorFactory;
this.traversableResolver = traversableResolver;
@@ -282,10 +282,9 @@
public ConstraintViolationImpl<T> createConstraintViolation(Object value, ErrorMessage error) {
ConstraintDescriptor descriptor = currentValidatedProperty.getConstraintDescriptor();
String messageTemplate = error.getMessage();
- String interpolatedMessage = messageResolver.interpolate(
+ String interpolatedMessage = messageInterpolator.interpolate(
messageTemplate,
- descriptor,
- peekCurrentBean()
+ new MessageInterpolatorContext( descriptor, peekCurrentBean() )
);
return new ConstraintViolationImpl<T>(
messageTemplate,
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MessageInterpolatorContext.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MessageInterpolatorContext.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MessageInterpolatorContext.java 2009-03-12 20:41:54 UTC (rev 16150)
@@ -0,0 +1,27 @@
+package org.hibernate.validation.engine;
+
+import javax.validation.MessageInterpolator;
+import javax.validation.ConstraintDescriptor;
+
+/**
+ * Takes mandatory elements in the constructor
+ *
+ * @author Emmanuel Bernard
+ */
+public class MessageInterpolatorContext implements MessageInterpolator.Context {
+ private final ConstraintDescriptor<?> constraintDescriptor;
+ private final Object validatedValue;
+
+ public MessageInterpolatorContext(ConstraintDescriptor<?> constraintDescriptor, Object validatedValue) {
+ this.constraintDescriptor = constraintDescriptor;
+ this.validatedValue = validatedValue;
+ }
+
+ public ConstraintDescriptor<?> getConstraintDescriptor() {
+ return constraintDescriptor;
+ }
+
+ public Object getValidatedValue() {
+ return validatedValue;
+ }
+}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolator.java 2009-03-12 19:55:18 UTC (rev 16149)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolator.java 2009-03-12 20:41:54 UTC (rev 16150)
@@ -24,7 +24,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.validation.ConstraintDescriptor;
import javax.validation.MessageInterpolator;
import org.slf4j.Logger;
@@ -87,17 +86,17 @@
/**
* {@inheritDoc}
*/
- public String interpolate(String message, ConstraintDescriptor<?> constraintDescriptor, Object value) {
+ public String interpolate(String message, Context context) {
// probably no need for caching, but it could be done by parameters since the map
// is immutable and uniquely built per Validation definition, the comparaison has to be based on == and not equals though
- return interpolateMessage( message, constraintDescriptor.getParameters(), defaultLocale );
+ return interpolateMessage( message, context.getConstraintDescriptor().getParameters(), defaultLocale );
}
/**
* {@inheritDoc}
*/
- public String interpolate(String message, ConstraintDescriptor<?> constraintDescriptor, Object value, Locale locale) {
- return interpolateMessage( message, constraintDescriptor.getParameters(), locale );
+ public String interpolate(String message, Context context, Locale locale) {
+ return interpolateMessage( message, context.getConstraintDescriptor().getParameters(), locale );
}
/**
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-03-12 19:55:18 UTC (rev 16149)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-03-12 20:41:54 UTC (rev 16150)
@@ -115,11 +115,11 @@
configuration = Validation.byDefaultProvider().configure();
configuration.messageInterpolator(
new MessageInterpolator() {
- public String interpolate(String message, ConstraintDescriptor<?> constraintDescriptor, Object value) {
+ public String interpolate(String message, Context context) {
return "my custom message";
}
- public String interpolate(String message, ConstraintDescriptor<?> constraintDescriptor, Object value, Locale locale) {
+ public String interpolate(String message, Context context, Locale locale) {
throw new UnsupportedOperationException( "No specific locale is possible" );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java 2009-03-12 19:55:18 UTC (rev 16149)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java 2009-03-12 20:41:54 UTC (rev 16150)
@@ -27,6 +27,7 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.constraints.Max;
+import javax.validation.MessageInterpolator;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
@@ -63,21 +64,21 @@
);
interpolator = new ResourceBundleMessageInterpolator( new TestResourceBundle() );
-
+ MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
String expected = "replacement worked";
- String actual = interpolator.interpolate( "{foo}", descriptor, null );
+ String actual = interpolator.interpolate( "{foo}", context );
assertEquals( "Wrong substitution", expected, actual );
expected = "replacement worked replacement worked";
- actual = interpolator.interpolate( "{foo} {foo}", descriptor, null );
+ actual = interpolator.interpolate( "{foo} {foo}", context );
assertEquals( "Wrong substitution", expected, actual );
expected = "This replacement worked just fine";
- actual = interpolator.interpolate( "This {foo} just fine", descriptor, null );
+ actual = interpolator.interpolate( "This {foo} just fine", context );
assertEquals( "Wrong substitution", expected, actual );
expected = "{} { replacement worked }";
- actual = interpolator.interpolate( "{} { {foo} }", descriptor, null );
+ actual = interpolator.interpolate( "{} { {foo} }", context );
assertEquals( "Wrong substitution", expected, actual );
}
@@ -88,13 +89,14 @@
);
interpolator = new ResourceBundleMessageInterpolator( new TestResourceBundle() );
+ MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
String expected = "foo"; // missing {}
- String actual = interpolator.interpolate( "foo", descriptor, null );
+ String actual = interpolator.interpolate( "foo", context );
assertEquals( "Wrong substitution", expected, actual );
expected = "#{foo {}";
- actual = interpolator.interpolate( "#{foo {}", descriptor, null );
+ actual = interpolator.interpolate( "#{foo {}", context );
assertEquals( "Wrong substitution", expected, actual );
}
@@ -105,9 +107,10 @@
);
interpolator = new ResourceBundleMessageInterpolator( new TestResourceBundle() );
+ MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
String expected = "{bar}"; // unkown token {}
- String actual = interpolator.interpolate( "{bar}", descriptor, null );
+ String actual = interpolator.interpolate( "{bar}", context );
assertEquals( "Wrong substitution", expected, actual );
}
@@ -118,16 +121,18 @@
);
interpolator = new ResourceBundleMessageInterpolator( new TestResourceBundle() );
+ MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
String expected = "may not be null";
- String actual = interpolator.interpolate( notNull.message(), descriptor, null );
+ String actual = interpolator.interpolate( notNull.message(), context );
assertEquals( "Wrong substitution", expected, actual );
ConstraintDescriptorImpl<Size> sizeDescriptor = new ConstraintDescriptorImpl<Size>(
size, new Class<?>[] { }, new ConstraintHelper()
);
expected = "size must be between 0 and 2147483647"; // unkown token {}
- actual = interpolator.interpolate( size.message(), sizeDescriptor, null );
+ context = new MessageInterpolatorContext( sizeDescriptor, null );
+ actual = interpolator.interpolate( size.message(), context );
assertEquals( "Wrong substitution", expected, actual );
}
@@ -140,7 +145,8 @@
interpolator = new ResourceBundleMessageInterpolator();
String expected = "kann nicht null sein";
- String actual = interpolator.interpolate( notNull.message(), descriptor, null, Locale.GERMAN );
+ MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
+ String actual = interpolator.interpolate( notNull.message(), context, Locale.GERMAN );
assertEquals( "Wrong substitution", expected, actual );
}
@@ -151,9 +157,10 @@
);
interpolator = new ResourceBundleMessageInterpolator();
+ MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
String expected = "may not be null";
- String actual = interpolator.interpolate( notNull.message(), descriptor, null, Locale.JAPAN );
+ String actual = interpolator.interpolate( notNull.message(), context, Locale.JAPAN );
assertEquals( "Wrong substitution", expected, actual );
}
@@ -164,9 +171,10 @@
);
interpolator = new ResourceBundleMessageInterpolator();
+ MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
String expected = "no puede ser null";
- String actual = interpolator.interpolate( notNull.message(), descriptor, null, new Locale( "es", "ES" ) );
+ String actual = interpolator.interpolate( notNull.message(), context, new Locale( "es", "ES" ) );
assertEquals( "Wrong substitution", expected, actual );
}
@@ -186,9 +194,10 @@
);
interpolator = new ResourceBundleMessageInterpolator( new TestResourceBundle() );
+ MessageInterpolator.Context context = new MessageInterpolatorContext( constraintDescriptor, null );
String expected = "{replace.in.default.bundle2}";
- String actual = interpolator.interpolate( max.message(), constraintDescriptor, null );
+ String actual = interpolator.interpolate( max.message(), context );
assertEquals( "Within default bundle replacement parameter evauation should not be recursive!", expected, actual );
}
15 years, 9 months