Search in sources :

Example 16 with RangePeriodSelector

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;
}
Also used : Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector)

Example 17 with RangePeriodSelector

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);
}
Also used : Project(com.artezio.arttime.datamodel.Project) HourType(com.artezio.arttime.datamodel.HourType) Employee(com.artezio.arttime.datamodel.Employee) Hours(com.artezio.arttime.datamodel.Hours) Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector) HoursRepository(com.artezio.arttime.repositories.HoursRepository) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 18 with RangePeriodSelector

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;
}
Also used : Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector)

Example 19 with RangePeriodSelector

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;
}
Also used : Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector)

Aggregations

RangePeriodSelector (com.artezio.arttime.web.criteria.RangePeriodSelector)19 Filter (com.artezio.arttime.filter.Filter)16 Test (org.junit.Test)14 Hours (com.artezio.arttime.datamodel.Hours)5 Project (com.artezio.arttime.datamodel.Project)5 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)5 Date (java.util.Date)5 HourType (com.artezio.arttime.datamodel.HourType)4 Employee (com.artezio.arttime.datamodel.Employee)2 Period (com.artezio.arttime.datamodel.Period)2 Date (java.sql.Date)2 HoursRepository (com.artezio.arttime.repositories.HoursRepository)1 Before (org.junit.Before)1