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 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.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testFindByDepartment_exists.
@Test
public void testFindByDepartment_exists() {
WorkdaysCalendar expected = new WorkdaysCalendar();
expected.setDepartments(new HashSet<>(Arrays.asList("dep1", "dep2")));
WorkdaysCalendar unexpected = new WorkdaysCalendar();
unexpected.setDepartments(new HashSet<>(Arrays.asList("dep3", "dep4")));
entityManager.persist(expected);
entityManager.persist(unexpected);
WorkdaysCalendar actual = workdaysCalendarRepository.findByDepartment("dep1");
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testAttachAndRefresh.
@Test
public void testAttachAndRefresh() {
String savedName = "SavedName1";
String externallyChangedName = "ExternChangedName";
WorkdaysCalendar calendar = new WorkdaysCalendar(savedName);
entityManager.persist(calendar);
entityManager.flush();
entityManager.clear();
entityManager.createQuery("UPDATE WorkdaysCalendar wc " + "SET wc.name=:newName WHERE wc.name=:savedName").setParameter("savedName", savedName).setParameter("newName", externallyChangedName).executeUpdate();
entityManager.flush();
entityManager.clear();
calendar = workdaysCalendarRepository.attachAndRefresh(calendar);
assertEquals(externallyChangedName, calendar.getName());
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testFindDefaultCalendar_ifNotFound.
@Test
public void testFindDefaultCalendar_ifNotFound() {
WorkdaysCalendar actual = workdaysCalendarRepository.findDefaultCalendar("");
assertNull(actual);
}
Aggregations