### Question:
CmsCorePaymentMapper { public PaymentInitiationJson mapToPaymentInitiationJson(PisPayment pisPayment) { return Optional.ofNullable(pisPayment) .map(ref -> { PaymentInitiationJson payment = new PaymentInitiationJson(); payment.setCreditorAddress(cmsAddressMapper.mapToAddress(pisPayment.getCreditorAddress())); payment.setRemittanceInformationStructured(mapToRemittanceInformationStructured(pisPayment.getRemittanceInformationStructured())); payment.setCreditorAgent(pisPayment.getCreditorAgent()); payment.setCreditorName(pisPayment.getCreditorName()); payment.setCreditorAccount(mapToAccountReference(pisPayment.getCreditorAccount())); payment.setDebtorAccount(mapToAccountReference(pisPayment.getDebtorAccount())); payment.setEndToEndIdentification(pisPayment.getEndToEndIdentification()); payment.setInstructionIdentification(pisPayment.getInstructionIdentification()); Amount amount = new Amount(); amount.setAmount(pisPayment.getAmount().toPlainString()); amount.setCurrency(mapToCurrency(pisPayment.getCurrency())); payment.setInstructedAmount(amount); payment.setPurposeCode(PurposeCode.fromValue(pisPayment.getPurposeCode())); payment.setRemittanceInformationUnstructured(pisPayment.getRemittanceInformationUnstructured()); payment.setRequestedExecutionDate(pisPayment.getRequestedExecutionDate()); payment.setUltimateCreditor(pisPayment.getUltimateCreditor()); payment.setUltimateDebtor(pisPayment.getUltimateDebtor()); return payment; }).orElse(null); }  PaymentInitiationJson mapToPaymentInitiationJson(PisPayment pisPayment); PaymentInitiationJson mapToPaymentInitiationJson(List<PisPayment> payments); BulkPaymentInitiationJson mapToBulkPaymentInitiationJson(List<PisPayment> payments); PeriodicPaymentInitiationJson mapToPeriodicPaymentInitiationJson(List<PisPayment> payments);  }### Answer:
@Test void mapToPaymentInitiationJson() { PisPayment pisPayment = jsonReader.getObjectFromFile("json/service/mapper/pis-payment.json", PisPayment.class); PaymentInitiationJson actual = mapper.mapToPaymentInitiationJson(pisPayment); PaymentInitiationJson expected = jsonReader.getObjectFromFile("json/service/mapper/payment-initiation-resp.json", PaymentInitiationJson.class); assertEquals(expected, actual); }
@Test void mapToPaymentInitiationJsonList_emptyValueValue() { assertNull(mapper.mapToPaymentInitiationJson(Collections.emptyList())); }
@Test void mapToPaymentInitiationJsonList() { PisPayment pisPayment = jsonReader.getObjectFromFile("json/service/mapper/pis-payment.json", PisPayment.class); PaymentInitiationJson actual = mapper.mapToPaymentInitiationJson(Arrays.asList(pisPayment, new PisPayment())); PaymentInitiationJson expected = jsonReader.getObjectFromFile("json/service/mapper/payment-initiation-resp.json", PaymentInitiationJson.class); assertEquals(expected, actual); }