Search in sources :

Example 1 with WorkdaysCalendar

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

the class LdapAdapter method createEmployee.

protected Employee createEmployee(Attributes attrs) throws NamingException, IllegalAccessException, InvocationTargetException {
    Employee employee = new Employee();
    for (Entry<String, String> item : attributeMapping.entrySet()) {
        Attribute attr = attrs.get(item.getKey());
        String value = parseAttribute(attr);
        BeanUtils.setProperty(employee, item.getValue(), value);
    }
    employee.castDepartmentToNameCase();
    WorkdaysCalendar calendar = workdaysCalendarRepository.findDefaultCalendar(employee);
    employee.setCalendar(calendar);
    return employee;
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Employee(com.artezio.arttime.datamodel.Employee) Attribute(javax.naming.directory.Attribute)

Example 2 with WorkdaysCalendar

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

the class DepartmentServiceTest method testGetDepartmentsAvailableForChoice.

@Test
public void testGetDepartmentsAvailableForChoice() throws NoSuchFieldException {
    setField(departmentService, "employeeService", employeeService);
    setField(departmentService, "workdaysCalendarRepository", workdaysCalendarRepository);
    WorkdaysCalendar calendar1 = new WorkdaysCalendar();
    calendar1.getDepartments().add("Minsk");
    WorkdaysCalendar calendar2 = new WorkdaysCalendar();
    calendar2.getDepartments().add("Moscow");
    List<WorkdaysCalendar> calendars = Arrays.asList(calendar1, calendar2);
    expect(workdaysCalendarRepository.getWorkdaysCalendars()).andReturn(calendars);
    expect(employeeService.getEmployees()).andReturn(getEmployeesInTrackingSystem());
    replay(workdaysCalendarRepository, employeeService);
    List<String> expected = Arrays.asList("Minsk");
    List<String> actual = departmentService.getAvailableForChoice(calendar1);
    verify(workdaysCalendarRepository, employeeService);
    ListAssert.assertEquals(expected, actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 3 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() {
    Employee employee = new Employee();
    WorkdaysCalendar actual = workdaysCalendarRepository.findDefaultCalendar(employee);
    assertNull(actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 4 with WorkdaysCalendar

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

the class WorkdaysCalendarRepositoryTest method testCreateOrUpdateDays_Create.

@Test
public void testCreateOrUpdateDays_Create() {
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendarTtestCreateOrUpdateDays_Create");
    entityManager.persist(workdaysCalendar);
    Day expected = new Day(new Date(), workdaysCalendar);
    workdaysCalendarRepository.update(Arrays.asList(expected));
    assertNotNull(expected.getId());
    Day actual = entityManager.find(Day.class, expected.getId());
    assertEquals(expected, actual);
}
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 5 with WorkdaysCalendar

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

the class WorkdaysCalendarRepositoryTest method testGetPersistedDays_ShouldFilterByCalendar.

@Test
public void testGetPersistedDays_ShouldFilterByCalendar() {
    WorkdaysCalendar expectedCalendar = new WorkdaysCalendar();
    WorkdaysCalendar unexpectedCalendar = new WorkdaysCalendar();
    String expectedName = "expected calendar name";
    String unexpectedName = "unexpected calendar name";
    expectedCalendar.setName(expectedName);
    unexpectedCalendar.setName(unexpectedName);
    Date start = new Date();
    Date finish = getOffsetDate(1);
    Day expectedDay = new Day(start, expectedCalendar);
    Day unexpectedDay = new Day(start, unexpectedCalendar);
    entityManager.persist(expectedCalendar);
    entityManager.persist(unexpectedCalendar);
    entityManager.persist(expectedDay);
    entityManager.persist(unexpectedDay);
    Period period = new Period(start, finish);
    List<Day> actuals = workdaysCalendarRepository.getPersistedDays(expectedCalendar, period);
    assertEquals(1, actuals.size());
    assertTrue(actuals.contains(expectedDay));
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Period(com.artezio.arttime.datamodel.Period) Day(com.artezio.arttime.datamodel.Day) Date(java.util.Date) 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