Search in sources :

Example 71 with WorkdaysCalendar

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

Example 72 with WorkdaysCalendar

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

Example 73 with WorkdaysCalendar

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

Example 74 with WorkdaysCalendar

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

Example 75 with WorkdaysCalendar

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