[hibernate-commits] Hibernate SVN: r16186 - validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Mar 19 10:16:07 EDT 2009


Author: hardy.ferentschik
Date: 2009-03-19 10:16:07 -0400 (Thu, 19 Mar 2009)
New Revision: 16186

Added:
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java
Removed:
   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/ElementDescriptorImplTest.java
Log:
HV-116

Deleted: 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/BeanDescriptorImplTest.java	2009-03-19 13:55:43 UTC (rev 16185)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java	2009-03-19 14:16:07 UTC (rev 16186)
@@ -1,165 +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.metadata;
-
-import java.util.Set;
-import javax.validation.BeanDescriptor;
-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.Order;
-import org.hibernate.validation.util.TestUtil;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class BeanDescriptorImplTest {
-
-	@Test
-	public void testIsBeanConstrained() {
-		Validator validator = TestUtil.getValidator();
-		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
-
-		// constraint via @Valid
-		assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
-		assertTrue( "Bean should be constrainted due to @valid ", beanDescriptor.isBeanConstrained() );
-
-		// constraint hosted on bean itself
-		beanDescriptor = validator.getConstraintsForClass( Account.class );
-		assertTrue( "There should be direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
-		assertTrue( "Bean should be constrainted due to @valid", beanDescriptor.isBeanConstrained() );
-
-		// constraint on bean property
-		beanDescriptor = validator.getConstraintsForClass( Order.class );
-		assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
-		assertTrue( "Bean should be constrainted due to @NotNull", beanDescriptor.isBeanConstrained() );
-	}
-
-	@Test
-	public void testUnconstraintClass() {
-		Validator validator = TestUtil.getValidator();
-		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
-		assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
-		assertFalse( "Bean should be unconstrainted.", beanDescriptor.isBeanConstrained() );
-	}
-
-	@Test
-	public void testGetConstraintForExistingConstrainedProperty() {
-		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()
-		);
-
-		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() );
-	}
-
-	@Test
-	public void testGetConstraintForUnConstrainedProperty() {
-		Validator validator = TestUtil.getValidator();
-		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
-		PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
-		assertEquals(
-				"There should be no constraint descriptors", 0, propertyDescriptor.getConstraintDescriptors().size()
-		);
-		assertTrue( "The property should be cascaded", propertyDescriptor.isCascaded() );
-	}
-
-	@Test
-	public void testGetConstraintsForNonExistingProperty() {
-		Validator validator = TestUtil.getValidator();
-		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
-		assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( "foobar" ) );
-	}
-
-	/**
-	 * @todo Is this corect or should we get a IllegalArgumentException
-	 */
-	@Test
-	public void testGetConstraintsForNullProperty() {
-		Validator validator = TestUtil.getValidator();
-		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
-		assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( null ) );
-	}
-
-	/**
-	 * HV-95
-	 */
-	@Test
-	public void testGetConstrainedProperties() {
-		Validator validator = TestUtil.getValidator();
-		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
-		Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
-		assertEquals( "There should be only one property", 1, constraintProperties.size() );
-		boolean hasOrderNumber = false;
-		for ( PropertyDescriptor pd : constraintProperties ) {
-			hasOrderNumber |= pd.getPropertyName().equals( "orderNumber" );
-		}
-		assertTrue( "Wrong property", hasOrderNumber );
-	}
-
-	/**
-	 * HV-95
-	 */
-	@Test
-	public void testGetConstrainedPropertiesImmutable() {
-		Validator validator = TestUtil.getValidator();
-		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
-		Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
-		try {
-			constraintProperties.add( null );
-			fail( "Set should be immutable" );
-		}
-		catch ( UnsupportedOperationException e ) {
-
-		}
-
-		try {
-			constraintProperties.remove( constraintProperties.iterator().next() );
-			fail( "Set should be immutable" );
-		}
-		catch ( UnsupportedOperationException e ) {
-
-		}
-	}
-
-	/**
-	 * HV-95
-	 */
-	@Test
-	public void testGetConstrainedPropertiesForUnconstraintEntity() {
-		Validator validator = TestUtil.getValidator();
-		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
-		Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
-		assertEquals( "We should get the empty set.", 0, constraintProperties.size() );
-	}
-}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java (from rev 16185, 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/BeanDescriptorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java	2009-03-19 14:16:07 UTC (rev 16186)
@@ -0,0 +1,165 @@
+// $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.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.Order;
+import org.hibernate.validation.util.TestUtil;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class BeanDescriptorTest {
+
+	@Test
+	public void testIsBeanConstrained() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
+
+		// constraint via @Valid
+		assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
+		assertTrue( "Bean should be constrainted due to @valid ", beanDescriptor.isBeanConstrained() );
+
+		// constraint hosted on bean itself
+		beanDescriptor = validator.getConstraintsForClass( Account.class );
+		assertTrue( "There should be direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
+		assertTrue( "Bean should be constrainted due to @valid", beanDescriptor.isBeanConstrained() );
+
+		// constraint on bean property
+		beanDescriptor = validator.getConstraintsForClass( Order.class );
+		assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
+		assertTrue( "Bean should be constrainted due to @NotNull", beanDescriptor.isBeanConstrained() );
+	}
+
+	@Test
+	public void testUnconstraintClass() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
+		assertFalse( "There should be no direct constraints on the specified bean.", beanDescriptor.hasConstraints() );
+		assertFalse( "Bean should be unconstrainted.", beanDescriptor.isBeanConstrained() );
+	}
+
+	@Test
+	public void testGetConstraintForExistingConstrainedProperty() {
+		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()
+		);
+
+		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() );
+	}
+
+	@Test
+	public void testGetConstraintForUnConstrainedProperty() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
+		PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
+		assertEquals(
+				"There should be no constraint descriptors", 0, propertyDescriptor.getConstraintDescriptors().size()
+		);
+		assertTrue( "The property should be cascaded", propertyDescriptor.isCascaded() );
+	}
+
+	@Test
+	public void testGetConstraintsForNonExistingProperty() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+		assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( "foobar" ) );
+	}
+
+	/**
+	 * @todo Is this corect or should we get a IllegalArgumentException
+	 */
+	@Test
+	public void testGetConstraintsForNullProperty() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+		assertNull( "There should be no descriptor", beanDescriptor.getConstraintsForProperty( null ) );
+	}
+
+	/**
+	 * HV-95
+	 */
+	@Test
+	public void testGetConstrainedProperties() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+		Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
+		assertEquals( "There should be only one property", 1, constraintProperties.size() );
+		boolean hasOrderNumber = false;
+		for ( PropertyDescriptor pd : constraintProperties ) {
+			hasOrderNumber |= pd.getPropertyName().equals( "orderNumber" );
+		}
+		assertTrue( "Wrong property", hasOrderNumber );
+	}
+
+	/**
+	 * HV-95
+	 */
+	@Test
+	public void testGetConstrainedPropertiesImmutable() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+		Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
+		try {
+			constraintProperties.add( null );
+			fail( "Set should be immutable" );
+		}
+		catch ( UnsupportedOperationException e ) {
+
+		}
+
+		try {
+			constraintProperties.remove( constraintProperties.iterator().next() );
+			fail( "Set should be immutable" );
+		}
+		catch ( UnsupportedOperationException e ) {
+
+		}
+	}
+
+	/**
+	 * HV-95
+	 */
+	@Test
+	public void testGetConstrainedPropertiesForUnconstraintEntity() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
+		Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
+		assertEquals( "We should get the empty set.", 0, constraintProperties.size() );
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorImplTest.java	2009-03-19 13:55:43 UTC (rev 16185)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorImplTest.java	2009-03-19 14:16:07 UTC (rev 16186)
@@ -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.engine.metadata;
-
-import java.util.Set;
-import javax.validation.ConstraintDescriptor;
-import javax.validation.ElementDescriptor;
-import javax.validation.Validator;
-
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-
-import org.hibernate.validation.engine.Order;
-import org.hibernate.validation.util.TestUtil;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class ElementDescriptorImplTest {
-	/**
-	 * 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 ) {
-
-		}
-	}
-}
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java (from rev 16185, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorImplTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java	2009-03-19 14:16:07 UTC (rev 16186)
@@ -0,0 +1,94 @@
+// $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.Validator;
+
+import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import org.hibernate.validation.engine.Order;
+import org.hibernate.validation.util.TestUtil;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ElementDescriptorTest {
+
+	@Test
+	public void testGetTypeForConstrainedBean() {
+		Validator validator = TestUtil.getValidator();
+		BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
+		assertEquals( "Wrong type.", Customer.class, beanDescriptor.getType() );
+	}
+
+	@Test
+	public void testGetTypeForConstrainedProperty() {
+		Validator validator = TestUtil.getValidator();
+		ElementDescriptor elementDescriptor = validator.getConstraintsForClass( Order.class )
+				.getConstraintsForProperty( "orderNumber" );
+		assertEquals( "Wrong type.", Integer.class, elementDescriptor.getType() );
+	}
+
+	/**
+	 * HV-95
+	 */
+	@Test
+	public void testElementDescriptorForProperty() {
+		Validator validator = TestUtil.getValidator();
+		ElementDescriptor elementDescriptor = validator.getConstraintsForClass( Order.class )
+				.getConstraintsForProperty( "orderNumber" );
+		Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
+		assertTrue( "There should be a descriptor", constraintDescriptors.size() == 1 );
+	}
+
+	/**
+	 * HV-95
+	 */
+	@Test
+	public void testElementDescriptorImmutable() {
+		Validator validator = TestUtil.getValidator();
+		ElementDescriptor elementDescriptor = validator.getConstraintsForClass( Order.class )
+				.getConstraintsForProperty( "orderNumber" );
+		Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
+		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 ) {
+
+		}
+	}
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java	2009-03-19 14:16:07 UTC (rev 16186)
@@ -0,0 +1,60 @@
+// $Id: ElementDescriptorTest.java 16185 2009-03-19 13:55:43Z 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;
+
+import javax.validation.PropertyDescriptor;
+import javax.validation.Validator;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import org.hibernate.validation.engine.Order;
+import org.hibernate.validation.util.TestUtil;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class PropertyDescriptorTest {
+	@Test
+	public void testIsNotCascaded() {
+		Validator validator = TestUtil.getValidator();
+		PropertyDescriptor descriptor = validator.getConstraintsForClass( Order.class )
+				.getConstraintsForProperty( "orderNumber" );
+		assertFalse( "Should not be cascaded", descriptor.isCascaded() );
+	}
+
+	@Test
+	public void testIsCascaded() {
+		Validator validator = TestUtil.getValidator();
+		PropertyDescriptor descriptor = validator.getConstraintsForClass( Customer.class )
+				.getConstraintsForProperty( "orderList" );
+		assertTrue( "Should be cascaded", descriptor.isCascaded() );
+	}
+
+	@Test
+	public void testPropertyName() {
+		Validator validator = TestUtil.getValidator();
+		String propertyName = "orderList";
+		PropertyDescriptor descriptor = validator.getConstraintsForClass( Customer.class )
+				.getConstraintsForProperty( propertyName );
+		assertEquals( "Wrong property name", propertyName, descriptor.getPropertyName() );
+	}
+}
\ No newline at end of file




More information about the hibernate-commits mailing list