### Question:
FieldExtractor { public Optional<String> extractOptionalField(HttpServletRequest request, String fieldName) { try { return xs2aObjectMapper.toJsonField(request.getInputStream(), fieldName, new TypeReference<String>() { }); } catch (IOException e) { return Optional.empty(); } }  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 extractOptionalField_Success() { Optional<String> expectedResult = Optional.of(FIELD_VALUE); Optional<String> actualResult = fieldExtractor.extractOptionalField(mockRequest, FIELD_NAME); assertEquals(expectedResult, actualResult); }
@Test void extractOptionalField_Exception() { Optional<String> actualResult = fieldExtractor.extractOptionalField(mockedRequest, FIELD_NAME); assertFalse(actualResult.isPresent()); }