Search in sources :

Example 11 with Day

use of com.artezio.arttime.datamodel.Day in project ART-TIME by Artezio.

the class WorkdaysCalendarBean method addDayShift.

public void addDayShift() {
    Day dayTo = days.get(shiftTo);
    Day dayFrom = days.get(shiftFrom);
    dayFrom.setShiftedFrom(dayFrom.getDate());
    dayFrom.setShiftedTo(dayTo.getDate());
    boolean isShiftToWorkDay = dayTo.isWorking();
    dayTo.setWorking(dayFrom.isWorking());
    dayFrom.setWorking(isShiftToWorkDay);
    boolean isShiftToHoliday = dayTo.isHoliday();
    dayTo.setHoliday(dayFrom.isHoliday());
    dayFrom.setHoliday(isShiftToHoliday);
    dayTo.setComment(comment);
    dayFrom.setComment(comment);
    shiftFrom = null;
    shiftTo = null;
    comment = null;
}
Also used : Day(com.artezio.arttime.datamodel.Day)

Example 12 with Day

use of com.artezio.arttime.datamodel.Day in project ART-TIME by Artezio.

the class WorkdaysCalendarServiceTest method testCreateDays.

@Test
public void testCreateDays() {
    Date date1 = new GregorianCalendar(2011, 1, 3).getTime();
    Date date2 = new GregorianCalendar(2011, 1, 0).getTime();
    List<Date> dates = Arrays.asList(date1, date2);
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
    List<Day> actuals = workdaysCalendarService.createDays(dates, workdaysCalendar);
    assertEquals(2, actuals.size());
    Day actual = actuals.get(0);
    assertEquals(date1, actual.getDate());
    assertEquals(workdaysCalendar.getName(), actual.getWorkdaysCalendar().getName());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 13 with Day

use of com.artezio.arttime.datamodel.Day in project ART-TIME by Artezio.

the class WorkdaysCalendarRepositoryTest method testCreateOrUpdateDays_Create.

@Test
public void testCreateOrUpdateDays_Create() {
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendarTtestCreateOrUpdateDays_Create");
    entityManager.persist(workdaysCalendar);
    Day expected = new Day(new Date(), workdaysCalendar);
    workdaysCalendarRepository.update(Arrays.asList(expected));
    assertNotNull(expected.getId());
    Day actual = entityManager.find(Day.class, expected.getId());
    assertEquals(expected, actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 14 with Day

use of com.artezio.arttime.datamodel.Day in project ART-TIME by Artezio.

the class WorkdaysCalendarRepositoryTest method testUpdateWorkdaysCalendar.

@Test
public void testUpdateWorkdaysCalendar() {
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
    entityManager.persist(workdaysCalendar);
    String expected = "calendar new name";
    workdaysCalendar.setName(expected);
    workdaysCalendarRepository.update(workdaysCalendar, new ArrayList<Day>());
    WorkdaysCalendar actual = entityManager.find(WorkdaysCalendar.class, workdaysCalendar.getId());
    assertEquals(expected, actual.getName());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Day(com.artezio.arttime.datamodel.Day) Test(org.junit.Test)

Example 15 with Day

use of com.artezio.arttime.datamodel.Day in project ART-TIME by Artezio.

the class WorkdaysCalendarRepositoryTest method testSaveDayWithNullFieldsThenLoadNotNull.

@Test
public void testSaveDayWithNullFieldsThenLoadNotNull() {
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
    Day day = new Day(new Date(), workdaysCalendar);
    day.setHoliday(null);
    day.setWorking(null);
    entityManager.persist(workdaysCalendar);
    entityManager.persist(day);
    Long dayId = day.getId();
    entityManager.flush();
    entityManager.clear();
    Day persistedDay = entityManager.find(Day.class, dayId);
    assertNotNull(persistedDay.isWorking());
    assertNotNull(persistedDay.isHoliday());
    assertFalse(persistedDay.isHoliday());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Day(com.artezio.arttime.datamodel.Day) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Aggregations

Day (com.artezio.arttime.datamodel.Day)37 Test (org.junit.Test)33 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)25 Period (com.artezio.arttime.datamodel.Period)17 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 Date (java.util.Date)8 DateFormat (java.text.DateFormat)5 SimpleDateFormat (java.text.SimpleDateFormat)5 GregorianCalendar (java.util.GregorianCalendar)2 SelectEvent (org.primefaces.event.SelectEvent)1