Search in sources :

Example 61 with WorkdaysCalendar

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

the class WorkdaysCalendarsBeanTest method testGetWorkdaysCalendarsByDepartments_whenNotNull.

@Test
public void testGetWorkdaysCalendarsByDepartments_whenNotNull() throws NoSuchFieldException {
    Map<String, WorkdaysCalendar> calendarMap = new HashMap<>();
    calendarMap.put("Dept1", new WorkdaysCalendar("aa"));
    calendarMap.put("Dept2", new WorkdaysCalendar("bb"));
    setField(bean, "workdaysCalendarsByDepartments", calendarMap);
    Map<String, WorkdaysCalendar> actual = bean.getWorkdaysCalendarsByDepartments();
    assertEquals(calendarMap, actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 62 with WorkdaysCalendar

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

the class WorkdaysCalendarsBeanTest method testSaveCalendarsByDepartments.

@Test
public void testSaveCalendarsByDepartments() throws NoSuchFieldException {
    List<String> departments = Arrays.asList("Dept1", "Dept2");
    Map<String, WorkdaysCalendar> calendarMap = new HashMap<>();
    WorkdaysCalendar calendar = new WorkdaysCalendar("Cal1");
    calendarMap.put("Dept1", calendar);
    calendarMap.put("Dept2", null);
    setField(bean, "departments", departments);
    setField(bean, "workdaysCalendarsByDepartments", calendarMap);
    departmentService.setCalendarToDepartment("Dept1", calendar);
    departmentService.setCalendarToDepartment("Dept2", null);
    replay(departmentService);
    bean.save();
    verify(departmentService);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 63 with WorkdaysCalendar

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

the class EmployeesBeanTest method testFilterByCalendar_valueNull_filterNotNull_filterEmpty.

@Test
public void testFilterByCalendar_valueNull_filterNotNull_filterEmpty() throws NoSuchFieldException {
    WorkdaysCalendar calendar = new WorkdaysCalendar("calendar1");
    setField(calendar, "id", 1L);
    boolean actual = bean.filterByCalendar(null, Collections.emptyList(), null);
    assertTrue(actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Test(org.junit.Test)

Example 64 with WorkdaysCalendar

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

the class DepartmentService method setCalendarToDepartment.

@RolesAllowed({ EXEC_ROLE, OFFICE_MANAGER })
public void setCalendarToDepartment(String department, WorkdaysCalendar newCalendar) {
    WorkdaysCalendar currentCalendar = workdaysCalendarRepository.findByDepartment(department);
    changeDepartmentCalendar(department, newCalendar, currentCalendar);
    changeEmployeesCalendar(department, newCalendar, currentCalendar);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) RolesAllowed(javax.annotation.security.RolesAllowed)

Example 65 with WorkdaysCalendar

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

the class KeycloakAdapter method createEmployee.

Employee createEmployee(UserInfo userInfo) {
    Employee employee = new Employee(userInfo.getUsername(), userInfo.getFirstName(), userInfo.getLastName(), userInfo.getEmail(), userInfo.getDepartment());
    WorkdaysCalendar calendar = workdaysCalendarRepository.findDefaultCalendar(employee.getDepartment());
    employee.setCalendar(calendar);
    return employee;
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Employee(com.artezio.arttime.datamodel.Employee)

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