use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetHours_FilterHasProjectsAndHourTypes.
@Test
public void testGetHours_FilterHasProjectsAndHourTypes() {
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.singletonList(project));
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 IntegrationFacadeTest method testGetHours_includeSubprojects_ExpectDistinct.
@Test
public void testGetHours_includeSubprojects_ExpectDistinct() {
List<Hours> expecteds = new ArrayList<>();
HourType type = new HourType("Type");
Project project = new Project();
project.setCode("TEST-PROJECT");
Project subproject = new Project(project);
subproject.setCode("TEST_SUBPROJECT");
Project subproject2 = new Project(project);
subproject2.setCode("TEST_SUBPROJECT_2");
Employee employee = new Employee("employee");
Date from = new GregorianCalendar(2011, 1, 5).getTime();
Date to = new GregorianCalendar(2011, 1, 15).getTime();
Period period = new Period(from, to);
List<Project> allProjects = asList(project, subproject, subproject2);
Filter filter = new Filter();
filter.setProjects(allProjects);
filter.setApproved(null);
Hours h1 = new Hours(project, from, employee, type);
Hours h2 = new Hours(subproject, from, employee, type);
Hours h3 = new Hours(subproject2, from, employee, type);
expecteds.add(h1);
expecteds.add(h2);
expecteds.add(h3);
RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(period);
filter.setRangePeriodSelector(rangePeriodSelector);
HoursSearchCriteria criteria = new HoursSearchCriteria(from, to, false, asList("TEST-PROJECT", "TEST_SUBPROJECT"));
criteria.setIncludeSubprojects(true);
Project anotherProject = new Project();
Project anotherSubproject = new Project();
anotherProject.setCode("ANOTHER-PROJECT");
anotherSubproject.setCode("ANOTHER-SUBPROJECT");
List<Project> allStoredProjects = Arrays.asList(project, subproject, subproject2, anotherProject, anotherSubproject);
expect(projectService.getAll()).andReturn(allStoredProjects).anyTimes();
EasyMock.expect(hoursService.getHours(filter)).andReturn(expecteds);
EasyMock.replay(projectService, hoursService);
List<Hours> actuals = facade.getHours(criteria);
EasyMock.verify(projectService, hoursService);
assertSame(expecteds, actuals);
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class ReportsBeanTest method testGetSelectedStartDate.
@Test
public void testGetSelectedStartDate() throws Exception {
Filter filter = new Filter();
Date expected = new Date(1000);
filter.setRangePeriodSelector(new RangePeriodSelector(new Period(expected, new Date(2000))));
expect(filterBean.getCurrentFilter()).andReturn(filter);
replay(filterBean);
Date actual = reportsBean.getSelectedStartDate();
verify(filterBean);
assertEquals(expected, actual);
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class ReportsBeanTest method testGetSelectedEndDate.
@Test
public void testGetSelectedEndDate() throws Exception {
Filter filter = new Filter();
Date expected = new Date(2000);
filter.setRangePeriodSelector(new RangePeriodSelector(new Period(new Date(1000), expected)));
expect(filterBean.getCurrentFilter()).andReturn(filter);
replay(filterBean);
Date actual = reportsBean.getSelectedEndDate();
verify(filterBean);
assertEquals(expected, actual);
}
use of com.artezio.arttime.web.criteria.RangePeriodSelector in project ART-TIME by Artezio.
the class EmployeeEffortsSpreadSheetTest method setUp.
@Before
public void setUp() throws ParseException, NoSuchFieldException {
createEmployees();
Date date1 = sdf.parse("1-01-2014");
Date date2 = sdf.parse("2-01-2014");
Period period = new Period(date1, date2);
filter = new Filter();
filter.setRangePeriodSelector(new RangePeriodSelector(period));
expect(employeeService.getEffortsEmployees()).andReturn(employees);
replay(employeeService);
spreadSheet = new EmployeeEffortsSpreadSheet(hoursService, projectService, employeeService, filter);
setField(spreadSheet, "rows", new LinkedList<SpreadSheetRow<?>>());
}
Aggregations