### Question:
RawToXs2aPaymentMapper { public BulkPayment mapToBulkPayment(byte[] paymentBody) { if (ArrayUtils.isEmpty(paymentBody)) { return null; } BulkPaymentInitiationJson paymentInitiationJson = readBytes(paymentBody, BulkPaymentInitiationJson.class); BulkPayment bulkPayment = paymentModelMapper.mapToXs2aPayment(paymentInitiationJson); if (bulkPayment != null) { bulkPayment.setPaymentData(paymentBody); } return bulkPayment; }  SinglePayment mapToSinglePayment(byte[] paymentBody); PeriodicPayment mapToPeriodicPayment(byte[] paymentBody); BulkPayment mapToBulkPayment(byte[] paymentBody);  }### Answer:
@Test void mapToBulkPayment() { BulkPaymentInitiationJson paymentInitiationJson = jsonReader.getObjectFromFile(BULK_PAYMENT_PSD2_JSON_PATH, BulkPaymentInitiationJson.class); BulkPayment xs2aBulkPayment = jsonReader.getObjectFromFile(BULK_PAYMENT_XS2A_JSON_PATH, BulkPayment.class); when(paymentModelMapper.mapToXs2aPayment(paymentInitiationJson)).thenReturn(xs2aBulkPayment); byte[] paymentBody = jsonReader.getBytesFromFile(BULK_PAYMENT_PSD2_JSON_PATH); BulkPayment expectedBulkPayment = jsonReader.getObjectFromFile(BULK_PAYMENT_XS2A_JSON_PATH, BulkPayment.class); expectedBulkPayment.setPaymentData(paymentBody); BulkPayment actual = rawToXs2aPaymentMapper.mapToBulkPayment(paymentBody); assertEquals(expectedBulkPayment, actual); }
@Test void mapToBulkPayment_null() { BulkPayment actual = rawToXs2aPaymentMapper.mapToBulkPayment(null); assertNull(actual); }
@Test void mapToBulkPayment_malformedBody() { BulkPayment actual = rawToXs2aPaymentMapper.mapToBulkPayment(MALFORMED_PAYMENT_BODY); assertNull(actual); verify(paymentModelMapper, never()).mapToXs2aPayment(any(BulkPaymentInitiationJson.class)); }
@Test void mapToBulkPayment_nullBulkPayment() { BulkPaymentInitiationJson paymentInitiationJson = jsonReader.getObjectFromFile(BULK_PAYMENT_PSD2_JSON_PATH, BulkPaymentInitiationJson.class); when(paymentModelMapper.mapToXs2aPayment(paymentInitiationJson)).thenReturn(null); byte[] paymentBody = jsonReader.getBytesFromFile(BULK_PAYMENT_PSD2_JSON_PATH); BulkPayment actual = rawToXs2aPaymentMapper.mapToBulkPayment(paymentBody); assertNull(actual); }