Author: hardy.ferentschik
Date: 2009-06-26 08:18:52 -0400 (Fri, 26 Jun 2009)
New Revision: 16956
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
Log:
Cleanup. Adding more helper methods to TestUtil and making sure that the tests are calling
ther helpers were possible
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -53,6 +53,8 @@
import org.hibernate.jsr303.tck.util.TestUtil;
import static org.hibernate.jsr303.tck.util.TestUtil.assertConstraintViolation;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
+import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
/**
* @author Hardy Ferentschik
@@ -185,9 +187,8 @@
person.setPersonalNumber( 1234567890l );
Set<ConstraintViolation<Person>> constraintViolations = validator.validate(
person );
- assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
- ConstraintViolation<Person> constraintViolation =
constraintViolations.iterator().next();
- assertEquals( "my custom message", constraintViolation.getMessage(),
"Wrong message" );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages( constraintViolations, "my custom
message" );
}
private void addProviderToList(List<ValidationProvider> providers, URL url)
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -21,15 +21,15 @@
import java.util.Arrays;
import java.util.List;
import java.util.Set;
-import javax.validation.metadata.BeanDescriptor;
import javax.validation.ConstraintDefinitionException;
-import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.validation.groups.Default;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
@@ -37,7 +37,6 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
-import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
@@ -46,6 +45,7 @@
import static org.hibernate.jsr303.tck.util.TestUtil.assertConstraintViolation;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintType;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintTypes;
+import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
/**
@@ -54,7 +54,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class ConstraintCompositionTest extends AbstractTest {
@Test
@@ -70,7 +70,7 @@
assertCorrectNumberOfViolations( constraintViolations, 1 );
ConstraintViolation<FrenchAddress> constraintViolation =
constraintViolations.iterator().next();
assertCorrectConstraintType( constraintViolation, NotNull.class );
- assertEquals( constraintViolation.getMessage(), "may not be null",
"Wrong error message" );
+ assertCorrectConstraintViolationMessages( constraintViolations, "may not be
null" );
assertConstraintViolation(
constraintViolation,
FrenchAddress.class,
@@ -102,7 +102,10 @@
}
@Test
- @SpecAssertion(section = "2.3", id = "b")
+ @SpecAssertions({
+ @SpecAssertion(section = "2.3", id = "b"),
+ @SpecAssertion(section = "2.4", id = "m")
+ })
public void testValidationOfMainAnnotationIsAlsoApplied() {
Validator validator = TestUtil.getDefaultValidator();
@@ -113,8 +116,7 @@
assertCorrectConstraintTypes(
constraintViolations, new Class<?>[] { FrenchZipcode.class }
);
- ConstraintViolation<FrenchAddress> constraintViolation =
constraintViolations.iterator().next();
- assertEquals( constraintViolation.getMessage(), "00000 is a reserved code",
"Wrong error message" );
+ assertCorrectConstraintViolationMessages( constraintViolations, "00000 is a
reserved code" );
}
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -40,7 +40,7 @@
import org.hibernate.jsr303.tck.util.TestUtil;
import static org.hibernate.jsr303.tck.util.TestUtil.assertConstraintViolation;
-import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessage;
+import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
/**
@@ -49,7 +49,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class DefaultGroupRedefinitionTest extends AbstractTest {
@Test
@@ -70,7 +70,7 @@
ConstraintViolation<Address> violation = constraintViolations.iterator().next();
assertConstraintViolation( violation, Address.class, null, "zipcode" );
- assertCorrectConstraintViolationMessage( violation, "may not be null" );
+ assertCorrectConstraintViolationMessages( constraintViolations, "may not be
null" );
address.setZipcode( "41841" );
@@ -84,7 +84,7 @@
violation = constraintViolations.iterator().next();
assertConstraintViolation( violation, Address.class, address, "" );
- assertCorrectConstraintViolationMessage( violation, "Zip code is not
coherent." );
+ assertCorrectConstraintViolationMessages( constraintViolations, "Zip code is not
coherent." );
}
@Test(enabled = false)
@@ -119,16 +119,22 @@
// if the group sequence would not be properly redefined there would be no error when
validating default.
Set<ConstraintViolation<Car>> constraintViolations = validator.validate(
car );
- assertCorrectNumberOfViolations(constraintViolations, 1);
- assertCorrectConstraintViolationMessage( constraintViolations.iterator().next(),
"Car type has to be betweeb 2 and 20 characters." );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, "Car type has to be betweeb 2 and 20 characters."
+ );
constraintViolations = validator.validateProperty( car, "type" );
- assertCorrectNumberOfViolations(constraintViolations, 1);
- assertCorrectConstraintViolationMessage( constraintViolations.iterator().next(),
"Car type has to be betweeb 2 and 20 characters.");
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, "Car type has to be betweeb 2 and 20 characters."
+ );
constraintViolations = validator.validateValue( Car.class, "type",
"A" );
- assertCorrectNumberOfViolations(constraintViolations, 1);
- assertCorrectConstraintViolationMessage( constraintViolations.iterator().next(),
"Car type has to be betweeb 2 and 20 characters.");
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, "Car type has to be betweeb 2 and 20 characters."
+ );
}
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -38,6 +38,8 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
import static org.hibernate.jsr303.tck.util.TestUtil.assertEqualPaths;
@@ -189,9 +191,9 @@
book.setSubtitle( "Revised Edition of Hibernate in Action" );
constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
- assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages( constraintViolations, "size must be
between 0 and 30" );
constraintViolation = constraintViolations.iterator().next();
- assertEquals( constraintViolation.getMessage(), "size must be between 0 and
30", "Wrong message" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
assertEquals( constraintViolation.getInvalidValue(), book.getSubtitle(), "Wrong
value" );
assertCorrectPropertyPaths( constraintViolations, "subtitle" );
@@ -230,9 +232,9 @@
author.setLastName( "King" );
constraintViolations = validator.validate( book, Book.All.class );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages( constraintViolations, "may not be
null" );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
- assertEquals( constraintViolation.getMessage(), "may not be null",
"Wrong message" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong
value" );
assertCorrectPropertyPaths( constraintViolations, "title" );
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -35,7 +35,7 @@
import org.hibernate.jsr303.tck.util.TestUtil;
import static org.hibernate.jsr303.tck.util.TestUtil.assertConstraintViolation;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintType;
-import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessage;
+import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
/**
@@ -44,7 +44,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class ValidatePropertyTest extends AbstractTest {
//TODO Needs verification
@@ -64,7 +64,6 @@
}
-
@Test
@SpecAssertion(section = "4.1.1", id = "e")
public void testIllegalArgumentExceptionIsThrownForNullValue() {
@@ -140,7 +139,9 @@
ConstraintViolation<Address> violation = constraintViolations.iterator().next();
assertCorrectConstraintType( violation, Size.class );
assertConstraintViolation( violation, Address.class, townInNorthWales, "city"
);
- assertCorrectConstraintViolationMessage( violation, "City name cannot be longer
than 30 characters." );
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, "City name cannot be longer than 30 characters."
+ );
address.setCity( "London" );
constraintViolations = validator.validateProperty( address, "city" );
@@ -175,6 +176,6 @@
ConstraintViolation<ActorListBased> violation =
constraintViolations.iterator().next();
assertCorrectConstraintType( violation, NotNull.class );
assertConstraintViolation( violation, ActorListBased.class, null, property );
- assertCorrectConstraintViolationMessage( violation, "Everyone has a last
name." );
+ assertCorrectConstraintViolationMessages( constraintViolations, "Everyone has a
last name." );
}
}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -55,6 +55,7 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "3.1", id = "a"),
+ @SpecAssertion(section = "3.1.2", id = "f"),
@SpecAssertion(section = "5.1", id = "a")
})
public void testValidatedPropertyDoesNotFollowJavaBeansConvention() {
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -33,6 +33,8 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
import static org.hibernate.jsr303.tck.util.TestUtil.assertEqualPaths;
@@ -53,9 +55,8 @@
DummyBean bean = new DummyBean( "foobar" );
Set<ConstraintViolation<DummyBean>> constraintViolations =
validator.validate( bean );
- assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
- ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "dummy message", constraintViolation.getMessage(), "Wrong
message" );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages( constraintViolations, "dummy
message" );
}
/**
@@ -87,9 +88,8 @@
DummyBean bean = new DummyBean( "foobar" );
Set<ConstraintViolation<DummyBean>> constraintViolations =
validator.validate( bean );
- assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
- ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( constraintViolation.getMessage(), "message1", "Wrong
message" );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages( constraintViolations, "message1"
);
assertCorrectPropertyPaths( constraintViolations, "property1" );
}
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -31,20 +31,21 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
-import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessage;
+import static
org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
/**
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
@ValidationXml(value = "validation.xml")
@Resources(
{
@Resource(source = "user-constraints.xml",
destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml"),
- @Resource(source = "order-constraints.xml", destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints.xml")
+ @Resource(source = "order-constraints.xml",
+ destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints.xml")
}
)
public class XmlConfigurationTest extends AbstractTest {
@@ -56,8 +57,8 @@
User user = new User();
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user );
assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintViolationMessage(
- constraintViolations.iterator().next(), "Message from xml"
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, "Message from xml"
);
user.setConsistent( true );
@@ -75,7 +76,7 @@
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user );
assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintViolationMessage( constraintViolations.iterator().next(),
"Size is limited!" );
+ assertCorrectConstraintViolationMessages( constraintViolations, "Size is
limited!" );
user.setFirstname( "Wolfgang" );
constraintViolations = validator.validate( user );
@@ -93,8 +94,8 @@
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user );
assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintViolationMessage(
- constraintViolations.iterator().next(), "Last name has to start with with a
capital letter."
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, "Last name has to start with with a capital letter."
);
user.setLastname( "Doe" );
@@ -112,9 +113,8 @@
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user );
assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintViolationMessage(
- constraintViolations.iterator().next(),
- "A phone number can only contain numbers, whitespaces and dashes."
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, "A phone number can only contain numbers, whitespaces and
dashes."
);
user.setPhoneNumber( "112" );
@@ -134,10 +134,7 @@
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user );
assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintViolationMessage(
- constraintViolations.iterator().next(),
- "Not a credit casrd number."
- );
+ assertCorrectConstraintViolationMessages( constraintViolations, "Not a credit
casrd number." );
card.setNumber( "1234567890" );
constraintViolations = validator.validate( user );
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-26
08:29:41 UTC (rev 16955)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-26
12:18:52 UTC (rev 16956)
@@ -57,17 +57,27 @@
);
}
- public static <T> void
assertCorrectConstraintViolationMessage(ConstraintViolation<T> violation, String
message) {
- assertEquals(
- violation.getMessage(), message, "Wrong error message"
- );
+ public static <T> void
assertCorrectConstraintViolationMessages(Set<ConstraintViolation<T>>
violations, String... messages) {
+ List<String> actualMessages = new ArrayList<String>();
+ for ( ConstraintViolation<?> violation : violations ) {
+ actualMessages.add( violation.getMessage() );
+ }
+
+ assertTrue( actualMessages.size() == messages.length, "Wrong number or error
messages" );
+
+ for ( String expectedMessage : messages ) {
+ assertTrue(
+ actualMessages.contains( expectedMessage ),
+ "The message " + expectedMessage + " should have been in the st of
error messages"
+ );
+ }
}
public static <T> void
assertCorrectNumberOfViolations(Set<ConstraintViolation<T>> violations, int
expectedViolations) {
assertEquals( violations.size(), expectedViolations, "Wrong number of constraint
violations" );
}
- public static <T> void
assertCorrectConstraintTypes(Set<ConstraintViolation<T>> violations,
Class<?>[] expectedConsraintTypes) {
+ public static <T> void
assertCorrectConstraintTypes(Set<ConstraintViolation<T>> violations,
Class<?>... expectedConsraintTypes) {
List<String> constraintTypes = new ArrayList<String>();
for ( ConstraintViolation<?> violation : violations ) {
constraintTypes.add(
@@ -75,7 +85,7 @@
);
}
- assertEquals( expectedConsraintTypes.length, constraintTypes.size(), "Wring number
of constraint types." );
+ assertEquals( expectedConsraintTypes.length, constraintTypes.size(), "Wrong number
of constraint types." );
for ( Class<?> expectedConstraintType : expectedConsraintTypes ) {
assertTrue(