use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testGetSpecialDays_ByPeriod.
@Test
public void testGetSpecialDays_ByPeriod() {
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar();
workdaysCalendar.setName("calendarName");
Date start = new GregorianCalendar(2011, 0, 2).getTime();
Date finish = new GregorianCalendar(2011, 0, 29).getTime();
Date expectedDate = new GregorianCalendar(2011, 0, 15).getTime();
Date unexpectedDate1 = new GregorianCalendar(2011, 0, 1).getTime();
Date unexpectedDate2 = new GregorianCalendar(2011, 0, 30).getTime();
Period period = new Period(start, finish);
Day expected1 = new Day(start, workdaysCalendar);
Day expected2 = new Day(expectedDate, workdaysCalendar);
Day expected3 = new Day(finish, workdaysCalendar);
Day unexpected1 = new Day(unexpectedDate1, workdaysCalendar);
Day unexpected2 = new Day(unexpectedDate2, workdaysCalendar);
entityManager.persist(workdaysCalendar);
entityManager.persist(expected1);
entityManager.persist(expected3);
entityManager.persist(expected2);
entityManager.persist(unexpected1);
entityManager.persist(unexpected2);
List<Day> actuals = workdaysCalendarRepository.getSpecialDays(workdaysCalendar, period);
assertEquals(3, actuals.size());
assertFalse(actuals.contains(unexpected1));
assertFalse(actuals.contains(unexpected2));
}
Aggregations