### Question:
PaymentModelMapperXs2a { public byte[] mapToXs2aRawPayment(PaymentInitiationParameters requestParameters, Object xmlSct, PeriodicPaymentInitiationXmlPart2StandingorderTypeJson jsonStandingOrderType) { if (requestParameters.getPaymentType() == PERIODIC) { return buildPeriodicBinaryBodyData(httpServletRequest, xmlSct, jsonStandingOrderType); } return buildBinaryBodyData(httpServletRequest); }  byte[] mapToXs2aPayment(); byte[] mapToXs2aRawPayment(PaymentInitiationParameters requestParameters, Object xmlSct, PeriodicPaymentInitiationXmlPart2StandingorderTypeJson jsonStandingOrderType);  }### Answer:
@Test void mapToXs2aRawPayment_notPeriodic() { PaymentInitiationParameters requestParameters = new PaymentInitiationParameters(); requestParameters.setPaymentType(PaymentType.SINGLE); mockHttpServletRequest.setContent(CONTENT.getBytes()); byte[] actual = paymentModelMapper.mapToXs2aRawPayment(requestParameters, "xml", null); assertEquals(CONTENT, new String(actual)); }
@Test void mapToXs2aRawPayment_periodic() { PaymentInitiationParameters requestParameters = new PaymentInitiationParameters(); requestParameters.setPaymentType(PaymentType.PERIODIC); PeriodicPaymentInitiationXmlPart2StandingorderTypeJson jsonStandingOrderType = new PeriodicPaymentInitiationXmlPart2StandingorderTypeJson(); jsonStandingOrderType.setDayOfExecution(DayOfExecution._5); jsonStandingOrderType.setExecutionRule(ExecutionRule.FOLLOWING); jsonStandingOrderType.setFrequency(FrequencyCode.MONTHLY); byte[] actual = paymentModelMapper.mapToXs2aRawPayment(requestParameters, "xml", jsonStandingOrderType); String expected = jsonReader.getStringFromFile("json/web/mapper/raw-periodic-payment.txt").trim(); assertEquals(expected, new String(actual)); }
@Test void mapToXs2aRawPayment_exceptionWhenXmlPartIsNull() { PaymentInitiationParameters requestParameters = new PaymentInitiationParameters(); requestParameters.setPaymentType(PaymentType.PERIODIC); PeriodicPaymentInitiationXmlPart2StandingorderTypeJson jsonStandingOrderType = new PeriodicPaymentInitiationXmlPart2StandingorderTypeJson(); jsonStandingOrderType.setDayOfExecution(DayOfExecution._5); jsonStandingOrderType.setExecutionRule(ExecutionRule.FOLLOWING); jsonStandingOrderType.setFrequency(FrequencyCode.MONTHLY); assertThrows(IllegalArgumentException.class, () -> paymentModelMapper.mapToXs2aRawPayment(requestParameters, null, jsonStandingOrderType)); }