[hibernate-commits] Hibernate SVN: r17641 - in beanvalidation/tck/trunk/src/main: java/org/hibernate/jsr303/tck/tests/metadata and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Oct 7 05:09:58 EDT 2009


Author: hardy.ferentschik
Date: 2009-10-07 05:09:57 -0400 (Wed, 07 Oct 2009)
New Revision: 17641

Removed:
   beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictionary.java
Modified:
   beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
   beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
   beanvalidation/tck/trunk/src/main/resources/tck-audit.xml
Log:
added some missing constraint mappings

Deleted: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictionary.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictionary.java	2009-10-07 08:36:01 UTC (rev 17640)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictionary.java	2009-10-07 09:09:57 UTC (rev 17641)
@@ -1,56 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.jsr303.tck.tests.constraints.groups;
-
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-/**
- * @author Hardy Ferentschik
- */
-public class Dictionary extends Book {
-	@NotNull(groups = Translate.class)
-	@Size(min = 1, groups = Translate.class)
-	private String translatesTo;
-
-	@NotNull(groups = Translate.class)
-	@Size(min = 1, 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 {
-	}
-}

Modified: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java	2009-10-07 08:36:01 UTC (rev 17640)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java	2009-10-07 09:09:57 UTC (rev 17641)
@@ -162,6 +162,7 @@
 	}
 
 	@Test
+	@SpecAssertion(section = "3.4", id = "d")
 	public void testGroups() {
 		Validator validator = TestUtil.getValidatorUnderTest();
 
@@ -192,7 +193,9 @@
 
 		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
 		assertCorrectNumberOfViolations( constraintViolations, 1 );
-		assertCorrectConstraintViolationMessages( constraintViolations, "The book's subtitle can only have 30 characters" );
+		assertCorrectConstraintViolationMessages(
+				constraintViolations, "The book's subtitle can only have 30 characters"
+		);
 		constraintViolation = constraintViolations.iterator().next();
 		assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
 		assertEquals( constraintViolation.getInvalidValue(), book.getSubtitle(), "Wrong value" );
@@ -204,7 +207,9 @@
 		constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
 		constraintViolation = constraintViolations.iterator().next();
 		assertCorrectNumberOfViolations( constraintViolations, 1 );
-		assertCorrectConstraintViolationMessages( constraintViolations, "The company name can only have 20 characters" );
+		assertCorrectConstraintViolationMessages(
+				constraintViolations, "The company name can only have 20 characters"
+		);
 		assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
 		assertEquals( constraintViolation.getInvalidValue(), author.getCompany(), "Wrong value" );
 		assertCorrectPropertyPaths( constraintViolations, "author.company" );
@@ -216,6 +221,10 @@
 	}
 
 	@Test
+	@SpecAssertions({
+			@SpecAssertion(section = "3.4.2", id = "b"),
+			@SpecAssertion(section = "3.4.2", id = "d")
+	})
 	public void testGroupSequence() {
 		Validator validator = TestUtil.getValidatorUnderTest();
 
@@ -258,22 +267,10 @@
 	}
 
 	@Test
-	public void testGroupSequences() {
-		Validator validator = TestUtil.getValidatorUnderTest();
-
-		Dictionary dictionary = new Dictionary();
-		dictionary.setTitle( "English - German" );
-		Author author = new Author();
-		author.setLastName( "-" );
-		author.setFirstName( "-" );
-		author.setCompany( "Langenscheidt Publ." );
-		dictionary.setAuthor( author );
-
-		Set<ConstraintViolation<Dictionary>> constraintViolations = validator.validate( dictionary, DefaultAlias.class );
-		assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
-	}
-
-	@Test
+	@SpecAssertions({
+			@SpecAssertion(section = "3.4", id = "c"),
+			@SpecAssertion(section = "3.5", id = "b")
+	})
 	public void testValidationFailureInMultipleGroups() {
 		Validator validator = TestUtil.getValidatorUnderTest();
 		Animal elephant = new Animal();
@@ -286,11 +283,12 @@
 		assertEquals(
 				constraintViolations.size(),
 				1,
-				"The should be one invalid constraint since the same constraint gets validated in both groups"
+				"The should be only one invalid constraint even though the constraint belongs to both groups"
 		);
 	}
 
 	@Test
+	@SpecAssertion(section = "3.4", id = "d")
 	public void testGroupSequenceFollowedByGroup() {
 		User user = new User();
 		user.setFirstname( "Foo" );

Modified: beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
===================================================================
--- beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java	2009-10-07 08:36:01 UTC (rev 17640)
+++ beanvalidation/tck/trunk/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java	2009-10-07 09:09:57 UTC (rev 17641)
@@ -49,6 +49,7 @@
 public class ConstraintDescriptorTest extends AbstractTest {
 
 	@Test
+	@SpecAssertion(section = "5.5", id = "k")
 	public void testReportAsSingleViolation() {
 		ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
 		assertFalse( descriptor.isReportAsSingleViolation() );
@@ -58,6 +59,7 @@
 	}
 
 	@Test
+	@SpecAssertion(section = "5.5", id = "l")
 	public void testEmptyComposingConstraints() {
 		ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
 		assertTrue( descriptor.getComposingConstraints().isEmpty() );
@@ -79,7 +81,9 @@
 				Size sizeAnn = ( Size ) desc.getAnnotation();
 				assertEquals( sizeAnn.min(), 5, "The min parameter should reflect the overridden parameter" );
 				assertEquals(
-						desc.getAttributes().get( "min" ), 5, "The min parameter should reflect the overridden parameter"
+						desc.getAttributes().get( "min" ),
+						5,
+						"The min parameter should reflect the overridden parameter"
 				);
 			}
 			else if ( desc.getAnnotation().annotationType().equals( NotNull.class ) ) {
@@ -88,7 +92,7 @@
 				fail( "Unexpected annotation." );
 			}
 		}
-		assertTrue(hasSize, "Size composed annotation not found");
+		assertTrue( hasSize, "Size composed annotation not found" );
 	}
 
 	@Test
@@ -141,7 +145,10 @@
 	}
 
 	@Test
-	@SpecAssertion(section = "5.5", id = "f")
+	@SpecAssertions({
+			@SpecAssertion(section = "5.5", id = "f"),
+			@SpecAssertion(section = "5.5", id = "l")
+	})
 	public void testComposingConstraints() {
 		ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Person.class, "firstName" );
 		Set<ConstraintDescriptor<?>> composingDescriptors = descriptor.getComposingConstraints();
@@ -168,8 +175,8 @@
 
 	@Test
 	@SpecAssertions({
-		@SpecAssertion(section = "5.5", id = "h"),
-		@SpecAssertion(section = "5.5", id = "i")
+			@SpecAssertion(section = "5.5", id = "h"),
+			@SpecAssertion(section = "5.5", id = "i")
 	})
 	public void testComposingConstraintsPayload() {
 		ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Person.class, "firstName" );

Modified: beanvalidation/tck/trunk/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/tck/trunk/src/main/resources/tck-audit.xml	2009-10-07 08:36:01 UTC (rev 17640)
+++ beanvalidation/tck/trunk/src/main/resources/tck-audit.xml	2009-10-07 09:09:57 UTC (rev 17641)
@@ -1042,7 +1042,14 @@
         <assertion id="i">
             <text>Any payload definition on a composing annotation is ignored</text>
         </assertion>
-
+        <assertion id="k">
+            <text>isReportAsSingleViolation() returns true if the constraint is annotated with
+                @ReportAsSingleViolation </text>
+        </assertion>
+        <assertion id="l">
+            <text>getComposingConstraints return a set of composing ConstraintDescriptors where each
+                descriptor describes a composing constraint.</text>
+        </assertion>
     </section>
 
     <section id="6" title="Built-in Constraint definitions">



More information about the hibernate-commits mailing list