Skip to content

Commit

Permalink
REPORT-906: Add pagination support to ReportRequest read methods (#251)
Browse files Browse the repository at this point in the history
Also related to O3-1494
---------
Co-authored-by: druchniewicz <druchniewicz@soldevelo.com>
  • Loading branch information
pwargulak authored Jan 2, 2025
1 parent bd25e82 commit d37011a
Show file tree
Hide file tree
Showing 14 changed files with 386 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.UUID;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

public class ReportServiceTest extends BaseModuleContextSensitiveTest {

Expand Down Expand Up @@ -521,4 +524,108 @@ public void purgeReportDesignsForReportDefinition_shouldDeleteAllAssociatedRepor
assertNull(rs.getReportDesignByUuid("d7a82b63-1066-4c1d-9b43-b405851fc467"));
assertNull(rs.getReportDesignByUuid("e7a82b63-1066-4c1d-9b43-b405851fc467"));
}
}

@Test
public void getReportRequests_shouldReturnCorrectReportRequests() {
final ReportService rs = Context.getService(ReportService.class);
final List<ReportRequest> reportRequests = rs.getReportRequests(null, null, null, 0,2);

assertEquals(2, reportRequests.size());

final List<String> resultUuids = mapToReportRequestUuids(reportRequests);
assertTrue(resultUuids.contains("fce15a1b-4618-4f65-bfe9-8bb60a85c110"));
assertTrue(resultUuids.contains("b0a82b63-1066-4c1d-9b43-b405851fc467"));
}

@Test
public void getReportRequestsCount_shouldReturnTotalCount() {
final ReportService rs = Context.getService(ReportService.class);
final long totalCount = rs.getReportRequestsCount(null, null, null);

assertEquals(4, totalCount);
}

@Test
public void getReportRequests_shouldReturnCorrectReportRequestsForGivenReportDefinition() {
final ReportService rs = Context.getService(ReportService.class);
final ReportDefinition testReportDefinition =
rs.getReportDesignByUuid("d7a82b63-1066-4c1d-9b43-b405851fc467").getReportDefinition();
final List<ReportRequest> reportRequests = rs.getReportRequests(testReportDefinition, null, null, 0,2);

assertEquals(2, reportRequests.size());

final List<String> resultUuids = mapToReportRequestUuids(reportRequests);
assertTrue(resultUuids.contains("h8a82b63-1066-4c1d-9b43-b405851fc467"));
assertTrue(resultUuids.contains("b0a82b63-1066-4c1d-9b43-b405851fc467"));
}

@Test
public void getReportRequestsCount_shouldReturnCorrectTotalCountForReportDefinitionFilter() {
final ReportService rs = Context.getService(ReportService.class);
final ReportDefinition testReportDefinition =
rs.getReportDesignByUuid("d7a82b63-1066-4c1d-9b43-b405851fc467").getReportDefinition();
final long totalCount = rs.getReportRequestsCount(testReportDefinition, null, null);

assertEquals(2, totalCount);
}

@Test
public void getReportRequests_shouldReturnCorrectReportRequestsForRequestedWithinDates() {
final ReportService rs = Context.getService(ReportService.class);
final Date from = newDate(2013, Calendar.JANUARY, 21, 14, 8, 48);
final Date to = newDate(2013, Calendar.JANUARY, 21, 14, 8, 49);
final List<ReportRequest> reportRequests = rs.getReportRequests(null, from, to, 0,2);

assertEquals(2, reportRequests.size());

final List<String> resultUuids = mapToReportRequestUuids(reportRequests);
assertTrue(resultUuids.contains("b0a82b63-1066-4c1d-9b43-b405851fc467"));
assertTrue(resultUuids.contains("d9a82b63-1066-4c1d-9b43-b405851fc467"));
}

@Test
public void getReportRequestsCount_shouldReturnCorrectTotalCountForRequestedWithinDatesFilter() {
final ReportService rs = Context.getService(ReportService.class);
final Date from = newDate(2013, Calendar.JANUARY, 21, 14, 8, 48);
final Date to = newDate(2013, Calendar.JANUARY, 21, 14, 8, 49);
final long totalCount = rs.getReportRequestsCount(null, from, to);

assertEquals(2, totalCount);
}

@Test
public void getReportRequests_shouldReturnAPartialPageOfReportRequests() {
final ReportService rs = Context.getService(ReportService.class);
final List<ReportRequest> reportRequests = rs.getReportRequests(null, null, null, 0, 2, ReportRequest.Status.FAILED);

assertEquals(1, reportRequests.size());

final List<String> resultUuids = mapToReportRequestUuids(reportRequests);
assertTrue(resultUuids.contains("fce15a1b-4618-4f65-bfe9-8bb60a85c110"));
}

@Test
public void getReportRequestsCount_shouldReturnCorrectTotalCountForStatusFilter() {
final ReportService rs = Context.getService(ReportService.class);
final long totalCount = rs.getReportRequestsCount(null, null, null, ReportRequest.Status.FAILED);

assertEquals(1, totalCount);
}

private List<String> mapToReportRequestUuids(List<ReportRequest> reportRequests) {
List<String> reportRequestUuids = new ArrayList<String>();

for (ReportRequest reportRequest : reportRequests) {
reportRequestUuids.add(reportRequest.getUuid());
}

return reportRequestUuids;
}

private Date newDate(int year, int month, int day, int hour, int minute, int second) {
final Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(year, month, day, hour, minute, second);
return cal.getTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,21 @@
properties="#Mon Jan 21 14:08:47 CET 2013" creator="1"
date_created="2013-01-21 14:08:47" retired="0" />

<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />

</dataset>
<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:48" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:49" />
<reporting_report_request id="4" uuid="fce15a1b-4618-4f65-bfe9-8bb60a85c110"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873925"
process_automatically="1" priority="LOW" status="FAILED" requested_by="1"
request_datetime="2013-01-21 14:08:50" />

</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,21 @@
properties="#Mon Jan 21 14:08:47 CET 2013" creator="1"
date_created="2013-01-21 14:08:47" retired="0" />

<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:48" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:49" />
<reporting_report_request id="4" uuid="fce15a1b-4618-4f65-bfe9-8bb60a85c110"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873925"
process_automatically="1" priority="LOW" status="FAILED" requested_by="1"
request_datetime="2013-01-21 14:08:50" />

</dataset>
</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,21 @@
properties="#Mon Jan 21 14:08:47 CET 2013" creator="1"
date_created="2013-01-21 14:08:47" retired="0" />

<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:48" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:49" />
<reporting_report_request id="4" uuid="fce15a1b-4618-4f65-bfe9-8bb60a85c110"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873925"
process_automatically="1" priority="LOW" status="FAILED" requested_by="1"
request_datetime="2013-01-21 14:08:50" />

</dataset>
</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,21 @@
properties="#Mon Jan 21 14:08:47 CET 2013" creator="1"
date_created="2013-01-21 14:08:47" retired="0" />

<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:48" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:49" />
<reporting_report_request id="4" uuid="fce15a1b-4618-4f65-bfe9-8bb60a85c110"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873925"
process_automatically="1" priority="LOW" status="FAILED" requested_by="1"
request_datetime="2013-01-21 14:08:50" />

</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,21 @@
properties="#Mon Jan 21 14:08:47 CET 2013" creator="1"
date_created="2013-01-21 14:08:47" retired="0" />

<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />

</dataset>
<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:48" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:49" />
<reporting_report_request id="4" uuid="fce15a1b-4618-4f65-bfe9-8bb60a85c110"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873925"
process_automatically="1" priority="LOW" status="FAILED" requested_by="1"
request_datetime="2013-01-21 14:08:50" />

</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,22 @@
properties="#Mon Jan 21 14:08:47 CET 2013" creator="1"
date_created="2013-01-21 14:08:47" retired="0" />

<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467" report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1" request_datetime="2013-01-21 14:08:47" />


</dataset>
<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:47" />
<reporting_report_request id="2" uuid="d9a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:48" />
<reporting_report_request id="3" uuid="b0a82b63-1066-4c1d-9b43-b405851fc467"
report_definition_uuid="c11f5354-9567-4cc5-b3ef-163e28873926"
process_automatically="1" priority="LOW" status="REQUESTED" requested_by="1"
request_datetime="2013-01-21 14:08:49" />
<reporting_report_request id="4" uuid="fce15a1b-4618-4f65-bfe9-8bb60a85c110"
report_definition_uuid="d11f5354-9567-4cc5-b3ef-163e28873925"
process_automatically="1" priority="LOW" status="FAILED" requested_by="1"
request_datetime="2013-01-21 14:08:50" />


</dataset>
Loading

0 comments on commit d37011a

Please sign in to comment.