### Question:
ConsentModelMapper { public ConsentsResponse201 mapToConsentsResponse201(CreateConsentResponse createConsentResponse) { return Optional.ofNullable(createConsentResponse) .map(cnst -> new ConsentsResponse201() .consentStatus(ConsentStatus.fromValue(cnst.getConsentStatus())) .consentId(cnst.getConsentId()) .scaMethods(scaMethodsMapper.mapToScaMethods(cnst.getScaMethods())) ._links(hrefLinkMapper.mapToLinksMap(cnst.getLinks())) .psuMessage(cnst.getPsuMessage()) .tppMessages(mapToTppMessage2XXList(cnst.getTppMessageInformation())) ) .orElse(null); }  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 mapToConsentsResponse201_withScaMethods_shouldReturnArrayOfThem() { ScaMethods methods = new ScaMethods(); methods.add(new AuthenticationObject()); when(scaMethodsMapper.mapToScaMethods(anyList())).thenReturn(methods); when(hrefLinkMapper.mapToLinksMap(any(Links.class))).thenReturn(buildLinks()); ConsentsResponse201 actual = consentModelMapper.mapToConsentsResponse201(createConsentResponseWithScaMethods); checkCommonFields(actual); assertFalse(actual.getScaMethods().isEmpty()); }
@Test void mapToConsentsResponse201_withScaMethods_withWarnings() { ScaMethods methods = new ScaMethods(); methods.add(new AuthenticationObject()); when(scaMethodsMapper.mapToScaMethods(anyList())).thenReturn(methods); when(hrefLinkMapper.mapToLinksMap(any(Links.class))).thenReturn(buildLinks()); createConsentResponseWithScaMethods.setTppMessageInformation(Collections.singleton(TppMessageInformation.buildWarning(INVALID_DOMAIN_MESSAGE))); ConsentsResponse201 actual = consentModelMapper.mapToConsentsResponse201(createConsentResponseWithScaMethods); checkCommonFields(actual); assertFalse(actual.getScaMethods().isEmpty()); }
@Test void mapToConsentsResponse201_withoutScaMethods_shouldNotReturnEmptyArray() { when(hrefLinkMapper.mapToLinksMap(any(Links.class))).thenReturn(buildLinks()); ConsentsResponse201 actual = consentModelMapper.mapToConsentsResponse201(createConsentResponseWithoutScaMethods); checkCommonFields(actual); assertNull(actual.getScaMethods()); }