### Question:
CmsCorePaymentMapper { public PeriodicPaymentInitiationJson mapToPeriodicPaymentInitiationJson(List<PisPayment> payments) { if (CollectionUtils.isEmpty(payments)) { return null; } PisPayment pisPayment = payments.get(0); PeriodicPaymentInitiationJson payment = new PeriodicPaymentInitiationJson(); payment.setDebtorAccount(mapToAccountReference(pisPayment.getDebtorAccount())); 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.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.setUltimateCreditor(pisPayment.getUltimateCreditor()); payment.setUltimateDebtor(pisPayment.getUltimateDebtor()); payment.setStartDate(pisPayment.getStartDate()); payment.setEndDate(pisPayment.getEndDate()); payment.setExecutionRule(ExecutionRule.fromValue(pisPayment.getExecutionRule().getValue())); payment.setFrequency(FrequencyCode.valueOf(pisPayment.getFrequency())); payment.setDayOfExecution(DayOfExecution.fromValue(pisPayment.getDayOfExecution().getValue())); return payment; }  PaymentInitiationJson mapToPaymentInitiationJson(PisPayment pisPayment); PaymentInitiationJson mapToPaymentInitiationJson(List<PisPayment> payments); BulkPaymentInitiationJson mapToBulkPaymentInitiationJson(List<PisPayment> payments); PeriodicPaymentInitiationJson mapToPeriodicPaymentInitiationJson(List<PisPayment> payments);  }### Answer:
@Test void mapToPeriodicPaymentInitiationJson() { PisPayment pisPayment = jsonReader.getObjectFromFile("json/service/mapper/pis-payment.json", PisPayment.class); PeriodicPaymentInitiationJson actual = mapper.mapToPeriodicPaymentInitiationJson(Collections.singletonList(pisPayment)); PeriodicPaymentInitiationJson expected = jsonReader.getObjectFromFile("json/service/mapper/periodic-payment-initiation-resp.json", PeriodicPaymentInitiationJson.class); assertEquals(expected, actual); }
@Test void mapToPeriodicPaymentInitiationJson_nullValue() { assertNull(mapper.mapToPeriodicPaymentInitiationJson(null)); }