Class ConstraintViolationAssert
java.lang.Object
org.hibernate.validator.testutil.ConstraintViolationAssert
This class provides useful functions to assert correctness of constraint violations raised
during tests.
- Author:
- Kevin Pollet <[email protected]> (C) 2011 SERLI, Hardy Ferentschik, Gunnar Morling
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classA property path expected to be returned by a givenConstraintViolation.static class -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertConstraintTypes(Set<? extends ConstraintDescriptor<?>> descriptors, Class<?>... expectedConstraintTypes) static voidassertCorrectConstraintTypes(Set<? extends ConstraintViolation<?>> violations, Class<?>... expectedConstraintTypes) Asserts that the violated constraint type in the violation list matches exactly the expected constraint types list.static voidassertCorrectPropertyPathStringRepresentations(Set<? extends ConstraintViolation<?>> violations, String... expectedPropertyPaths) Asserts that the given list of constraint violation paths matches the list of expected property paths.static voidassertNoViolations(Set<? extends ConstraintViolation<?>> violations) Asserts that the given violation list has no violations (is empty).static voidassertNoViolations(Set<? extends ConstraintViolation<?>> violations, String message) Asserts that the given violation list has no violations (is empty).static voidassertPathEquals(Path path, ConstraintViolationAssert.PathExpectation expectedPath) Asserts that the path matches the expected path.assertThat(Set<? extends ConstraintViolation<?>> actualViolations) static booleanpathsAreEqual(Path p1, Path p2) Checks that two property paths are equal.pathWith()violationOf(Class<? extends Annotation> constraintType)
-
Method Details
-
assertCorrectConstraintTypes
public static void assertCorrectConstraintTypes(Set<? extends ConstraintViolation<?>> violations, Class<?>... expectedConstraintTypes) Asserts that the violated constraint type in the violation list matches exactly the expected constraint types list.- Parameters:
violations- The violation list to verify.expectedConstraintTypes- The expected constraint types.
-
assertCorrectPropertyPathStringRepresentations
public static void assertCorrectPropertyPathStringRepresentations(Set<? extends ConstraintViolation<?>> violations, String... expectedPropertyPaths) Asserts that the given list of constraint violation paths matches the list of expected property paths.- Parameters:
violations- The violation list to verify.expectedPropertyPaths- The expected property paths.
-
assertThat
public static ConstraintViolationAssert.ConstraintViolationSetAssert assertThat(Set<? extends ConstraintViolation<?>> actualViolations) -
assertNoViolations
Asserts that the given violation list has no violations (is empty).- Parameters:
violations- The violation list to verify.
-
assertNoViolations
public static void assertNoViolations(Set<? extends ConstraintViolation<?>> violations, String message) Asserts that the given violation list has no violations (is empty).- Parameters:
violations- The violation list to verify.
-
assertConstraintTypes
public static void assertConstraintTypes(Set<? extends ConstraintDescriptor<?>> descriptors, Class<?>... expectedConstraintTypes) -
assertPathEquals
public static void assertPathEquals(Path path, ConstraintViolationAssert.PathExpectation expectedPath) Asserts that the path matches the expected path.- Parameters:
path- The path under testexpectedPath- The expected path
-
pathsAreEqual
-
pathWith
-
violationOf
public static ConstraintViolationAssert.ViolationExpectation violationOf(Class<? extends Annotation> constraintType)
-