use of io.crnk.core.engine.error.ErrorResponse in project crnk-framework by crnk-project.
the class CrnkExceptionMapperTest method badRequest.
@Test
public void badRequest() {
CrnkExceptionMapper mapper = new CrnkExceptionMapper();
ErrorResponse response = mapper.toErrorResponse(new BadRequestException("testMessage"));
assertThat(response.getHttpStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400);
assertThat(mapper.accepts(response)).isTrue();
CrnkMappableException exception = mapper.fromErrorResponse(response);
assertThat(exception).isInstanceOf(BadRequestException.class);
assertThat(exception.getMessage()).isEqualTo("testMessage");
}
use of io.crnk.core.engine.error.ErrorResponse in project crnk-framework by crnk-project.
the class CrnkExceptionMapperTest method shouldMapToErrorResponse.
@Test
public void shouldMapToErrorResponse() throws Exception {
CrnkExceptionMapper mapper = new CrnkExceptionMapper();
ErrorResponse response = mapper.toErrorResponse(new SampleCrnkException());
assertThat(response.getHttpStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
assertThat((Iterable<?>) response.getResponse().getEntity()).hasSize(1).extracting("title", "detail").containsExactly(tuple(TITLE1, DETAIL1));
}
use of io.crnk.core.engine.error.ErrorResponse 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");
}
Aggregations