ForbiddenRequestExceptionMapper implements ExceptionMapper<ForbiddenRequestException> { @Override public Response toResponse(final ForbiddenRequestException exception) { LOGGER.debug("Forbidden Request", exception); return Response.status(FORBIDDEN) .entity(createObjectBuilder().add("error", exception.getMessage()).build().toString()) .build(); }  @Override Response toResponse(final ForbiddenRequestException exception);  }
@Test public void shouldReturn403ResponseForForbiddenRequestException() throws Exception { final Response response = exceptionMapper.toResponse(new ForbiddenRequestException(TEST_ERROR_MESSAGE)); assertThat(response.getStatus(), is(FORBIDDEN.getStatusCode())); assertThat(response.getEntity(), notNullValue()); assertThat(response.getEntity().toString(), hasJsonPath("$.error", equalTo(TEST_ERROR_MESSAGE))); }