@Test
public void entity_withCause() throws Exception {
// given
final Exception cause = new Exception("barfoo");
final JsonApplicationException ex = JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, cause, "foobar");
// when
final Response response = exceptionMapper.toResponse(ex);
final String entity = (String) response.getEntity();
assertThat(entity, is(not(nullValue())));
final JsonRepresentation jsonRepr = JsonMapper.instance().read(entity, JsonRepresentation.class);
// then
assertThat(jsonRepr.getString("message"), is(ex.getMessage()));
final JsonRepresentation causedByRepr = jsonRepr.getRepresentation("causedBy");
assertThat(causedByRepr, is(not(nullValue())));
assertThat(causedByRepr.getString("message"), is(cause.getMessage()));
}