Search in sources :

Example 41 with WorkdaysCalendar

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

Example 42 with WorkdaysCalendar

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());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Day(com.artezio.arttime.datamodel.Day) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 43 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 44 with WorkdaysCalendar

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

Example 45 with WorkdaysCalendar

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);
}
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