Search in sources :

Example 21 with WorkdaysCalendar

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));
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 22 with WorkdaysCalendar

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());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Day(com.artezio.arttime.datamodel.Day) Test(org.junit.Test)

Example 23 with WorkdaysCalendar

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);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 24 with WorkdaysCalendar

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());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 25 with WorkdaysCalendar

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);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Aggregations

WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)76 Test (org.junit.Test)65 Day (com.artezio.arttime.datamodel.Day)23 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)17 Employee (com.artezio.arttime.datamodel.Employee)16 Period (com.artezio.arttime.datamodel.Period)11 Date (java.util.Date)10 Project (com.artezio.arttime.datamodel.Project)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 SimpleDateFormat (java.text.SimpleDateFormat)5 DateFormat (java.text.DateFormat)3 Before (org.junit.Before)3 HourType (com.artezio.arttime.datamodel.HourType)2 Hours (com.artezio.arttime.datamodel.Hours)2 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)2 BigDecimal (java.math.BigDecimal)2 GregorianCalendar (java.util.GregorianCalendar)2 HashMap (java.util.HashMap)2 WebCached (com.artezio.arttime.admin_tool.cache.WebCached)1 Scope (com.artezio.arttime.admin_tool.cache.WebCached.Scope)1