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