### Question:
CardAccountModelMapper { protected String mapToAccountDetailsCurrency(Currency currency) { return Optional.ofNullable(currency) .map(Currency::getCurrencyCode) .orElseGet(this::getMulticurrencyRepresentationOrNull); }  CardAccountList mapToCardAccountList(Xs2aCardAccountListHolder xs2aCardAccountListHolder); InlineResponse2002 mapToInlineResponse202(Xs2aCardAccountDetailsHolder xs2aAccountDetailsHolder); @Mapping(target = "_links", ignore = true) @Mapping(target = "links", expression = "java(hrefLinkMapper.mapToLinksMap(accountDetails.getLinks()))") @Mapping(target = "status", source = "accountStatus") @Mapping(target = "usage", source = "usageType") @Mapping(target = "currency", expression = "java(mapToAccountDetailsCurrency(accountDetails.getCurrency()))") abstract CardAccountDetails mapToCardAccountDetails(Xs2aCardAccountDetails accountDetails); @Mapping(target = "balanceType", expression = "java(mapToBalanceType(balance.getBalanceType()))") @Mapping(target = "lastChangeDateTime", expression = "java(mapToOffsetDateTime(balance.getLastChangeDateTime()))") abstract Balance mapToBalance(Xs2aBalance balance); @Mapping(target = "cardAccount", source = "xs2aAccountReference") abstract ReadCardAccountBalanceResponse200 mapToBalance(Xs2aBalancesReport balancesReport); @Mapping(target = "_links", ignore = true) @Mapping(target = "links", expression = "java(hrefLinkMapper.mapToLinksMap(accountReport.getLinks()))") abstract CardAccountReport mapToCardAccountReport(Xs2aCardAccountReport accountReport); @Mapping(target = "_links", ignore = true) @Mapping(target = "links", expression = "java(hrefLinkMapper.mapToLinksMap(cardTransactionsReport.getLinks()))") @Mapping(target = "cardTransactions", source = "cardAccountReport") @Mapping(target = "cardAccount", source = "accountReference") abstract CardAccountsTransactionsResponse200 mapToTransactionsResponse200Json(Xs2aCardTransactionsReport cardTransactionsReport); byte[] mapToTransactionsResponseRaw(Xs2aCardTransactionsReport transactionsReport); @Mapping(target = "currencyExchange", expression = "java(mapToReportExchanges(transactions.getCurrencyExchange()))") abstract CardTransaction mapToCardTransaction(de.adorsys.psd2.xs2a.domain.CardTransaction transactions);  }### Answer:
@Test void mapToAccountDetailsCurrency_currencyPresent() { Currency currency = Currency.getInstance("EUR"); String currencyRepresentation = mapper.mapToAccountDetailsCurrency(currency); assertEquals(currency.getCurrencyCode(), currencyRepresentation); }
@Test void mapToAccountDetailsCurrency_currencyNull() { String currencyRepresentation = mapper.mapToAccountDetailsCurrency(null); assertNull(currencyRepresentation); }
@Test void mapToAccountDetailsCurrency_multicurrencySubaccount() { when(aspspProfileService.getMulticurrencyAccountLevel()).thenReturn(MulticurrencyAccountLevel.SUBACCOUNT); String currencyRepresentation = mapper.mapToAccountDetailsCurrency(null); assertNull(currencyRepresentation); }
@Test void mapToAccountDetailsCurrency_multicurrencyAggregations() { Arrays.asList(MulticurrencyAccountLevel.AGGREGATION, MulticurrencyAccountLevel.AGGREGATION_AND_SUBACCOUNT).forEach(multicurrencyAccountLevel -> { when(aspspProfileService.getMulticurrencyAccountLevel()).thenReturn(multicurrencyAccountLevel); String currencyRepresentation = mapper.mapToAccountDetailsCurrency(null); assertEquals("XXX", currencyRepresentation); }); }