TimesheetServiceImpl implements IOverviewTimesheet { public List<LocalDate> getBookedDaysMonthOverview(Integer userId, Calendar requestedMonth) { DateRange monthRange = DateUtil.calendarToMonthRange(requestedMonth); List<BookedDay> bookedDays = timesheetDAO.getBookedHoursperDayInRange(userId, monthRange); List<LocalDate> fullyBookedDays = new ArrayList<>(); for (BookedDay bookedDay : bookedDays) { if (bookedDay.getHours() != null && bookedDay.getHours().floatValue() >= configuration.getCompleteDayHours()) { fullyBookedDays.add(new LocalDate(bookedDay.getDate())); } } Collections.sort(fullyBookedDays); return fullyBookedDays; } @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_booked_days_for_february() throws Exception { Calendar cal = new GregorianCalendar(2006, Calendar.NOVEMBER, 5); BookedDay dayA = new BookedDay(); dayA.setDate(new Date(2006 - 1900, Calendar.NOVEMBER, 1)); dayA.setHours((float) 6); BookedDay dayB = new BookedDay(); dayB.setDate(new Date(2006 - 1900, Calendar.NOVEMBER, 2)); dayB.setHours((float) 8); when(timesheetDAO.getBookedHoursperDayInRange(1, DateUtil.calendarToMonthRange(cal))).thenReturn(Arrays.asList(dayA, dayB)); when(config.getCompleteDayHours()).thenReturn(8f); List<LocalDate> results = timesheetService.getBookedDaysMonthOverview(1, cal); verify(timesheetDAO).getBookedHoursperDayInRange(1, DateUtil.calendarToMonthRange(cal)); verify(config, times(2)).getCompleteDayHours(); assertEquals(1, results.size()); assertEquals(2, results.get(0).getDayOfMonth()); }