Search in sources :

Example 76 with WorkdaysCalendar

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));
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Period(com.artezio.arttime.datamodel.Period) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Aggregations

WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)76 Test (org.junit.Test)65 Day (com.artezio.arttime.datamodel.Day)23 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)17 Employee (com.artezio.arttime.datamodel.Employee)16 Period (com.artezio.arttime.datamodel.Period)11 Date (java.util.Date)10 Project (com.artezio.arttime.datamodel.Project)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 SimpleDateFormat (java.text.SimpleDateFormat)5 DateFormat (java.text.DateFormat)3 Before (org.junit.Before)3 HourType (com.artezio.arttime.datamodel.HourType)2 Hours (com.artezio.arttime.datamodel.Hours)2 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)2 BigDecimal (java.math.BigDecimal)2 GregorianCalendar (java.util.GregorianCalendar)2 HashMap (java.util.HashMap)2 WebCached (com.artezio.arttime.admin_tool.cache.WebCached)1 Scope (com.artezio.arttime.admin_tool.cache.WebCached.Scope)1