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);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testGetDays.
@Test
public void testGetDays() {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
Day day = new Day(new Date(), calendar);
entityManager.persist(calendar);
entityManager.persist(day);
entityManager.flush();
entityManager.clear();
List<Day> actual = workdaysCalendarRepository.getDays(calendar, period);
assertNotNull(actual);
assertEquals(3, actual.size());
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testGetPersistedDays_ShouldFilterByPeriod.
@Test
public void testGetPersistedDays_ShouldFilterByPeriod() {
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar();
workdaysCalendar.setName("calendarName");
Date start = new GregorianCalendar(2011, 0, 2).getTime();
Date finish = new GregorianCalendar(2011, 0, 29).getTime();
Date expectedDate = new GregorianCalendar(2011, 0, 15).getTime();
Date unexpectedDate1 = new GregorianCalendar(2011, 0, 1).getTime();
Date unexpectedDate2 = new GregorianCalendar(2011, 0, 30).getTime();
Period period = new Period(start, finish);
Day expected1 = new Day(start, workdaysCalendar);
Day expected2 = new Day(expectedDate, workdaysCalendar);
Day expected3 = new Day(finish, workdaysCalendar);
Day unexpected1 = new Day(unexpectedDate1, workdaysCalendar);
Day unexpected2 = new Day(unexpectedDate2, workdaysCalendar);
entityManager.persist(workdaysCalendar);
entityManager.persist(expected1);
entityManager.persist(expected3);
entityManager.persist(expected2);
entityManager.persist(unexpected1);
entityManager.persist(unexpected2);
List<Day> actuals = workdaysCalendarRepository.getPersistedDays(workdaysCalendar, period);
assertEquals(3, actuals.size());
assertFalse(actuals.contains(unexpected1));
assertFalse(actuals.contains(unexpected2));
}
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 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);
}
Aggregations