public static void checkExpectedValidationViolations ( ConstraintViolationException exception , List < String > expectedValidationViolations ) { if ( exception != null && expectedValidationViolations != null ) { List < String > givenViolations = new ArrayList < String > ( ) ; for ( ConstraintViolation < ? > violation : exception . getConstraintViolations ( ) ) { givenViolations . add ( violation . getMessageTemplate ( ) ) ; } checkViolations ( givenViolations , expectedValidationViolations ) ; } }
This method checks if the validation violations matches the violations given in a ViolationException .