TimesheetServiceImpl implements IOverviewTimesheet { public WeekOverview getWeekOverview(User user, Calendar requestedWeek) { Calendar reqWeek = (Calendar) requestedWeek.clone(); reqWeek.setFirstDayOfWeek(configuration.getFirstDayOfWeek()); DateRange range = DateUtil.getDateRangeForWeek(reqWeek); List<TimesheetEntry> timesheetEntries = timesheetDAO.getTimesheetEntriesInRange(user.getUserId(), range); TimesheetComment comment = timesheetCommentDAO.findById(new TimesheetCommentId(user.getUserId(), range.getDateStart())); List<ProjectAssignment> assignments = projectAssignmentService.getProjectAssignmentsForUser(user.getUserId(), range); Seq<Interval> lockedDatesAsIntervals = timesheetLockService.findLockedDatesInRange(range.getDateStart(), range.getDateEnd(), user); List<Date> lockedDates = TimesheetLockService$.MODULE$.intervalToJavaDates(lockedDatesAsIntervals); return new WeekOverview(timesheetEntries, comment, assignments, range, user, lockedDates); } @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_entries() { Date da = new Date(2006 - 1900, Calendar.DECEMBER, 31); Date db = new Date(2007 - 1900, Calendar.JANUARY, 6); DateRange range = new DateRange(da, db); DateRange rangeB = new DateRange(new Date(2006 - 1900, Calendar.DECEMBER, 31), new Date(2007 - 1900, Calendar.JANUARY, 6)); when(timesheetDAO.getTimesheetEntriesInRange(1, range)).thenReturn(new ArrayList<TimesheetEntry>()); when(timesheetCommentDAO.findById(new TimesheetCommentId(1, range.getDateStart()))).thenReturn(new TimesheetComment()); when(projectAssignmentService.getProjectAssignmentsForUser(1, rangeB)).thenReturn(new ArrayList<ProjectAssignment>()); when(config.getFirstDayOfWeek()).thenReturn(1); when(timesheetLockService.findLockedDatesInRange(any(Date.class), any(Date.class), any(User.class))).thenReturn(new Vector<Interval>(0, 0, 1)); timesheetService.getWeekOverview(new User(1), new GregorianCalendar(2007, Calendar.JANUARY, 1)); verify(timesheetDAO).getTimesheetEntriesInRange(1, range); verify(timesheetCommentDAO).findById(new TimesheetCommentId(1, range.getDateStart())); verify(projectAssignmentService).getProjectAssignmentsForUser(1, rangeB); verify(config).getFirstDayOfWeek(); verify(timesheetLockService).findLockedDatesInRange(any(Date.class), any(Date.class), any(User.class)); }