use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.
the class ProgrammaticContainerElementConstraintsForParameterTest method declaringContainerElementConstraintOnNonGenericParameterCausesException.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000211.*")
@TestForIssue(jiraKey = "HV-1239")
public void declaringContainerElementConstraintOnNonGenericParameterCausesException() {
ConstraintMapping newMapping = config.createConstraintMapping();
newMapping.type(IFishTank.class).method("setSize", int.class).parameter(0).containerElementType(1);
}
use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.
the class ProgrammaticContainerElementConstraintsForParameterTest method omittingTypeArgumentForMultiTypeArgumentTypeOnParameterCausesException.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000213.*")
@TestForIssue(jiraKey = "HV-1239")
public void omittingTypeArgumentForMultiTypeArgumentTypeOnParameterCausesException() {
ConstraintMapping newMapping = config.createConstraintMapping();
newMapping.type(FishTank.class).method("test1", Optional.class, Map.class).parameter(1).containerElementType();
}
use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.
the class ProgrammaticContainerElementConstraintsForReturnValueTest method canDeclareDeeplyNestedContainerElementConstraintsForReturnValueProgrammatically.
@Test
@TestForIssue(jiraKey = "HV-1239")
public void canDeclareDeeplyNestedContainerElementConstraintsForReturnValueProgrammatically() {
ConstraintMapping newMapping = config.createConstraintMapping();
newMapping.type(IFishTank.class).method("test3").returnValue().containerElementType(0, 1, 0).constraint(new NotNullDef());
config.addMapping(newMapping);
Validator validator = config.buildValidatorFactory().getValidator();
IFishTank fishTank = ValidatorUtil.getValidatingProxy(new FishTank(), validator);
try {
fishTank.test3();
fail("Expected exception wasn't raised");
} catch (ConstraintViolationException e) {
assertThat(e.getConstraintViolations()).containsOnlyViolations(violationOf(NotNull.class).withMessage("must not be null"));
}
}
use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.
the class ProgrammaticContainerElementConstraintsForReturnValueTest method canDeclareContainerElementCascadesForReturnValueProgrammatically.
@Test
@TestForIssue(jiraKey = "HV-1239")
public void canDeclareContainerElementCascadesForReturnValueProgrammatically() {
ConstraintMapping newMapping = config.createConstraintMapping();
newMapping.type(IFishTank.class).method("test4").returnValue().containerElementType().valid().type(Fish.class).field("name").constraint(new NotNullDef());
config.addMapping(newMapping);
Validator validator = config.buildValidatorFactory().getValidator();
IFishTank fishTank = ValidatorUtil.getValidatingProxy(new FishTank(), validator);
try {
fishTank.test4();
fail("Expected exception wasn't raised");
} catch (ConstraintViolationException e) {
assertThat(e.getConstraintViolations()).containsOnlyViolations(violationOf(NotNull.class).withMessage("must not be null"));
}
}
use of org.hibernate.validator.testutil.TestForIssue in project hibernate-validator by hibernate.
the class ProgrammaticContainerElementConstraintsForReturnValueTest method declaringContainerElementConstraintForNonExistingTypeArgumentIndexOnReturnValueCausesException.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000212.*")
@TestForIssue(jiraKey = "HV-1239")
public void declaringContainerElementConstraintForNonExistingTypeArgumentIndexOnReturnValueCausesException() {
ConstraintMapping newMapping = config.createConstraintMapping();
newMapping.type(FishTank.class).method("test1").returnValue().containerElementType(2);
}
Aggregations