### Question:
Xs2aPiisConsentMapper { public CmsConsent mapToCmsConsent(CreatePiisConsentRequest request, PsuIdData psuData, TppInfo tppInfo) { PiisConsentData piisConsentData = new PiisConsentData(request.getCardNumber(), request.getCardExpiryDate(), request.getCardInformation(), request.getRegistrationInformation()); byte[] consentDataInBytes = consentDataMapper.getBytesFromConsentData(piisConsentData); CmsConsent cmsConsent = new CmsConsent(); cmsConsent.setConsentData(consentDataInBytes); ConsentTppInformation tppInformation = new ConsentTppInformation(); tppInformation.setTppInfo(tppInfo); tppInformation.setTppRedirectPreferred(requestProviderService.resolveTppRedirectPreferred().orElse(false)); cmsConsent.setTppInformation(tppInformation); AuthorisationTemplate authorisationTemplate = new AuthorisationTemplate(); String tppRedirectURI = requestProviderService.getTppRedirectURI(); if (tppRedirectURI != null) { TppRedirectUri tppRedirectUri = new TppRedirectUri(tppRedirectURI, requestProviderService.getTppNokRedirectURI()); authorisationTemplate.setTppRedirectUri(tppRedirectUri); } cmsConsent.setAuthorisationTemplate(authorisationTemplate); cmsConsent.setFrequencyPerDay(PIIS_FREQUENCY_PER_DAY); cmsConsent.setInternalRequestId(requestProviderService.getInternalRequestIdString()); cmsConsent.setPsuIdDataList(Collections.singletonList(psuData)); cmsConsent.setConsentType(ConsentType.PIIS_TPP); AccountAccess accountAccess = new AccountAccess(Collections.singletonList(request.getAccount()), Collections.emptyList(), Collections.emptyList(), null); cmsConsent.setTppAccountAccesses(accountAccess); cmsConsent.setAspspAccountAccesses(AccountAccess.EMPTY_ACCESS); cmsConsent.setConsentStatus(ConsentStatus.RECEIVED); cmsConsent.setInstanceId(requestProviderService.getInstanceId()); return cmsConsent; }  @Mapping(target = "consentTppInformation", source = "tppInformation") abstract PiisConsent mapToPiisConsent(CmsConsent cmsConsent); UpdateConsentPsuDataReq mapToUpdateConsentPsuDataReq(UpdateAuthorisationRequest request,
                                                                AuthorisationProcessorResponse response); CmsConsent mapToCmsConsent(CreatePiisConsentRequest request, PsuIdData psuData, TppInfo tppInfo);  }### Answer:
@Test void mapToCmsConsent() { AccountReference accountReference = new AccountReference(); accountReference.setIban("DE15500105172295759744"); accountReference.setCurrency("EUR"); de.adorsys.psd2.xs2a.core.profile.AccountReference reference = new de.adorsys.psd2.xs2a.core.profile.AccountReference(null, null, accountReference.getIban(), null, null, null, null, Currency.getInstance(accountReference.getCurrency())); when(consentModelMapper.mapToXs2aAccountReferences(Collections.singletonList(accountReference))) .thenReturn(Collections.singletonList(reference)); PsuIdData psuIdData = jsonReader.getObjectFromFile("json/service/mapper/psu-id-data.json", PsuIdData.class); CreatePiisConsentRequest request = jsonReader.getObjectFromFile("json/piis/create-piis-consent.json", CreatePiisConsentRequest.class); TppInfo tppInfo = jsonReader.getObjectFromFile("json/service/mapper/tpp-info.json", TppInfo.class); CmsConsent cmsConsent = xs2aPiisConsentMapper.mapToCmsConsent(request, psuIdData, tppInfo); CmsConsent cmsConsentExpected = jsonReader.getObjectFromFile("json/service/mapper/consent/piis/cms-consent-creation.json", CmsConsent.class); assertEquals(cmsConsentExpected, cmsConsent); }