AggregateReportServiceImpl extends AbstractReportServiceImpl<AssignmentAggregateReportElement> implements AggregateReportService { @Override public ProjectManagerReport getProjectManagerDetailedReport(Project project) { ProjectManagerReport report = new ProjectManagerReport(); report.setProject(project); DateRange reportRange = getReportRangeForProject(project); report.setReportRange(reportRange); List<Project> projects = Arrays.asList(project); SortedSet<AssignmentAggregateReportElement> aggregates = new TreeSet<AssignmentAggregateReportElement>(reportAggregatedDAO.getCumulatedHoursPerAssignmentForProjects(projects, reportRange)); List<Integer> assignmentIds = new ArrayList<>(); for (AssignmentAggregateReportElement aggregate : aggregates) { assignmentIds.add(aggregate.getProjectAssignment().getAssignmentId()); } List<ProjectAssignment> allAssignments = projectAssignmentService.getProjectAssignments(project, reportRange); for (ProjectAssignment assignment : allAssignments) { if (!assignmentIds.contains(assignment.getAssignmentId())) { AssignmentAggregateReportElement emptyAggregate = new AssignmentAggregateReportElement(); emptyAggregate.setProjectAssignment(assignment); aggregates.add(emptyAggregate); } } report.setAggregates(aggregates); report.deriveTotals(); return report; } AggregateReportServiceImpl(); @Autowired  AggregateReportServiceImpl(ProjectAssignmentService projectAssignmentService, ReportCriteriaService reportCriteriaService, ProjectDao projectDao, TimesheetLockService lockService, ReportAggregatedDao reportAggregatedDAO); @Override List<AssignmentAggregateReportElement> getHoursPerAssignment(List<Integer> projectAssignmentIds); @Override List<AssignmentAggregateReportElement> getHoursPerAssignmentInRange(Integer userId, DateRange dateRange); @Override ReportData getAggregateReportData(ReportCriteria criteria); @Override ProjectManagerReport getProjectManagerDetailedReport(Project project);  }
@Test public void should_create_pm_detailed_report() { Project project = new Project(1); project.setProjectCode("PRJ"); DateRange dr = new DateRange(new Date(), new Date()); when(reportAggregatedDao.getMinMaxDateTimesheetEntry(project)).thenReturn(dr); List<AssignmentAggregateReportElement> elms = new ArrayList<>(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { elms.add(AssignmentAggregateReportElementMother.createProjectAssignmentAggregate(j, i, i)); } } when(reportAggregatedDao.getCumulatedHoursPerAssignmentForProjects(any(List.class), any(DateRange.class))) .thenReturn(elms); List<ProjectAssignment> assignments = new ArrayList<>(); assignments.add(ProjectAssignmentObjectMother.createProjectAssignment(2)); when(assignmentService.getProjectAssignments(project, dr)).thenReturn(assignments); ProjectManagerReport report = aggregateReportService.getProjectManagerDetailedReport(project); assertEquals(new Integer(1), report.getProject().getPK()); assertEquals(16, report.getAggregates().size()); }