Author: hardy.ferentschik
Date: 2009-06-25 06:14:40 -0400 (Thu, 25 Jun 2009)
New Revision: 16950
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
Log:
Made sure that no new path node is added when validating a class level consrtaint.
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-06-25
10:13:28 UTC (rev 16949)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-06-25
10:14:40 UTC (rev 16950)
@@ -262,7 +262,9 @@
boolean validationSuccessful = true;
for ( MetaConstraint<T, ?> metaConstraint : beanMetaData.geMetaConstraintList() )
{
PathImpl newPath = PathImpl.createShallowCopy( path );
- newPath.addNode( new NodeImpl( metaConstraint.getPropertyName() ) );
+ if ( !"".equals( metaConstraint.getPropertyName() ) ) {
+ newPath.addNode( new NodeImpl( metaConstraint.getPropertyName() ) );
+ }
localExecutionContext.setPropertyPath( newPath );
if ( isValidationRequired( globalExecutionContext, localExecutionContext,
metaConstraint ) ) {
Object valueToValidate = metaConstraint.getValue(
localExecutionContext.getCurrentBean() );
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-06-25
10:13:28 UTC (rev 16949)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-06-25
10:14:40 UTC (rev 16950)
@@ -32,6 +32,7 @@
import org.hibernate.validation.HibernateValidationProvider;
import org.hibernate.validation.engine.HibernateValidatorConfiguration;
+import org.hibernate.validation.engine.PathImpl;
/**
* Tests for the <code>ReflectionHelper</code>.
@@ -114,8 +115,8 @@
public static void assertConstraintViolation(ConstraintViolation violation, String
errorMessage, Class rootBean, Object invalidValue, String propertyPath) {
assertEquals(
- violation.getPropertyPath().toString(),
- propertyPath,
+ violation.getPropertyPath(),
+ PathImpl.createPathFromString( propertyPath ),
"Wrong propertyPath"
);
assertConstraintViolation( violation, errorMessage, rootBean, invalidValue );
Show replies by date