use of org.jboss.as.test.integration.jpa.beanvalidation.SFSB1 in project wildfly by wildfly.
the class JPABeanValidationTestCase method testSuccessfulBeanValidation.
/**
* Test that a bean validation error is not thrown
*
* @throws Exception
*/
@Test
public void testSuccessfulBeanValidation() throws Exception {
SFSB1 sfsb1 = lookup("SFSB1", SFSB1.class);
sfsb1.createEmployee("name", "address", 1);
}
use of org.jboss.as.test.integration.jpa.beanvalidation.SFSB1 in project wildfly by wildfly.
the class JPABeanValidationTestCase method testFailingBeanValidationNullAddress.
/**
* Test that a bean validation error is thrown
*
* @throws Exception
*/
@Test
public void testFailingBeanValidationNullAddress() throws Exception {
SFSB1 sfsb1 = lookup("SFSB1", SFSB1.class);
try {
sfsb1.createEmployee("name", null, 2);
fail("should of thrown validation error for null address in Employee entity");
} catch (Throwable throwable) {
ConstraintViolationException constraintViolationException = null;
// find the ConstraintViolationException
while (throwable != null && !(throwable instanceof ConstraintViolationException)) {
throwable = throwable.getCause();
}
// should be null or instanceof ConstraintViolationException
constraintViolationException = (ConstraintViolationException) throwable;
assertTrue("expected ConstraintViolationException but got " + constraintViolationException, constraintViolationException instanceof ConstraintViolationException);
}
}
Aggregations