use of org.hibernate.validator.engine.HibernateConstraintViolation in project hibernate-validator by hibernate.
the class HibernateConstraintValidatorContextTest method testNullIsReturnedForNonExistingPayloadType.
@Test
@TestForIssue(jiraKey = "HV-1020")
public void testNullIsReturnedForNonExistingPayloadType() {
Validator validator = getValidator();
Set<ConstraintViolation<ExpressionVariableFoo>> constraintViolations = validator.validate(new ExpressionVariableFoo(QUESTION_4));
assertThat(constraintViolations).containsOnlyViolations(violationOf(ExpressionVariableOracleConstraint.class));
ConstraintViolation<ExpressionVariableFoo> constraintViolation = constraintViolations.iterator().next();
@SuppressWarnings("unchecked") HibernateConstraintViolation<ExpressionVariableFoo> hibernateConstraintViolation = constraintViolation.unwrap(HibernateConstraintViolation.class);
Assert.assertNull(hibernateConstraintViolation.getDynamicPayload(String.class));
}
use of org.hibernate.validator.engine.HibernateConstraintViolation in project hibernate-validator by hibernate.
the class HibernateConstraintValidatorContextTest method testDynamicPayloadExposedInHibernateConstraintViolation.
// Dynamic payload
@Test
@TestForIssue(jiraKey = "HV-1020")
public void testDynamicPayloadExposedInHibernateConstraintViolation() {
Validator validator = getValidator();
Set<ConstraintViolation<ExpressionVariableFoo>> constraintViolations = validator.validate(new ExpressionVariableFoo(QUESTION_4));
assertThat(constraintViolations).containsOnlyViolations(violationOf(ExpressionVariableOracleConstraint.class));
ConstraintViolation<ExpressionVariableFoo> constraintViolation = constraintViolations.iterator().next();
@SuppressWarnings("unchecked") HibernateConstraintViolation<ExpressionVariableFoo> hibernateConstraintViolation = constraintViolation.unwrap(HibernateConstraintViolation.class);
Assert.assertEquals(hibernateConstraintViolation.getDynamicPayload(List.class), INVALID_KEYWORDS);
}
use of org.hibernate.validator.engine.HibernateConstraintViolation in project hibernate-validator by hibernate.
the class HibernateConstraintValidatorContextTest method testNullIsReturnedIfPayloadIsNull.
@Test
@TestForIssue(jiraKey = "HV-1164")
public void testNullIsReturnedIfPayloadIsNull() {
Validator validator = getValidator();
Set<ConstraintViolation<ExpressionVariableFoo>> constraintViolations = validator.validate(new ExpressionVariableFoo(QUESTION_1));
assertThat(constraintViolations).containsOnlyViolations(violationOf(ExpressionVariableOracleConstraint.class));
ConstraintViolation<ExpressionVariableFoo> constraintViolation = constraintViolations.iterator().next();
@SuppressWarnings("unchecked") HibernateConstraintViolation<ExpressionVariableFoo> hibernateConstraintViolation = constraintViolation.unwrap(HibernateConstraintViolation.class);
Assert.assertNull(hibernateConstraintViolation.getDynamicPayload(Object.class));
}
Aggregations