use of jakarta.validation.ConstraintViolationException in project hibernate-validator by hibernate.
the class ContainerElementTypeConstraintsForParameterXmlMappingTest method canDeclareContainerElementTypeConstraintsForArrayTypeParameterWithXmlMapping.
// HV-1428 Container element support is disabled for arrays
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000226:.*")
@TestForIssue(jiraKey = "HV-1291")
public void canDeclareContainerElementTypeConstraintsForArrayTypeParameterWithXmlMapping() {
Validator validator = getValidator("parameter-canDeclareContainerElementTypeConstraintsForArrayType-mapping.xml");
IFishTank fishTank = ValidatorUtil.getValidatingProxy(new FishTank(), validator);
try {
fishTank.test5(new String[] { "Too Long" });
fail("Expected exception wasn't raised");
} catch (ConstraintViolationException e) {
assertThat(e.getConstraintViolations()).containsOnlyViolations(violationOf(Size.class).withMessage("size must be between 0 and 5"));
}
}
use of jakarta.validation.ConstraintViolationException in project hibernate-validator by hibernate.
the class ContainerElementTypeConstraintsForParameterXmlMappingTest method canDeclareContainerElementTypeConstraintsForListContainingArrayTypeParameterWithXmlMapping.
// HV-1428 Container element support is disabled for arrays
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000226:.*")
@TestForIssue(jiraKey = "HV-1291")
public void canDeclareContainerElementTypeConstraintsForListContainingArrayTypeParameterWithXmlMapping() {
Validator validator = getValidator("parameter-canDeclareContainerElementTypeConstraintsForListContainingArrayType-mapping.xml");
IFishTank fishTank = ValidatorUtil.getValidatingProxy(new FishTank(), validator);
try {
List<String[]> fishNamesByMonth = new ArrayList<>();
fishNamesByMonth.add(new String[] { "Too Long" });
fishTank.test6(fishNamesByMonth);
fail("Expected exception wasn't raised");
} catch (ConstraintViolationException e) {
assertThat(e.getConstraintViolations()).containsOnlyViolations(violationOf(Size.class).withMessage("size must be between 0 and 5"));
}
}
use of jakarta.validation.ConstraintViolationException in project hibernate-validator by hibernate.
the class ContainerElementTypeConstraintsForReturnValueXmlMappingTest method canDeclareContainerElementTypeConstraintsForListContainingArrayTypeReturnValueWithXmlMapping.
// HV-1428 Container element support is disabled for arrays
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000226:.*")
@TestForIssue(jiraKey = "HV-1291")
public void canDeclareContainerElementTypeConstraintsForListContainingArrayTypeReturnValueWithXmlMapping() {
Validator validator = getValidator("returnvalue-canDeclareContainerElementTypeConstraintsForListContainingArrayType-mapping.xml");
IFishTank fishTank = ValidatorUtil.getValidatingProxy(new FishTank(), validator);
try {
fishTank.test6();
fail("Expected exception wasn't raised");
} catch (ConstraintViolationException e) {
assertThat(e.getConstraintViolations()).containsOnlyViolations(violationOf(Size.class).withMessage("size must be between 0 and 5"));
}
}
use of jakarta.validation.ConstraintViolationException in project hibernate-validator by hibernate.
the class ContainerElementTypeConstraintsForReturnValueXmlMappingTest method canDeclareContainerElementTypeConstraintsForArrayTypeReturnValueWithXmlMapping.
// HV-1428 Container element support is disabled for arrays
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "HV000226:.*")
@TestForIssue(jiraKey = "HV-1291")
public void canDeclareContainerElementTypeConstraintsForArrayTypeReturnValueWithXmlMapping() {
Validator validator = getValidator("returnvalue-canDeclareContainerElementTypeConstraintsForArrayType-mapping.xml");
IFishTank fishTank = ValidatorUtil.getValidatingProxy(new FishTank(), validator);
try {
fishTank.test5();
fail("Expected exception wasn't raised");
} catch (ConstraintViolationException e) {
assertThat(e.getConstraintViolations()).containsOnlyViolations(violationOf(Size.class).withMessage("size must be between 0 and 5"));
}
}
use of jakarta.validation.ConstraintViolationException in project Clownfish by rawdog71.
the class TemplateList method onCreate.
@Override
public void onCreate(ActionEvent actionEvent) {
try {
if (!templateName.isBlank()) {
CfTemplate newtemplate = new CfTemplate();
newtemplate.setName(templateName);
newtemplate.setContent("//" + templateName);
newtemplate.setScriptlanguage(templateScriptLanguage);
newtemplate.setLayout(layout);
cftemplateService.create(newtemplate);
templateListe = cftemplateService.findAll();
templateName = "";
selectedTemplate = newtemplate;
refresh();
onSelect(null);
onCheckOut(null);
} else {
FacesMessage message = new FacesMessage("Please enter template name");
FacesContext.getCurrentInstance().addMessage(null, message);
}
} catch (ConstraintViolationException ex) {
LOGGER.error(ex.getMessage());
}
}
Aggregations