### Question:
CmsAspspPisExportServiceInternal implements CmsAspspPisExportService { @Override public Collection<CmsPayment> exportPaymentsByAccountId(@NotNull String aspspAccountId, @Nullable LocalDate createDateFrom, @Nullable LocalDate createDateTo, @NotNull String instanceId) { if (StringUtils.isBlank(aspspAccountId) || StringUtils.isBlank(instanceId)) { log.info("InstanceId: [{}], aspspAccountId: [{}]. Export payments by accountId failed, aspspAccountId or instanceId is empty or null.", instanceId, aspspAccountId); return Collections.emptyList(); } List<PisCommonPaymentData> commonPayments = pisCommonPaymentDataRepository.findAll(pisCommonPaymentDataSpecification.byAspspAccountIdAndCreationPeriodAndInstanceId(aspspAccountId, createDateFrom, createDateTo, instanceId)); return cmsPsuPisMapper.mapPaymentDataToCmsPayments(commonPayments); }  @Override Collection<CmsPayment> exportPaymentsByTpp(String tppAuthorisationNumber, @Nullable LocalDate createDateFrom, @Nullable LocalDate createDateTo, @Nullable PsuIdData psuIdData, @NotNull String instanceId); @Override Collection<CmsPayment> exportPaymentsByPsu(PsuIdData psuIdData, @Nullable LocalDate createDateFrom, @Nullable LocalDate createDateTo, @NotNull String instanceId); @Override Collection<CmsPayment> exportPaymentsByAccountId(@NotNull String aspspAccountId, @Nullable LocalDate createDateFrom, @Nullable LocalDate createDateTo, @NotNull String instanceId);  }### Answer:
@Test void exportPaymentsByAccountId_success() { when(pisCommonPaymentDataSpecification.byAspspAccountIdAndCreationPeriodAndInstanceId(ASPSP_ACCOUNT_ID, CREATION_DATE_FROM, CREATION_DATE_TO, DEFAULT_SERVICE_INSTANCE_ID)).thenReturn((root, criteriaQuery, criteriaBuilder) -> null); when(pisCommonPaymentDataRepository.findAll(any(Specification.class))) .thenReturn(Collections.singletonList(buildPisCommonPaymentData())); CmsPayment expectedPayment = buildCmsPayment(); when(cmsPsuPisMapper.mapPaymentDataToCmsPayments(Collections.singletonList(buildPisCommonPaymentData()))) .thenReturn(Collections.singletonList(buildCmsPayment())); Collection<CmsPayment> payments = cmsAspspPisExportServiceInternal.exportPaymentsByAccountId(ASPSP_ACCOUNT_ID, CREATION_DATE_FROM, CREATION_DATE_TO, DEFAULT_SERVICE_INSTANCE_ID); assertFalse(payments.isEmpty()); assertTrue(payments.contains(expectedPayment)); verify(pisCommonPaymentDataSpecification, times(1)) .byAspspAccountIdAndCreationPeriodAndInstanceId(ASPSP_ACCOUNT_ID, CREATION_DATE_FROM, CREATION_DATE_TO, DEFAULT_SERVICE_INSTANCE_ID); }
@Test void exportPaymentsByAccountId_failure_wrongAspspAccountId() { Collection<CmsPayment> payments = cmsAspspPisExportServiceInternal.exportPaymentsByAccountId(WRONG_ASPSP_ACCOUNT_ID, CREATION_DATE_FROM, CREATION_DATE_TO, DEFAULT_SERVICE_INSTANCE_ID); assertTrue(payments.isEmpty()); verify(pisCommonPaymentDataSpecification, times(1)) .byAspspAccountIdAndCreationPeriodAndInstanceId(WRONG_ASPSP_ACCOUNT_ID, CREATION_DATE_FROM, CREATION_DATE_TO, DEFAULT_SERVICE_INSTANCE_ID); }
@Test void exportPaymentsByAccountId_failure_blankAspspAccountId() { Collection<CmsPayment> payments = cmsAspspPisExportServiceInternal.exportPaymentsByAccountId(" ", CREATION_DATE_FROM, CREATION_DATE_TO, DEFAULT_SERVICE_INSTANCE_ID); assertTrue(payments.isEmpty()); verify(pisCommonPaymentDataSpecification, never()) .byPsuIdDataAndCreationPeriodAndInstanceId(any(), any(), any(), any()); }