Search in sources :

Example 11 with RangePeriodSelector

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

Example 12 with RangePeriodSelector

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

Example 13 with RangePeriodSelector

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

Example 14 with RangePeriodSelector

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

Example 15 with RangePeriodSelector

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

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