use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testRemoveWorkdaysCalendar_RemoveForbidden.
@Test(expected = PersistenceException.class)
public void testRemoveWorkdaysCalendar_RemoveForbidden() {
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
Project project = new Project();
Employee employee = new Employee("employee");
employee.setCalendar(workdaysCalendar);
project.addTeamMember(employee);
entityManager.persist(workdaysCalendar);
entityManager.persist(employee);
entityManager.persist(project);
workdaysCalendarRepository.remove(workdaysCalendar);
entityManager.flush();
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testCreateOrUpdateDays_Update.
@Test
public void testCreateOrUpdateDays_Update() {
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar-testCreateOrUpdateDays_Update");
Day day = new Day(new Date(), workdaysCalendar);
entityManager.persist(workdaysCalendar);
entityManager.persist(day);
WorkdaysCalendar calendar = new WorkdaysCalendar();
String expected = "expected calendar name";
calendar.setName(expected);
entityManager.persist(calendar);
day.setWorkdaysCalendar(calendar);
workdaysCalendarRepository.update(Arrays.asList(day));
assertEquals(expected, day.getWorkdaysCalendar().getName());
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testFindDefaultCalendar.
@Test
public void testFindDefaultCalendar() {
WorkdaysCalendar expected = new WorkdaysCalendar();
expected.setDepartments(new HashSet<>(Arrays.asList("dep1", "dep2")));
WorkdaysCalendar unexpected = new WorkdaysCalendar();
unexpected.setDepartments(new HashSet<>(Arrays.asList("dep2", "dep3")));
entityManager.persist(expected);
entityManager.persist(unexpected);
WorkdaysCalendar actual = workdaysCalendarRepository.findDefaultCalendar("dep1");
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testRemoveWorkdaysCalendar_NotUsedCalendarWithDepartment.
@Test
public void testRemoveWorkdaysCalendar_NotUsedCalendarWithDepartment() {
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
calendar.getDepartments().add("minsk");
entityManager.persist(calendar);
entityManager.flush();
entityManager.clear();
workdaysCalendarRepository.remove(calendar);
entityManager.flush();
entityManager.clear();
WorkdaysCalendar actual = entityManager.find(WorkdaysCalendar.class, calendar.getId());
assertNull(actual);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testRemoveWorkdaysCalendar.
@Test
public void testRemoveWorkdaysCalendar() {
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
Day day = new Day(new Date(), workdaysCalendar);
entityManager.persist(workdaysCalendar);
entityManager.persist(day);
Long dayId = day.getId();
Long workdaysCalendarId = workdaysCalendar.getId();
workdaysCalendarRepository.remove(workdaysCalendar);
entityManager.flush();
entityManager.clear();
WorkdaysCalendar actualCalendar = entityManager.find(WorkdaysCalendar.class, workdaysCalendarId);
Day actualDay = entityManager.find(Day.class, dayId);
assertNull(actualCalendar);
assertNull(actualDay);
}
Aggregations