use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class CalendarPeriodSelectorTest method testSetWeekPeriod.
@Test
public void testSetWeekPeriod() throws ParseException, NoSuchFieldException {
Period period = new Period(sdf.parse("1-05-2014"), sdf.parse("3-05-2014"));
setField(rangePeriodSelector, "period", period);
setField(rangePeriodSelector, "range", Range.CUSTOM);
Period expectedPeriod = new Period(sdf.parse("27-04-2014"), sdf.parse("3-05-2014"));
PowerMock.mockStatic(Locale.class);
expect(Locale.getDefault()).andReturn(Locale.US);
rangePeriodSelector.setWeekPeriod();
Range actualRange = (Range) getField(rangePeriodSelector, "range");
Period actualPeriod = (Period) getField(rangePeriodSelector, "period");
assertEquals(Range.WEEK, actualRange);
assertEquals(expectedPeriod, actualPeriod);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class FilterServiceTest method testCreatePersonalTimesheetFilter.
@Test
public void testCreatePersonalTimesheetFilter() throws NoSuchFieldException {
setField(filterService, "hourTypeRepository", hourTypeRepository);
setField(filterService, "projectRepository", projectRepository);
setField(filterService, "departmentRepository", departmentRepository);
Filter currentFilter = new Filter();
RangePeriodSelector currentPeriodSelector = new RangePeriodSelector(new Period(new Date(1), new Date(2)));
currentFilter.setRangePeriodSelector(currentPeriodSelector);
Employee employee = new Employee("user");
expect(departmentRepository.getDepartments()).andReturn(Collections.emptyList());
expect(hourTypeRepository.getAll()).andReturn(Collections.emptyList());
expect(projectRepository.getActiveAndReportedProjects(employee, currentFilter.getPeriod())).andReturn(Collections.emptyList());
replay(departmentRepository, hourTypeRepository, projectRepository);
Filter actual = filterService.createPersonalTimesheetFilter(currentFilter, employee);
verify(departmentRepository, hourTypeRepository, projectRepository);
assertEquals(currentFilter.getPeriod(), actual.getPeriod());
assertEquals(1, actual.getEmployees().size());
assertEquals(employee, actual.getEmployees().get(0));
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotificatePmAboutTimeProblems.
@Test
public void testNotificatePmAboutTimeProblems() throws MessagingException, NoSuchFieldException {
notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("getProjects", List.class).addMockedMethod("getProjectManagers", Collection.class).createMock();
setMockServices(notificationManager);
Employee employee = new Employee("iivanov");
Employee pm = new Employee("ppetrov");
pm.setEmail("ppetrov@mail.com");
Project project = createProject(1L, employee);
List<Employee> employees = Arrays.asList(employee);
List<Project> projects = Arrays.asList(project);
Map<Employee, Map<Date, BigDecimal>> timeProblems = new HashMap<Employee, Map<Date, BigDecimal>>();
timeProblems.put(employee, new HashMap<Date, BigDecimal>());
Period period = new Period();
String comment = "comment";
String subject = "subject";
String body = "body";
expect(notificationManager.getProjects(employees)).andReturn(projects);
expect(notificationManager.getProjectManagers(projects)).andReturn(Sets.newHashSet(pm));
expect(hourTypeRepository.findActual()).andReturn(new HourType());
expect(workTimeService.getApprovedWorkTimeProblems(period, employees)).andReturn(timeProblems);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY_FOR_PM.getFileName()), anyObject(Map.class))).andReturn(body);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
mailingEngine.sendAsync("ppetrov@mail.com", new Mail(subject, body));
replay(notificationManager, hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
notificationManager.notificatePmAboutTimeProblems(employees, period, comment);
verify(notificationManager, hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotificateAboutOwnTimeProblems.
@Test
public void testNotificateAboutOwnTimeProblems() throws MessagingException, NoSuchFieldException {
setMockServices(notificationManager);
Employee employee = new Employee("iivanov");
employee.setEmail("iivanov@mail.com");
List<Employee> employees = Arrays.asList(employee);
Map<Employee, Map<Date, BigDecimal>> timeProblems = new HashMap<Employee, Map<Date, BigDecimal>>();
timeProblems.put(employee, new HashMap<Date, BigDecimal>());
Period period = new Period();
String comment = "comment";
String subject = "subject";
String body = "body";
expect(hourTypeRepository.findActual()).andReturn(new HourType());
expect(workTimeService.getApprovedWorkTimeProblems(period, employees)).andReturn(timeProblems);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY.getFileName()), anyObject(Map.class))).andReturn(body);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
mailingEngine.sendAsync("iivanov@mail.com", new Mail(subject, body));
replay(hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
notificationManager.notificateAboutOwnTimeProblems(employees, period, comment);
verify(hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetApprovedActualHours_ifEmployeesIsEmpty.
@Test
public void testGetApprovedActualHours_ifEmployeesIsEmpty() {
Period period = new Period();
List<Employee> employees = new ArrayList<>();
List<Hours> actual = hoursRepository.getApprovedActualHours(employees, period);
assertTrue(actual.isEmpty());
}
Aggregations