### Question:
IdaJsonProcessingExceptionMapper implements ExceptionMapper<JsonProcessingException> { @Override public Response toResponse(JsonProcessingException exception) { if (exception instanceof JsonGenerationException) { LOG.error("Error generating JSON", exception); return Response.serverError().build(); } if (exception.getMessage().startsWith("No suitable constructor found")) { LOG.error("Unable to deserialize the specific type", exception); return Response.serverError().build(); } LOG.info(exception.getLocalizedMessage()); return Response .status(Response.Status.BAD_REQUEST) .type(MediaType.APPLICATION_JSON_TYPE) .entity(createUnauditedErrorStatus(UUID.randomUUID(), ExceptionType.JSON_PARSING, exception.getOriginalMessage())) .build(); }  @Override Response toResponse(JsonProcessingException exception);  }### Answer:
@Test public void toResponse_shouldReturnServerErrorWhenExceptionThrownGeneratingJson() { assertThat(mapper.toResponse(mock(JsonGenerationException.class)).getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); }
@Test public void toResponse_shouldReturnServerErrorWhenDeserialisationLacksAppropriateConstructor() { assertThat(mapper.toResponse(new JsonMappingException(null, "No suitable constructor found")).getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); }
@Test public void toResponse_shouldReturnBadRequestAndErrorStatusDtoWhenErrorDeemedToBeFromClient() { String clientErrorMessage = "This is a client error"; Response response = mapper.toResponse(new JsonMappingException(null, clientErrorMessage)); ErrorStatusDto errorStatus = (ErrorStatusDto) response.getEntity(); assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode()); assertThat(errorStatus.isAudited()).isEqualTo(false); assertThat(errorStatus.getClientMessage()).isEqualTo(clientErrorMessage); assertThat(errorStatus.getExceptionType()).isEqualTo(ExceptionType.JSON_PARSING); }