use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testPopulateDays.
@Test
public void testPopulateDays() throws NoSuchFieldException, ParseException {
Map<Date, Day> days = new HashMap<Date, Day>();
setField(calendarBean, "days", days);
DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
Period extendedPeriod = new Period(df.parse("01-12-2014"), df.parse("28-02-2015"));
setField(calendarBean, "extendedPeriod", extendedPeriod);
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar();
setField(calendarBean, "workdaysCalendar", workdaysCalendar);
List<Day> result = new ArrayList<Day>();
for (Date date : extendedPeriod.getDays()) {
result.add(new Day(date, workdaysCalendar));
}
expect(workdaysCalendarService.getDays(workdaysCalendar, extendedPeriod)).andReturn(result);
replay(workdaysCalendarService);
calendarBean.populateDays();
verify(workdaysCalendarService);
assertArrayEquals(result.toArray(), days.values().toArray());
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testNextMonth.
@Test
public void testNextMonth() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("monthCount", "1");
Period period = new Period(sdf.parse("1-01-2015"), sdf.parse("31-01-2015"));
setField(calendarBean, "period", period);
Period expected = new Period(sdf.parse("1-02-2015"), sdf.parse("28-02-2015"));
expect(externalContext.getRequestParameterMap()).andReturn(map);
expect(workdaysCalendarService.getDays(anyObject(WorkdaysCalendar.class), anyObject(Period.class))).andReturn(new ArrayList<Day>());
replayAll(workdaysCalendarService, externalContext);
calendarBean.nextMonth();
verify(workdaysCalendarService);
Period actual = (Period) getField(calendarBean, "period");
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testGetDaysOff_ifDayIsWorking.
@Test
public void testGetDaysOff_ifDayIsWorking() throws Exception {
Period extendedPeriod = new Period(sdf.parse("01-12-2014"), sdf.parse("28-02-2015"));
setField(calendarBean, "extendedPeriod", extendedPeriod);
Date date = sdf.parse("1-01-2015");
Map<Date, Day> days = new HashMap<Date, Day>();
days.put(date, new Day(date, null, true));
setField(calendarBean, "days", days);
assertEquals(calendarBean.getDaysOff(), "");
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testGetDaysShift_ifExist.
@Test
public void testGetDaysShift_ifExist() throws ParseException, Exception {
DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
Period period = new Period(df.parse("01-12-2014"), df.parse("28-02-2015"));
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar();
setField(calendarBean, "workdaysCalendar", workdaysCalendar);
Day day1 = createDay(1L, sdf.parse("1-01-2015"));
day1.setShiftedFrom(sdf.parse("1-01-2015"));
day1.setShiftedTo(sdf.parse("5-01-2015"));
Map<Date, Day> days = new HashMap<Date, Day>();
days.put(day1.getDate(), day1);
setField(calendarBean, "days", days);
setField(calendarBean, "period", period);
List<Day> expected = Arrays.asList(day1);
List<Day> actual = calendarBean.getDaysShift();
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testGetDaysOff.
@Test
public void testGetDaysOff() throws NoSuchFieldException, ParseException {
DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
Period extendedPeriod = new Period(df.parse("01-12-2014"), df.parse("28-02-2015"));
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar();
setField(calendarBean, "workdaysCalendar", workdaysCalendar);
setField(calendarBean, "extendedPeriod", extendedPeriod);
Day day1 = new Day(df.parse("01-01-2015"), workdaysCalendar);
day1.setWorking(false);
Day day2 = new Day(df.parse("02-01-2015"), workdaysCalendar);
day2.setWorking(true);
Map<Date, Day> days = new HashMap<Date, Day>();
days.put(day1.getDate(), day1);
days.put(day2.getDate(), day2);
setField(calendarBean, "days", days);
assertEquals("1-1-2015", calendarBean.getDaysOff());
}
Aggregations