use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class IntegrationFacade method buildHoursFilter.
private Filter buildHoursFilter(HoursSearchCriteria criteria, List<Project> projects) {
Filter filter = new Filter();
Period period = new Period(criteria.getDateFrom(), criteria.getDateTo());
filter.setRangePeriodSelector(new RangePeriodSelector(period));
filter.setProjects(projects);
if (criteria.isApprovedOnly()) {
filter.setApproved(true);
}
return filter;
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class HoursServiceTest method testGetHours.
@Test
public void testGetHours() {
HourType hourType = new HourType("1");
List<HourType> hourTypes = Collections.singletonList(hourType);
Project project = new Project();
project.setAccountableHours(hourTypes);
Employee employee = new Employee();
Hours hour = new Hours(project, new Date(), employee, hourType);
RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(createPeriod(-1, 1));
Filter filter = new Filter();
filter.setRangePeriodSelector(rangePeriodSelector);
filter.setHourTypes(hourTypes);
filter.setProjects(Collections.singletonList(project));
HoursRepository.HoursQuery hoursQuery = Mockito.mock(HoursRepository.HoursQuery.class, Mockito.RETURNS_DEEP_STUBS);
EasyMock.expect(hoursRepository.query()).andReturn(hoursQuery);
Mockito.when(hoursQuery.approved(filter.isApproved()).projects(Mockito.anyList()).departments(Mockito.anyList()).types(Mockito.anyList()).period(filter.getPeriod()).employees(Mockito.anyList()).list()).thenReturn(asList(hour));
EasyMock.replay(hoursRepository);
List<Hours> actual = hoursService.getHours(filter);
List<Hours> expected = Collections.singletonList(hour);
EasyMock.verify(hoursRepository);
Mockito.verify(hoursQuery.approved(filter.isApproved()).projects(Mockito.anyList()).departments(filter.getDepartments()).types(filter.getHourTypes()).period(filter.getPeriod()).employees(filter.getEmployees())).list();
assertEquals(expected, actual);
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method createFilter.
private Filter createFilter() throws ParseException, NoSuchFieldException {
Date date1 = sdf.parse("1-01-2014");
Date date2 = sdf.parse("2-01-2014");
Period period = new Period(date1, date2);
HourType hourType1 = new HourType("regular time");
setField(hourType1, "id", 1L);
hourType1.setActualTime(true);
HourType hourType2 = new HourType("over time");
setField(hourType1, "id", 2L);
List<HourType> hourTypes = asList(hourType1, hourType2);
List<Employee> employees = asList(employee1, employee2);
Project project1 = buildProject(1L, asList(employee1), asList(hourType1, hourType2), ACTIVE, null);
Project project2 = buildProject(2L, asList(employee1, employee2), asList(hourType1), ACTIVE, null);
List<Project> projects = asList(project1, project2);
Filter filter = new Filter();
filter.setEmployees(employees);
filter.setProjects(projects);
filter.setHourTypes(hourTypes);
filter.setDepartments(asList(department1, department2, department3));
filter.setRangePeriodSelector(new RangePeriodSelector(period));
return filter;
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class PersonalEffortsSpreadSheetTest method createFilter.
private Filter createFilter() throws ParseException, NoSuchFieldException {
Date date1 = sdf.parse("1-01-2014");
Date date2 = sdf.parse("2-01-2014");
Period period = new Period(date1, date2);
HourType hourType1 = new HourType("regular time");
setField(hourType1, "id", 1L);
hourType1.setActualTime(true);
HourType hourType2 = new HourType("over time");
setField(hourType1, "id", 2L);
List<HourType> hourTypes = asList(hourType1, hourType2);
Employee employee1 = new Employee("iivanov", "ivan", "ivanov", "ivanov@mail.ru");
employee1.setDepartment("Minsk");
List<Employee> employees = asList(employee1);
Project project1 = createProject("project1", asList(hourType1, hourType2), asList(employee1));
setField(project1, "id", 1L);
Project project2 = createProject("project2", asList(hourType1), asList(employee1));
setField(project2, "id", 2L);
List<Project> projects = asList(project1, project2);
Filter filter = new Filter();
filter.setEmployees(employees);
filter.setProjects(projects);
filter.setHourTypes(hourTypes);
filter.setDepartments(asList("Minsk"));
filter.setRangePeriodSelector(new RangePeriodSelector(period));
return filter;
}
Aggregations