DetailedReportServiceImpl extends AbstractReportServiceImpl<FlatReportElement> implements DetailedReportService { public ReportData getDetailedReportData(ReportCriteria reportCriteria) { return getReportData(reportCriteria); } DetailedReportServiceImpl(); @Autowired  DetailedReportServiceImpl(ReportCriteriaService reportCriteriaService, ProjectDao projectDao, TimesheetLockService lockService, DetailedReportDao detailedReportDao, ReportAggregatedDao reportAggregatedDAO); ReportData getDetailedReportData(ReportCriteria reportCriteria);  }
@Test public void should_get_all() { provideNoLocks(); provideNoAssignmentsWithoutBookings(); provideNoData(); noFilteringOnUserOrProject(); detailedReportService.getDetailedReportData(reportCriteria); }
@Test public void should_filter_on_user() { provideNoLocks(); provideNoAssignmentsWithoutBookings(); filterOnSingleUser(); List<Integer> userIds = Lists.newArrayList(1); when(detailedReportDao.getHoursPerDayForUsers(eq(userIds), any(DateRange.class))).thenReturn(Lists.newArrayList(createFlatReportElement())); detailedReportService.getDetailedReportData(reportCriteria); verify(detailedReportDao).getHoursPerDayForUsers(eq(userIds), any(DateRange.class)); }
@Test public void should_filter_on_project() { provideNoLocks(); provideNoAssignmentsWithoutBookings(); filterOnSingleProject(); List<Integer> projectIds = Lists.newArrayList(2); when(detailedReportDao.getHoursPerDayForProjects(eq(projectIds), any(DateRange.class))).thenReturn(new ArrayList<FlatReportElement>()); detailedReportService.getDetailedReportData(reportCriteria); verify(detailedReportDao).getHoursPerDayForProjects(eq(projectIds), any(DateRange.class)); }
@Test public void should_filter_on_project_and_user() { provideNoLocks(); provideNoAssignmentsWithoutBookings(); filterOnSingleUserAndSingleProject(); List<Integer> userIds = Lists.newArrayList(1); List<Integer> projectIds = Lists.newArrayList(2); when(detailedReportDao.getHoursPerDayForProjectsAndUsers(eq(projectIds), eq(userIds), any(DateRange.class))) .thenReturn(new ArrayList<FlatReportElement>()); detailedReportService.getDetailedReportData(reportCriteria); verify(detailedReportDao).getHoursPerDayForProjectsAndUsers(eq(projectIds), eq(userIds), any(DateRange.class)); }
@Test public void should_filter_on_user_department() { provideNoLocks(); provideNoAssignmentsWithoutBookings(); List<UserDepartment> departments = Arrays.asList(new UserDepartment(1)); userSelectedCriteria.setDepartments(departments); filterOnSingleUserAndSingleProject(); List<Integer> userIds = Lists.newArrayList(1); List<Integer> projectIds = Lists.newArrayList(2); when(detailedReportDao.getHoursPerDayForProjectsAndUsers(eq(projectIds), eq(userIds), any(DateRange.class))) .thenReturn(Lists.<FlatReportElement>newArrayList()); detailedReportService.getDetailedReportData(reportCriteria); verify(detailedReportDao).getHoursPerDayForProjectsAndUsers(eq(projectIds), eq(userIds), any(DateRange.class)); }
@Test public void should_only_include_billable_without_customer_or_project_selection() { provideNoLocks(); provideNoAssignmentsWithoutBookings(); userSelectedCriteria.setOnlyBillableProjects(true); Project billableProject = ProjectObjectMother.createProject(1); billableProject.setBillable(true); Project notBillableProject = ProjectObjectMother.createProject(2); notBillableProject.setBillable(false); when(projectDao.findAllActive()).thenReturn(Arrays.asList(billableProject, notBillableProject)); List<User> users = Lists.newArrayList(); List<Project> projects = Lists.newArrayList(billableProject); UsersAndProjects usersAndProjects = new UsersAndProjects(users, projects); when(reportCriteriaService.criteriaToUsersAndProjects(userSelectedCriteria)).thenReturn(usersAndProjects); ArgumentCaptor<List> projectIdListCapture = ArgumentCaptor.forClass(List.class); when(detailedReportDao.getHoursPerDayForProjects(projectIdListCapture.capture(), any(DateRange.class))) .thenReturn(new ArrayList<FlatReportElement>()); detailedReportService.getDetailedReportData(reportCriteria); assertEquals(1, projectIdListCapture.getValue().size()); assertEquals(billableProject.getPK(), projectIdListCapture.getValue().get(0)); }