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());
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarBean method init.
@PostConstruct
public void init() {
Map<String, String> requestParams = externalContext.getRequestParameterMap();
String calendarId = requestParams.get("calendar");
if (calendarId == null) {
this.workdaysCalendar = new WorkdaysCalendar();
} else {
this.workdaysCalendar = workdaysCalendarService.findById(Long.parseLong(calendarId));
Date start = CalendarUtils.firstDayOfMonth(new Date());
Date finish = CalendarUtils.lastDayOfMonth(new Date());
updatePeriod(start, finish);
}
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarServiceTest 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 = workdaysCalendarService.createDays(dates, workdaysCalendar);
assertEquals(2, actuals.size());
Day actual = actuals.get(0);
assertEquals(date1, actual.getDate());
assertEquals(workdaysCalendar.getName(), actual.getWorkdaysCalendar().getName());
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class WorkdaysCalendarServiceTest method testGetCalendarsByDepartments.
@Test
public void testGetCalendarsByDepartments() {
WorkdaysCalendar calendar1 = new WorkdaysCalendar("cal1");
calendar1.getDepartments().add("Minsk");
calendar1.getDepartments().add("Moscow");
WorkdaysCalendar calendar2 = new WorkdaysCalendar("cal2");
calendar2.getDepartments().add("Vitebsk");
Map<String, WorkdaysCalendar> expected = new HashMap<>();
expected.put("Minsk", calendar1);
expected.put("Moscow", calendar1);
expected.put("Vitebsk", calendar2);
expect(workdaysCalendarRepository.getWorkdaysCalendars()).andReturn(Arrays.asList(calendar1, calendar2));
replay(workdaysCalendarRepository);
Map<String, WorkdaysCalendar> actual = workdaysCalendarService.getCalendarsByDepartments();
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.WorkdaysCalendar in project ART-TIME by Artezio.
the class ProjectRepositoryTest method testCreateProject.
@Test
public void testCreateProject() throws NoSuchFieldException {
HourType hourType = new HourType("type");
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
entityManager.persist(hourType);
entityManager.persist(calendar);
entityManager.flush();
entityManager.clear();
Employee manager = new Employee("manager");
Employee resource = new Employee("slave");
resource.setCalendar(calendar);
Project project = new Project();
project.addManager(manager);
project.getAccountableHours().add(hourType);
project.addTeamMember(resource);
assertNull(project.getId());
setField(projectRepository, "employeeRepository", employeeRepository);
expect(employeeRepository.create(resource)).andReturn(getPersisted(resource));
expect(employeeRepository.create(manager)).andReturn(getPersisted(manager));
replay(employeeRepository);
Project actual = projectRepository.create(project);
entityManager.flush();
verify(employeeRepository);
assertNotNull(actual.getId());
}
Aggregations