### Question:
TransactionAspectService extends BaseAspectService<AccountController> { public ResponseObject<Xs2aTransactionsReport> getTransactionsReportByPeriod(ResponseObject<Xs2aTransactionsReport> result, Xs2aTransactionsReportByPeriodRequest request) { if (!result.hasError()) { Xs2aTransactionsReport transactionsReport = result.getBody(); transactionsReport.setLinks(new TransactionsReportDownloadLinks(getHttpUrl(), request.getAccountId(), request.isWithBalance(), transactionsReport.getDownloadId())); Xs2aAccountReport accountReport = transactionsReport.getAccountReport(); if (transactionsReport.getAccountReport() != null) { accountReport.setLinks(new TransactionsReportAccountLinks(getHttpUrl(), request.getAccountId(), request.isWithBalance())); } } return result; } @Autowired  TransactionAspectService(AspspProfileServiceWrapper aspspProfileServiceWrapper); ResponseObject<Xs2aTransactionsReport> getTransactionsReportByPeriod(ResponseObject<Xs2aTransactionsReport> result,
                                                                                Xs2aTransactionsReportByPeriodRequest request);  }### Answer:
@Test void getTransactionsReportByPeriod_successReport() { AspspSettings aspspSettings = jsonReader.getObjectFromFile("json/aspect/aspsp-settings.json", AspspSettings.class); when(aspspProfileServiceWrapper.isForceXs2aBaseLinksUrl()).thenReturn(aspspSettings.getCommon().isForceXs2aBaseLinksUrl()); when(aspspProfileServiceWrapper.getXs2aBaseLinksUrl()).thenReturn(aspspSettings.getCommon().getXs2aBaseLinksUrl()); xs2aTransactionsReportByPeriodRequest = jsonReader.getObjectFromFile("json/Xs2aTransactionsReportByPeriodRequest.json", Xs2aTransactionsReportByPeriodRequest.class); when(transactionsReport.getAccountReport()).thenReturn(new Xs2aAccountReport(Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), null)); responseObject = ResponseObject.<Xs2aTransactionsReport>builder() .body(transactionsReport) .build(); ResponseObject actualResponse = service.getTransactionsReportByPeriod(responseObject, xs2aTransactionsReportByPeriodRequest); assertFalse(actualResponse.hasError()); }
@Test void getTransactionsReportByPeriod_withError_shouldAddTextErrorMessage() { xs2aTransactionsReportByPeriodRequest = jsonReader.getObjectFromFile("json/Xs2aTransactionsReportByPeriodRequest.json", Xs2aTransactionsReportByPeriodRequest.class); responseObject = ResponseObject.<Xs2aCreatePisCancellationAuthorisationResponse>builder() .fail(AIS_400, of(CONSENT_UNKNOWN_400)) .build(); ResponseObject actualResponse = service.getTransactionsReportByPeriod(responseObject, xs2aTransactionsReportByPeriodRequest); assertTrue(actualResponse.hasError()); }