### Question:
ConsentModelMapper { public UpdateConsentPsuDataReq mapToUpdatePsuData(PsuIdData psuData, String consentId, String authorizationId, Map body) { UpdateConsentPsuDataReq updatePsuData = new UpdateConsentPsuDataReq(); updatePsuData.setPsuData(psuData); updatePsuData.setConsentId(consentId); updatePsuData.setAuthorizationId(authorizationId); updatePsuData.setAuthorisationType(AuthorisationType.CONSENT); if (body != null && !body.isEmpty()) { Optional.ofNullable(body.get("psuData")) .map(o -> (LinkedHashMap<String, String>) o) .ifPresent(psuDataMap -> updatePsuData.setPassword(psuDataMap.get("password"))); Optional.ofNullable(body.get("authenticationMethodId")) .map(o -> (String) o) .ifPresent(updatePsuData::setAuthenticationMethodId); Optional.ofNullable(body.get("scaAuthenticationData")) .map(o -> (String) o) .ifPresent(updatePsuData::setScaAuthenticationData); Optional.ofNullable(body.get("confirmationCode")) .map(o -> (String) o) .ifPresent(updatePsuData::setConfirmationCode); } else { updatePsuData.setUpdatePsuIdentification(true); } return updatePsuData; }  CreateConsentReq mapToCreateConsentReq(Consents consent, TppRedirectUri tppRedirectUri,
                                                  TppNotificationData tppNotificationData, String tppBrandLoggingInformation,
                                                  String instanceId); ConsentStatusResponse200 mapToConsentStatusResponse200(ConsentStatusResponse consentStatusResponse); ConsentsResponse201 mapToConsentsResponse201(CreateConsentResponse createConsentResponse); ConsentInformationResponse200Json mapToConsentInformationResponse200Json(AisConsent aisConsent); List<AccountReference> mapToXs2aAccountReferences(List<de.adorsys.psd2.model.AccountReference> references); AccountReference mapToAccountReference(Object reference); UpdateConsentPsuDataReq mapToUpdatePsuData(PsuIdData psuData, String consentId, String authorizationId, Map body); Authorisations mapToAuthorisations(Xs2aPaymentCancellationAuthorisationSubResource idsContainer); Xs2aUpdatePisCommonPaymentPsuDataRequest mapToPisUpdatePsuData(PsuIdData psuData, String paymentId, String authorisationId, PaymentType paymentService, String paymentProduct, Map body); final AccountModelMapper accountModelMapper; }### Answer:
@Test void mapToUpdatePsuData_WithBody() { UpdateConsentPsuDataReq expected = jsonReader.getObjectFromFile("json/service/mapper/update-consent-psu-data-req-with-password.json", UpdateConsentPsuDataReq.class); UpdateConsentPsuDataReq actual = consentModelMapper.mapToUpdatePsuData(psuIdData, CONSENT_ID, AUTHORISATION_ID, bodyMap); assertEquals(expected, actual); }
@Test void mapToUpdatePsuData_WithEmptyBody() { UpdateConsentPsuDataReq expected = jsonReader.getObjectFromFile("json/service/mapper/update-consent-psu-data-req-without-password.json", UpdateConsentPsuDataReq.class); UpdateConsentPsuDataReq actual = consentModelMapper.mapToUpdatePsuData(psuIdData, CONSENT_ID, AUTHORISATION_ID, getEmptyBodyMap()); assertEquals(expected, actual); }
@Test void mapToUpdatePsuData_WithoutBody() { UpdateConsentPsuDataReq expected = jsonReader.getObjectFromFile("json/service/mapper/update-consent-psu-data-req-without-password.json", UpdateConsentPsuDataReq.class); UpdateConsentPsuDataReq actual = consentModelMapper.mapToUpdatePsuData(psuIdData, CONSENT_ID, AUTHORISATION_ID, null); assertEquals(expected, actual); }