### Question:
SpiToXs2aTrustedBeneficiariesMapper { public Xs2aTrustedBeneficiaries mapToXs2aTrustedBeneficiaries(SpiTrustedBeneficiaries spiTrustedBeneficiaries) { return Optional.ofNullable(spiTrustedBeneficiaries) .map(tb -> new Xs2aTrustedBeneficiaries( tb.getTrustedBeneficiaryId(), accountReferenceMapper.mapToXs2aAccountReference(tb.getDebtorAccount()), accountReferenceMapper.mapToXs2aAccountReference(tb.getCreditorAccount()), tb.getCreditorAgent(), tb.getCreditorName(), tb.getCreditorAlias(), tb.getCreditorId(), addressMapper.mapToAddress(tb.getCreditorAddress()) )) .orElse(null); }  Xs2aTrustedBeneficiaries mapToXs2aTrustedBeneficiaries(SpiTrustedBeneficiaries spiTrustedBeneficiaries); List<Xs2aTrustedBeneficiaries> mapToXs2aTrustedBeneficiariesList(List<SpiTrustedBeneficiaries> spiTrustedBeneficiaries);  }### Answer:
@Test void mapToXs2aTrustedBeneficiaries() { Xs2aTrustedBeneficiaries expected = jsonReader.getObjectFromFile("json/service/mapper/trusted-beneficiaries-model-mapper/xs2a-trusted-beneficiaries.json", Xs2aTrustedBeneficiaries.class); SpiTrustedBeneficiaries input = jsonReader.getObjectFromFile("json/service/mapper/trusted-beneficiaries-model-mapper/spi-trusted-beneficiaries.json", SpiTrustedBeneficiaries.class); SpiAccountReference spiDebtor = jsonReader.getObjectFromFile("json/service/mapper/trusted-beneficiaries-model-mapper/debtor-account.json", SpiAccountReference.class); SpiAccountReference spiCreditor = jsonReader.getObjectFromFile("json/service/mapper/trusted-beneficiaries-model-mapper/creditor-account.json", SpiAccountReference.class); AccountReference xs2aDebtor = jsonReader.getObjectFromFile("json/service/mapper/trusted-beneficiaries-model-mapper/debtor-account.json", AccountReference.class); AccountReference xs2aCreditor = jsonReader.getObjectFromFile("json/service/mapper/trusted-beneficiaries-model-mapper/creditor-account.json", AccountReference.class); SpiAddress spiAddress = jsonReader.getObjectFromFile("json/service/mapper/trusted-beneficiaries-model-mapper/creditor-address.json", SpiAddress.class); Xs2aAddress xs2aAddress = jsonReader.getObjectFromFile("json/service/mapper/trusted-beneficiaries-model-mapper/xs2a-address.json", Xs2aAddress.class); when(accountReferenceMapper.mapToXs2aAccountReference(spiDebtor)).thenReturn(xs2aDebtor); when(accountReferenceMapper.mapToXs2aAccountReference(spiCreditor)).thenReturn(xs2aCreditor); when(addressMapper.mapToAddress(spiAddress)).thenReturn(xs2aAddress); Xs2aTrustedBeneficiaries actual = spiToXs2aTrustedBeneficiariesMapper.mapToXs2aTrustedBeneficiaries(input); assertThat(actual).isNotNull(); assertThat(actual).isEqualTo(expected); }
@Test void mapToXs2aTrustedBeneficiaries_null() { Xs2aTrustedBeneficiaries actual = spiToXs2aTrustedBeneficiariesMapper.mapToXs2aTrustedBeneficiaries(null); assertThat(actual).isNull(); }