### Question:
FeignExceptionReader { public String getErrorMessage(FeignException feignException) { return Optional.ofNullable(feignException.content()) .map(this::readTree) .map(this::getMessage) .map(JsonNode::asText) .orElse(null); }  String getErrorMessage(FeignException feignException); String getErrorCode(FeignException feignException);  }### Answer:
@Test void getErrorMessageSuccess() throws JsonProcessingException { String feignBodyString = buildFeignBodyMessage(DEV_MESSAGE); FeignException feignException = FeignException.errorStatus("", buildErrorResponse(feignBodyString)); String errorMessage = feignExceptionReader.getErrorMessage(feignException); assertEquals(DEV_MESSAGE, errorMessage); }
@Test void getErrorMessageNoDevMessage() throws JsonProcessingException { String feignBodyString = buildFeignBodyMessage("message", DEV_MESSAGE); FeignException feignException = FeignException.errorStatus("", buildErrorResponse(feignBodyString)); String errorMessage = feignExceptionReader.getErrorMessage(feignException); assertNotNull(errorMessage); }
@Test void getErrorMessageNoDevMessageAndNoMessage() throws JsonProcessingException { String feignBodyString = buildFeignBodyMessage("other message", DEV_MESSAGE); FeignException feignException = FeignException.errorStatus("", buildErrorResponse(feignBodyString)); String errorMessage = feignExceptionReader.getErrorMessage(feignException); assertNull(errorMessage); }
@Test void getErrorMessageNoContent() { FeignException feignException = FeignException.errorStatus("", FeignExceptionHandler.error(HttpStatus.BAD_REQUEST)); String errorMessage = feignExceptionReader.getErrorMessage(feignException); assertNull(errorMessage); }