Search in sources :

Example 6 with CrnkExceptionMapper

use of io.crnk.core.engine.internal.exception.CrnkExceptionMapper in project crnk-framework by crnk-project.

the class CrnkExceptionMapperTest method internalServerError.

@Test
public void internalServerError() {
    CrnkExceptionMapper mapper = new CrnkExceptionMapper();
    ErrorResponse response = mapper.toErrorResponse(new InternalServerErrorException("testMessage"));
    assertThat(response.getHttpStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
    assertThat(mapper.accepts(response)).isTrue();
    CrnkMappableException exception = mapper.fromErrorResponse(response);
    assertThat(exception).isInstanceOf(InternalServerErrorException.class);
    assertThat(exception.getMessage()).isEqualTo("testMessage");
}
Also used : CrnkExceptionMapper(io.crnk.core.engine.internal.exception.CrnkExceptionMapper) ErrorResponse(io.crnk.core.engine.error.ErrorResponse) Test(org.junit.Test)

Aggregations

ErrorResponse (io.crnk.core.engine.error.ErrorResponse)6 CrnkExceptionMapper (io.crnk.core.engine.internal.exception.CrnkExceptionMapper)6 Test (org.junit.Test)6