use of io.crnk.rs.internal.WebApplicationExceptionMapper in project crnk-framework by crnk-project.
the class WebApplicationExceptionMapperTest method test.
@Test
public void test() {
WebApplicationExceptionMapper mapper = new WebApplicationExceptionMapper();
WebApplicationException exception = new WebApplicationException("hi");
ErrorResponse response = mapper.toErrorResponse(exception);
Iterable<ErrorData> errors = response.getErrors();
Iterator<ErrorData> iterator = errors.iterator();
ErrorData data = iterator.next();
Assert.assertFalse(iterator.hasNext());
Assert.assertEquals("500", data.getStatus());
Assert.assertEquals("hi", data.getCode());
Assert.assertTrue(mapper.accepts(response));
WebApplicationException fromErrorResponse = mapper.fromErrorResponse(response);
Assert.assertEquals("hi", fromErrorResponse.getMessage());
}
Aggregations