Search in sources :

Example 51 with WorkdaysCalendar

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);
    });
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Before(org.junit.Before)

Example 52 with 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());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Period(com.artezio.arttime.datamodel.Period) Day(com.artezio.arttime.datamodel.Day) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 53 with WorkdaysCalendar

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);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Period(com.artezio.arttime.datamodel.Period) SimpleDateFormat(java.text.SimpleDateFormat) Day(com.artezio.arttime.datamodel.Day) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 54 with WorkdaysCalendar

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);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 55 with WorkdaysCalendar

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());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Period(com.artezio.arttime.datamodel.Period) SimpleDateFormat(java.text.SimpleDateFormat) Day(com.artezio.arttime.datamodel.Day) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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