use of io.crnk.jpa.internal.TransactionRollbackExceptionMapper in project crnk-framework by crnk-project.
the class JpaExceptionMapperTests method testTransactionRollbackException.
@Test
public void testTransactionRollbackException() {
javax.transaction.RollbackException exception = new javax.transaction.RollbackException() {
public Throwable getCause() {
return new BadRequestException("test");
}
};
ExceptionMapperRegistry exceptionMapperRegistry = boot.getExceptionMapperRegistry();
TransactionRollbackExceptionMapper mapper = (TransactionRollbackExceptionMapper) exceptionMapperRegistry.findMapperFor(exception.getClass()).get();
ErrorResponse response = mapper.toErrorResponse(exception);
ErrorData errorData = response.getErrors().iterator().next();
Assert.assertEquals(Integer.toString(HttpStatus.BAD_REQUEST_400), errorData.getStatus());
Assert.assertEquals("test", errorData.getDetail());
}
Aggregations