### Question:
ThrowableExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(Throwable t) { if (t instanceof WebApplicationException) { WebApplicationException webEx = (WebApplicationException) t; if(webEx.getResponse().getStatus() == 500) { this.logger.error("Internal server error while handling a request", webEx); } ResponseBuilder rb = Response.status(webEx.getResponse().getStatus()); String message = webEx.getLocalizedMessage(); if (webEx.getCause() != null) { message = message + " caused by " + webEx.getCause().toString(); } return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); } ResponseBuilder rb = Response.status(Status.INTERNAL_SERVER_ERROR); String message = t.toString(); this.logger.error("Error while HTTP Request on the Server", t); return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); }  @Override Response toResponse(Throwable t);  }### Answer:
@Test void testStatus() { try (Response response = this.tEM.toResponse(new WebApplicationException(404));) { assertThat(response.getStatus(), is(404)); } }
@Test void testStatus500() { try (Response response = this.tEM.toResponse(new WebApplicationException(500));) { assertThat(response.getStatus(), is(500)); } }
@Test void testMessage() { try (Response response = this.tEM.toResponse(new WebApplicationException("Forbidden", 403));) { assertThat(response.getStatus(), is(403)); assertThat(response.getEntity(), is("Forbidden")); } }
@Test void testCause() { try (Response response = this.tEM .toResponse(new WebApplicationException(new IllegalArgumentException("Input is not a String")));) { assertThat(response.getStatus(), is(500)); assertThat(response.getEntity(), is( "HTTP 500 Internal Server Error caused by java.lang.IllegalArgumentException: Input is not a String")); } }
@Test void testUnkownThrowable() { try (Response response = this.tEM.toResponse(new IllegalArgumentException("Input is not a String"));) { assertThat(response.getStatus(), is(500)); assertThat(response.getEntity(), is("java.lang.IllegalArgumentException: Input is not a String")); } }