Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPORT-906: Add pagination support to ReportRequest read methods #249

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading