Search in sources :

Example 71 with Period

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 });
}
Also used : 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 72 with Period

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 });
}
Also used : 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 73 with Period

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

Example 74 with Period

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

Example 75 with Period

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);
}
Also used : Period(com.artezio.arttime.datamodel.Period) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Period (com.artezio.arttime.datamodel.Period)93 Test (org.junit.Test)87 Employee (com.artezio.arttime.datamodel.Employee)59 Date (java.util.Date)56 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)44 HourType (com.artezio.arttime.datamodel.HourType)43 Project (com.artezio.arttime.datamodel.Project)42 Hours (com.artezio.arttime.datamodel.Hours)40 BigDecimal (java.math.BigDecimal)34 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)22 Day (com.artezio.arttime.datamodel.Day)17 HashMap (java.util.HashMap)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)13 List (java.util.List)13 Map (java.util.Map)11 ArrayList (java.util.ArrayList)8 GregorianCalendar (java.util.GregorianCalendar)8 HoursRepository (com.artezio.arttime.repositories.HoursRepository)7 Mail (com.artezio.arttime.services.mailing.Mail)7