TimesheetServiceImpl implements IOverviewTimesheet { public TimesheetOverview getTimesheetOverview(User user, Calendar requestedMonth) { TimesheetOverview overview = new TimesheetOverview(); DateRange monthRange = DateUtil.calendarToMonthRange(requestedMonth); overview.setProjectStatus(getProjectStatus(user.getUserId(), monthRange)); List<TimesheetEntry> timesheetEntries = timesheetDAO.getTimesheetEntriesInRange(user.getUserId(), monthRange); Map<Integer, List<TimesheetEntry>> calendarMap = entriesToCalendarMap(timesheetEntries); overview.setTimesheetEntries(calendarMap); return overview; } @Autowired  TimesheetServiceImpl(TimesheetDao timesheetDAO,
                                TimesheetCommentDao timesheetCommentDAO,
                                TimesheetLockService timesheetLockService,
                                AggregateReportService aggregateReportService,
                                ProjectAssignmentService projectAssignmentService,
                                EhourConfig configuration); TimesheetOverview getTimesheetOverview(User user, Calendar requestedMonth); List<LocalDate> getBookedDaysMonthOverview(Integer userId, Calendar requestedMonth); WeekOverview getWeekOverview(User user, Calendar requestedWeek);  }
@Test public void should_get_timesheet_overview() throws Exception { List<TimesheetEntry> daoResults = new ArrayList<>(); List<AssignmentAggregateReportElement> reportResults = new ArrayList<>(); Calendar cal = new GregorianCalendar(); TimesheetEntry entryA, entryB; TimesheetEntryId idA, idB; idA = new TimesheetEntryId(new Date(2006 - 1900, Calendar.OCTOBER, 2), null); entryA = new TimesheetEntry(); entryA.setEntryId(idA); entryA.setHours((float) 5); daoResults.add(entryA); idB = new TimesheetEntryId(new Date(2006 - 1900, Calendar.OCTOBER, 6), null); entryB = new TimesheetEntry(); entryB.setEntryId(idB); entryB.setHours((float) 3); daoResults.add(entryB); AssignmentAggregateReportElement agg = new AssignmentAggregateReportElement(); ProjectAssignment pa = ProjectAssignmentObjectMother.createProjectAssignment(0); agg.setProjectAssignment(pa); reportResults.add(agg); when(timesheetDAO.getTimesheetEntriesInRange(1, DateUtil.calendarToMonthRange(cal))).thenReturn(daoResults); when(aggregateReportService.getHoursPerAssignmentInRange(1, DateUtil.calendarToMonthRange(cal))).thenReturn(reportResults); timesheetService.getTimesheetOverview(new User(1), cal); verify(timesheetDAO).getTimesheetEntriesInRange(1, DateUtil.calendarToMonthRange(cal)); verify(aggregateReportService).getHoursPerAssignmentInRange(1, DateUtil.calendarToMonthRange(cal)); }