### Question:
ApiExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(final Throwable throwable) { if (throwable instanceof ApiException) { log.info("4xx exception is thrown", throwable); ApiException apiException = (ApiException) throwable; return apiException.getResponse(); } else { log.error("5xx exception is thrown", throwable); return new InternalServerApiException().getResponse(); } }  @Override Response toResponse(final Throwable throwable);  }### Answer:
@Test public void toResponse_apiException() { NotFoundException exception = new NotFoundException(); Response response = exceptionMapper.toResponse(new NotFoundApiException(exception)); assertThat(response.getStatus()).isEqualTo(404); assertThat(response.getMediaType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); assertThat(response.getEntity()).isEqualTo(exception); }
@Test public void toResponse_otherException() { InternalServerErrorException exception = new InternalServerErrorException() .errorCode("InternalError") .message("Internal Server Error."); Response response = exceptionMapper.toResponse(new IllegalArgumentException()); assertThat(response.getStatus()).isEqualTo(500); assertThat(response.getMediaType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); assertThat(response.getEntity()).isEqualTo(exception); }