Search in sources :

Example 46 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 47 with WorkdaysCalendar

use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.

the class WorkdaysCalendarRepositoryTest method testCreateDays.

@Test
public void testCreateDays() {
    Date date1 = new GregorianCalendar(2011, 1, 3).getTime();
    Date date2 = new GregorianCalendar(2011, 1, 0).getTime();
    List<Date> dates = Arrays.asList(date1, date2);
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
    List<Day> actuals = workdaysCalendarRepository.createDays(dates, workdaysCalendar);
    assertEquals(2, actuals.size());
    Day actual = actuals.get(0);
    assertEquals(date1, actual.getDate());
    assertEquals(workdaysCalendar.getName(), actual.getWorkdaysCalendar().getName());
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) GregorianCalendar(java.util.GregorianCalendar) Day(com.artezio.arttime.datamodel.Day) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 48 with WorkdaysCalendar

use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.

the class ProjectBeanTest method testAddNewTeamMember.

@Test
public void testAddNewTeamMember() throws NoSuchFieldException {
    Project project = new Project();
    Employee employee = new Employee("employee");
    WorkdaysCalendar calendar = new WorkdaysCalendar();
    employee.setCalendar(calendar);
    Map<Employee, Project[]> participations = new HashMap<>();
    setField(bean, "participations", participations);
    setField(bean, "project", project);
    setField(bean, "employee", employee);
    bean.addNewTeamMember();
    assertEquals(1, participations.size());
    assertEquals(1, participations.get(employee).length);
    assertSame(project, participations.get(employee)[0]);
    assertTrue(participations.containsKey(employee));
    assertNull(bean.getEmployee());
}
Also used : Project(com.artezio.arttime.datamodel.Project) WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 49 with WorkdaysCalendar

use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.

the class DepartmentServiceRbacIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    workdaysCalendar = new WorkdaysCalendar("Calendar");
    runInNewTx.run(() -> {
        entityManager.joinTransaction();
        entityManager.persist(workdaysCalendar);
    });
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Before(org.junit.Before)

Example 50 with WorkdaysCalendar

use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.

the class EmployeeServiceRbacIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    workdaysCalendar = new WorkdaysCalendar("Calendar");
    employee = new Employee("uname", "fname", "lname", "email", "department1");
    employee.setCalendar(workdaysCalendar);
    runInNewTx.run(() -> {
        entityManager.joinTransaction();
        entityManager.persist(workdaysCalendar);
        entityManager.persist(employee);
    });
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Employee(com.artezio.arttime.datamodel.Employee) Before(org.junit.Before)

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