use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testAddDayShift_ifWorkingDayShiftToWeekend.
@Test
public void testAddDayShift_ifWorkingDayShiftToWeekend() throws Exception {
DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
Period period = new Period(df.parse("01-12-2014"), df.parse("28-02-2015"));
Day day1 = createDay(1L, sdf.parse("1-01-2015"));
Day day2 = createDay(2L, sdf.parse("5-01-2015"));
day1.setWorking(true);
day2.setWorking(false);
Map<Date, Day> days = new HashMap<Date, Day>();
days.put(day1.getDate(), day1);
days.put(day2.getDate(), day2);
setField(calendarBean, "days", days);
setField(calendarBean, "shiftFrom", sdf.parse("1-01-2015"));
setField(calendarBean, "shiftTo", sdf.parse("5-01-2015"));
setField(calendarBean, "period", period);
calendarBean.addDayShift();
assertArrayEquals(calendarBean.getDaysShift().toArray(), new Day[] { day1 });
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testAddDayShift_ifWeekendShiftToWorkingDay.
@Test
public void testAddDayShift_ifWeekendShiftToWorkingDay() throws Exception {
DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
Period period = new Period(df.parse("01-12-2014"), df.parse("28-02-2015"));
Day day1 = createDay(1L, sdf.parse("1-01-2015"));
Day day2 = createDay(2L, sdf.parse("5-01-2015"));
day1.setWorking(false);
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);
setField(calendarBean, "shiftFrom", sdf.parse("1-01-2015"));
setField(calendarBean, "shiftTo", sdf.parse("5-01-2015"));
setField(calendarBean, "period", period);
calendarBean.addDayShift();
assertArrayEquals(calendarBean.getDaysShift().toArray(), new Day[] { day1 });
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testOnDateSelect.
@Test
public void testOnDateSelect() throws Exception {
SelectEvent event = createMock(SelectEvent.class);
Date date1 = sdf.parse("1-01-2015");
Date date2 = sdf.parse("2-01-2015");
Period period = new Period(sdf.parse("1-01-2015"), sdf.parse("16-01-2015"));
Map<Date, Day> days = new HashMap<Date, Day>();
days.put(date1, new Day(date1, null, true));
days.put(date2, new Day(date2, null, true));
setField(calendarBean, "days", days);
setField(calendarBean, "extendedPeriod", period);
expect(event.getObject()).andReturn(date1);
replay(event);
calendarBean.onDateSelect(event);
verify(event);
assertFalse(days.get(date1).isWorking());
assertNotNull(calendarBean.getDaysOff());
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testGetHolidays.
@Test
public void testGetHolidays() throws ParseException, Exception {
Day day1 = createDay(1L, sdf.parse("1-01-2015"));
Day day2 = createDay(2L, sdf.parse("2-01-2015"));
day1.setHoliday(true);
day2.setHoliday(false);
Map<Date, Day> days = new HashMap<Date, Day>();
days.put(day1.getDate(), day1);
days.put(day2.getDate(), day2);
Period extendedPeriod = new Period(sdf.parse("01-12-2014"), sdf.parse("28-02-2015"));
setField(calendarBean, "extendedPeriod", extendedPeriod);
setField(calendarBean, "days", days);
String actual = calendarBean.getHolidays();
assertEquals("1-1-2015", actual);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class MonthSelectorTest method setNextPeriod.
@Test
public void setNextPeriod() throws ParseException, NoSuchFieldException {
Date firstDayOfMonth = sdf.parse("1-05-2014");
Date lastDayOfMonth = sdf.parse("31-05-2014");
Period period = new Period(firstDayOfMonth, lastDayOfMonth);
setField(monthSelector, "period", period);
Period expected = new Period(sdf.parse("1-06-2014"), sdf.parse("30-06-2014"));
monthSelector.setNextPeriod();
Period actual = (Period) getField(monthSelector, "period");
assertEquals(expected, actual);
}
Aggregations