### Question:
RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> { @Override public Response toResponse(RuntimeException exception) { if (exception instanceof NotFoundException) { return Response.status(Status.NOT_FOUND).build(); } else { logger.error("Error occured", exception); return Response.status(Status.INTERNAL_SERVER_ERROR) .entity(new ExceptionResponse("Unexpected Internal Exception")).build(); } }  @Override Response toResponse(RuntimeException exception);  }### Answer:
@Test public void testResponse() { RuntimeExceptionMapper mapper = new RuntimeExceptionMapper(); Response r = mapper.toResponse(new RuntimeException("This is the run time exception message")); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus()); assertThat(r.getEntity(), instanceOf(ExceptionResponse.class)); assertThat(((ExceptionResponse) r.getEntity()).getMessage(), equalTo("Unexpected Internal Exception")); }
@Test public void preserve404ExceptionForForwarding() { RuntimeExceptionMapper mapper = new RuntimeExceptionMapper(); Response r = mapper.toResponse(new NotFoundException("not found")); assertEquals(Status.NOT_FOUND.getStatusCode(), r.getStatus()); assertThat(r.getEntity(), is(nullValue())); }