use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class FilterBean method setCurrentFilter.
public void setCurrentFilter(Filter filter) {
filter = filterRepository.fetchDetails(filter);
if (currentFilter != null) {
RangePeriodSelector currentPeriodSelector = currentFilter.getRangePeriodSelector();
filter.setRangePeriodSelector(currentPeriodSelector);
}
currentFilter = filter;
setSelectedProjects(filter.getProjects());
newFilterName = currentFilter.getName();
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class FilterServiceTest method testCreatePersonalTimesheetFilter.
@Test
public void testCreatePersonalTimesheetFilter() throws NoSuchFieldException {
setField(filterService, "hourTypeRepository", hourTypeRepository);
setField(filterService, "projectRepository", projectRepository);
setField(filterService, "departmentRepository", departmentRepository);
Filter currentFilter = new Filter();
RangePeriodSelector currentPeriodSelector = new RangePeriodSelector(new Period(new Date(1), new Date(2)));
currentFilter.setRangePeriodSelector(currentPeriodSelector);
Employee employee = new Employee("user");
expect(departmentRepository.getDepartments()).andReturn(Collections.emptyList());
expect(hourTypeRepository.getAll()).andReturn(Collections.emptyList());
expect(projectRepository.getActiveAndReportedProjects(employee, currentFilter.getPeriod())).andReturn(Collections.emptyList());
replay(departmentRepository, hourTypeRepository, projectRepository);
Filter actual = filterService.createPersonalTimesheetFilter(currentFilter, employee);
verify(departmentRepository, hourTypeRepository, projectRepository);
assertEquals(currentFilter.getPeriod(), actual.getPeriod());
assertEquals(1, actual.getEmployees().size());
assertEquals(employee, actual.getEmployees().get(0));
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetHours_FilterHasNoProjectsAndHasHourTypes.
@Test
public void testGetHours_FilterHasNoProjectsAndHasHourTypes() {
HourType hourType = new HourType("1");
List<HourType> hourTypes = Collections.singletonList(hourType);
Project project = new Project();
project.setAccountableHours(hourTypes);
Hours hour = new Hours(project, new Date(), null, hourType);
entityManager.persist(hourType);
entityManager.persist(project);
entityManager.persist(hour);
RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(createPeriod(-1, 1));
Filter filter = new Filter();
filter.setRangePeriodSelector(rangePeriodSelector);
filter.setHourTypes(hourTypes);
filter.setProjects(Collections.emptyList());
List<Hours> actual = hoursRepository.getHours(filter);
List<Hours> expected = Collections.singletonList(hour);
assertEquals(expected, actual);
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class FilterTest method testSetCustomPeriod.
@Test
public void testSetCustomPeriod() throws ParseException {
RangePeriodSelector rangePeriodSelector = new RangePeriodSelector();
rangePeriodSelector.setMonthPeriod();
filter.setRangePeriodSelector(rangePeriodSelector);
Period period = new Period(sdf.parse("13-01-2015"), sdf.parse("15-01-2015"));
filter.setCustomPeriod(period);
assertEquals(Range.CUSTOM, rangePeriodSelector.getRange());
assertSame(period.getStart(), rangePeriodSelector.getPeriod().getStart());
assertSame(period.getFinish(), rangePeriodSelector.getPeriod().getFinish());
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class IntegrationFacadeTest method testGetHours_includeSubprojects.
@Test
public void testGetHours_includeSubprojects() {
List<Hours> expecteds = new ArrayList<>();
Project project = new Project();
project.setCode("TEST-PROJECT");
Project subproject = new Project(project);
subproject.setCode("TEST_SUBPROJECT");
Date from = new GregorianCalendar(2011, 1, 5).getTime();
Date to = new GregorianCalendar(2011, 1, 15).getTime();
Period period = new Period(from, to);
List<Project> projects = asList(project, subproject);
Filter filter = new Filter();
filter.setProjects(projects);
filter.setApproved(null);
RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(period);
filter.setRangePeriodSelector(rangePeriodSelector);
HoursSearchCriteria criteria = new HoursSearchCriteria(from, to, false, asList("TEST-PROJECT"));
criteria.setIncludeSubprojects(true);
Project anotherProject = new Project();
Project anotherSubproject = new Project();
anotherProject.setCode("ANOTHER-PROJECT");
anotherSubproject.setCode("ANOTHER-SUBPROJECT");
List<Project> allProjects = Arrays.asList(project, subproject, anotherProject, anotherSubproject);
expect(projectService.getAll()).andReturn(allProjects).anyTimes();
expect(hoursService.getHours(eq(filter))).andReturn(expecteds);
replay(projectService, hoursRepository, hoursService);
List<Hours> actuals = facade.getHours(criteria);
verify(projectService, hoursRepository);
assertSame(expecteds, actuals);
}
Aggregations