### Question:
PisCommonPaymentServiceInternal implements PisCommonPaymentService { @Override public CmsResponse<List<PsuIdData>> getPsuDataListByPaymentId(String paymentId) { Optional<List<PsuIdData>> psuDataListOptional = readPisCommonPaymentDataByPaymentId(paymentId) .map(pc -> psuDataMapper.mapToPsuIdDataList(pc.getPsuDataList())); if (psuDataListOptional.isPresent()) { return CmsResponse.<List<PsuIdData>>builder() .payload(psuDataListOptional.get()) .build(); } log.info("PaymentId ID: [{}]. Get PSU data list by payment ID failed, because payment is not found", paymentId); return CmsResponse.<List<PsuIdData>>builder() .error(LOGICAL_ERROR) .build(); }  @Override @Transactional CmsResponse<CreatePisCommonPaymentResponse> createCommonPayment(PisPaymentInfo request); @Override @Transactional CmsResponse<TransactionStatus> getPisCommonPaymentStatusById(String paymentId); @Override @Transactional CmsResponse<PisCommonPaymentResponse> getCommonPaymentById(String paymentId); @Override @Transactional CmsResponse<Boolean> updateCommonPaymentStatusById(String paymentId, TransactionStatus status); @Override @Transactional CmsResponse<Boolean> updateMultilevelSca(String paymentId, boolean multilevelScaRequired); @Override CmsResponse<List<PsuIdData>> getPsuDataListByPaymentId(String paymentId);  }### Answer:
@Test void getPsuDataListByPaymentId_success() { PisPaymentData pisPaymentData = new PisPaymentData(); pisPaymentData.setPaymentData(pisCommonPaymentData); when(pisPaymentDataRepository.findByPaymentId(PAYMENT_ID)) .thenReturn(Optional.of(Collections.singletonList(pisPaymentData))); when(psuDataMapper.mapToPsuIdDataList(pisCommonPaymentData.getPsuDataList())).thenReturn(Collections.emptyList()); CmsResponse<List<PsuIdData>> actual = pisCommonPaymentService.getPsuDataListByPaymentId(PAYMENT_ID); assertTrue(actual.isSuccessful()); assertTrue(actual.getPayload().isEmpty()); }
@Test void getPsuDataListByPaymentId_logicalError() { PisPaymentData pisPaymentData = new PisPaymentData(); pisPaymentData.setPaymentData(pisCommonPaymentData); when(pisPaymentDataRepository.findByPaymentId(PAYMENT_ID)) .thenReturn(Optional.of(Collections.singletonList(pisPaymentData))); when(psuDataMapper.mapToPsuIdDataList(pisCommonPaymentData.getPsuDataList())).thenReturn(null); CmsResponse<List<PsuIdData>> actual = pisCommonPaymentService.getPsuDataListByPaymentId(PAYMENT_ID); assertTrue(actual.hasError()); assertEquals(CmsError.LOGICAL_ERROR, actual.getError()); }