org.testinfected.hamcrest.validation
Class ViolationMatchers

java.lang.Object
  extended by org.testinfected.hamcrest.validation.ViolationMatchers

public class ViolationMatchers
extends java.lang.Object

A collection of hamcrest matchers to validate JSR-303 ConstraintViolations.


Constructor Summary
ViolationMatchers()
           
 
Method Summary
static
<T> org.hamcrest.Matcher<java.lang.Iterable<? extends javax.validation.ConstraintViolation<T>>>
fails()
          Checks that validation fails, i.e.
static
<T> org.hamcrest.Matcher<javax.validation.ConstraintViolation<T>>
on(java.lang.String pathExpression)
          Checks that a violation occurs on a given property.
static
<T> org.hamcrest.Matcher<java.lang.Iterable<? extends javax.validation.ConstraintViolation<T>>>
succeeds()
          Checks that violation succeeds, i.e.
static
<T> org.hamcrest.Matcher<java.lang.Iterable<javax.validation.ConstraintViolation<T>>>
violates(java.util.Collection<org.hamcrest.Matcher<? super javax.validation.ConstraintViolation<T>>> matchers)
          Checks that a collection of violations contains at least one violation and that each of the given matchers matches at least one of its elements.
static
<T> org.hamcrest.Matcher<java.lang.Iterable<javax.validation.ConstraintViolation<T>>>
violates(org.hamcrest.Matcher<? super javax.validation.ConstraintViolation<T>>... matchers)
          Checks that a collection of violations contains at least one violation and that each of the given matchers matches at least one of its elements.
static
<T> org.hamcrest.Matcher<javax.validation.ConstraintViolation<T>>
violation(java.util.Collection<org.hamcrest.Matcher<? super javax.validation.ConstraintViolation<T>>> matchers)
          Checks that a violation satisfies a set of conditions.
static
<T> org.hamcrest.Matcher<javax.validation.ConstraintViolation<T>>
violation(org.hamcrest.Matcher<? super javax.validation.ConstraintViolation<T>>... matchers)
          Checks that a violation satisfies a set of conditions.
static
<T> org.hamcrest.Matcher<javax.validation.ConstraintViolation<T>>
withError(java.lang.String messagePart)
          Checks that a violation's error message template contains a given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViolationMatchers

public ViolationMatchers()
Method Detail

violates

public static <T> org.hamcrest.Matcher<java.lang.Iterable<javax.validation.ConstraintViolation<T>>> violates(org.hamcrest.Matcher<? super javax.validation.ConstraintViolation<T>>... matchers)
Checks that a collection of violations contains at least one violation and that each of the given matchers matches at least one of its elements.


violates

public static <T> org.hamcrest.Matcher<java.lang.Iterable<javax.validation.ConstraintViolation<T>>> violates(java.util.Collection<org.hamcrest.Matcher<? super javax.validation.ConstraintViolation<T>>> matchers)
Checks that a collection of violations contains at least one violation and that each of the given matchers matches at least one of its elements.


fails

public static <T> org.hamcrest.Matcher<java.lang.Iterable<? extends javax.validation.ConstraintViolation<T>>> fails()
Checks that validation fails, i.e. there is at least one constraint violation.


succeeds

public static <T> org.hamcrest.Matcher<java.lang.Iterable<? extends javax.validation.ConstraintViolation<T>>> succeeds()
Checks that violation succeeds, i.e. that there is no constraint violation.


violation

public static <T> org.hamcrest.Matcher<javax.validation.ConstraintViolation<T>> violation(org.hamcrest.Matcher<? super javax.validation.ConstraintViolation<T>>... matchers)
Checks that a violation satisfies a set of conditions.


violation

public static <T> org.hamcrest.Matcher<javax.validation.ConstraintViolation<T>> violation(java.util.Collection<org.hamcrest.Matcher<? super javax.validation.ConstraintViolation<T>>> matchers)
Checks that a violation satisfies a set of conditions.


on

public static <T> org.hamcrest.Matcher<javax.validation.ConstraintViolation<T>> on(java.lang.String pathExpression)
Checks that a violation occurs on a given property. The property can be a nested property expression. For instance, expression foo.bar would check that the violation applies to the bar property of the object accessed by the foo property.


withError

public static <T> org.hamcrest.Matcher<javax.validation.ConstraintViolation<T>> withError(java.lang.String messagePart)
Checks that a violation's error message template contains a given string.