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;
}
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());
}
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);
}
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());
}
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());
}
Aggregations