### Question:
FieldExtractor { public Optional<String> extractField(HttpServletRequest request, String fieldName, MessageError messageError) { Optional<String> fieldOptional = Optional.empty(); try { fieldOptional = xs2aObjectMapper.toJsonField(request.getInputStream(), fieldName, new TypeReference<String>() { }); } catch (IOException e) { errorBuildingService.enrichMessageError(messageError, TppMessageInformation.of(FORMAT_ERROR_DESERIALIZATION_FAIL)); } return fieldOptional; }  Optional<String> extractField(HttpServletRequest request, String fieldName, MessageError messageError); Optional<String> extractOptionalField(HttpServletRequest request, String fieldName); List<String> extractList(HttpServletRequest request, String fieldName, MessageError messageError); List<String> extractOptionalList(HttpServletRequest request, String fieldName); Optional<T> mapBodyToInstance(HttpServletRequest request, MessageError messageError, Class<T> clazz);  }### Answer:
@Test void extractField_Success() { Optional<String> expectedResult = Optional.of(FIELD_VALUE); Optional<String> actualResult = fieldExtractor.extractField(mockRequest, FIELD_NAME, messageError); assertEquals(expectedResult, actualResult); assertTrue(messageError.getTppMessages().isEmpty()); }
@Test void extractField_Exception() { Optional<String> actualResult = fieldExtractor.extractField(mockedRequest, FIELD_NAME, messageError); assertFalse(actualResult.isPresent()); assertEquals(DESERIALIZATION_ERROR, messageError); }