use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testGetCalendarsByDepartments.
@Test
public void testGetCalendarsByDepartments() throws NoSuchFieldException {
WorkdaysCalendar calendar1 = new WorkdaysCalendar("cal1");
calendar1.getDepartments().add("Minsk");
calendar1.getDepartments().add("Moscow");
WorkdaysCalendar calendar2 = new WorkdaysCalendar("cal2");
calendar2.getDepartments().add("Vitebsk");
entityManager.persist(calendar1);
entityManager.persist(calendar2);
Map<String, WorkdaysCalendar> expected = new HashMap<>();
expected.put("Minsk", calendar1);
expected.put("Moscow", calendar1);
expected.put("Vitebsk", calendar2);
Map<String, WorkdaysCalendar> actual = workdaysCalendarRepository.getCalendarsByDepartments();
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar 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());
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testGetWorkdaysCalendars.
@Test
public void testGetWorkdaysCalendars() {
WorkdaysCalendar workdaysCalendar1 = new WorkdaysCalendar("calendar1");
WorkdaysCalendar workdaysCalendar2 = new WorkdaysCalendar("calendar2");
entityManager.persist(workdaysCalendar1);
entityManager.persist(workdaysCalendar2);
List<WorkdaysCalendar> actuals = workdaysCalendarRepository.getWorkdaysCalendars();
assertEquals(2, actuals.size());
assertTrue(actuals.contains(workdaysCalendar1));
assertTrue(actuals.contains(workdaysCalendar2));
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testFindDefaultCalendarByEmployee.
@Test
public void testFindDefaultCalendarByEmployee() {
Employee employee = new Employee();
employee.setDepartment("dep1");
WorkdaysCalendar expected = new WorkdaysCalendar();
expected.setDepartments(Arrays.asList("dep1", "dep2"));
WorkdaysCalendar unexpected = new WorkdaysCalendar();
unexpected.setDepartments(Arrays.asList("dep2", "dep3"));
entityManager.persist(expected);
entityManager.persist(unexpected);
WorkdaysCalendar actual = workdaysCalendarRepository.findDefaultCalendar(employee);
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testCreateWorkdaysCalendar.
@Test
public void testCreateWorkdaysCalendar() throws NoSuchFieldException {
WorkdaysCalendar expected = new WorkdaysCalendar("expected calendar");
WorkdaysCalendar actual = workdaysCalendarRepository.create(expected);
assertSame(expected, actual);
}
Aggregations