use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarServiceRbacIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
workdaysCalendar = new WorkdaysCalendar("Calendar");
runInNewTx.run(() -> {
entityManager.joinTransaction();
entityManager.persist(workdaysCalendar);
});
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar 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.WorkdaysCalendar 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.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarBeanTest method testCreate.
@Test
public void testCreate() throws NoSuchFieldException {
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar();
setField(calendarBean, "workdaysCalendar", workdaysCalendar);
expect(workdaysCalendarService.create(workdaysCalendar)).andReturn(workdaysCalendar);
replay(workdaysCalendarService);
calendarBean.create();
verify(workdaysCalendarService);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar 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