use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class EffortsBeanTest method testInitByGetRequest_ifPeriodHasNullDate.
@Test
public void testInitByGetRequest_ifPeriodHasNullDate() throws Exception {
Filter filter = new Filter();
List<Employee> employees = Arrays.asList(new Employee());
FilterBean filterBean = createMock(FilterBean.class);
Period period = new Period(null, sdf.parse("15-01-2015"));
setField(effortsBean, "filterBean", filterBean);
setField(effortsBean, "period", period);
setField(effortsBean, "employees", employees);
effortsBean.initByGetRequest();
assertNotEquals(period, filter.getPeriod());
assertEquals(0, filter.getEmployees().size());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class EffortsBeanTest method testGetDay_ifCalendarDaysNotCached.
@Test
public void testGetDay_ifCalendarDaysNotCached() throws Exception {
Date date1 = sdf.parse("1-05-2015");
Date date2 = sdf.parse("2-05-2015");
WorkdaysCalendar calendar = new WorkdaysCalendar();
Day day1 = new Day(date1, calendar, false);
Day day2 = new Day(date2, calendar, false);
Filter filter = new Filter();
FilterBean filterBean = createMock(FilterBean.class);
WorkdaysCalendarService workdaysCalendarService = createMock(WorkdaysCalendarService.class);
setField(effortsBean, "filterBean", filterBean);
setField(effortsBean, "workdaysCalendarService", workdaysCalendarService);
expect(filterBean.getCurrentFilter()).andReturn(filter);
expect(workdaysCalendarService.getDays(calendar, filter.getPeriod())).andReturn(Arrays.asList(day1, day2));
replay(filterBean, workdaysCalendarService);
Day actual = effortsBean.getDay(calendar, date1);
verify(filterBean, workdaysCalendarService);
assertSame(day1, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class EffortsBeanTest method testInitByGetRequest_ifEmployeesIsNull.
@Test
public void testInitByGetRequest_ifEmployeesIsNull() throws Exception {
Filter filter = new Filter();
List<Employee> employees = null;
FilterBean filterBean = createMock(FilterBean.class);
Period period = new Period(sdf.parse("1-01-2015"), sdf.parse("15-01-2015"));
setField(effortsBean, "filterBean", filterBean);
setField(effortsBean, "period", period);
setField(effortsBean, "employees", employees);
expect(filterBean.getCurrentFilter()).andReturn(filter);
replay(filterBean);
effortsBean.initByGetRequest();
verify(filterBean);
assertEquals(period, filter.getPeriod());
assertEquals(Collections.emptyList(), filter.getEmployees());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testGetSelectedProjects_noneSelected.
@Test
public void testGetSelectedProjects_noneSelected() throws NoSuchFieldException {
Filter filter = new Filter();
filter.setProjects(Collections.emptyList());
setField(filterBean, "currentFilter", filter);
List<Project> actual = filterBean.getSelectedProjects();
assertTrue(actual.isEmpty());
}
use of com.artezio.arttime.filter.Filter 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);
}
Aggregations