use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyAboutIncorrectTimesheet.
@Test
public void testNotifyAboutIncorrectTimesheet() throws Exception {
notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("notifyAboutIncorrectTimesheet", Employee.class, Period.class).createMock();
setMockServices(notificationManager);
Employee goodEmployee = new Employee("good_employee");
Employee badEmployee1 = new Employee("bad_employee1");
Employee badEmployee2 = new Employee("bad_employee2");
List<Employee> employees = Arrays.asList(goodEmployee, badEmployee1, badEmployee2);
Date start = new GregorianCalendar(2020, 1, 1).getTime();
Date finish = new GregorianCalendar(2020, 1, 29).getTime();
Period period = new Period(start, finish);
expect(workTimeService.getRequiredWorkHours(goodEmployee, period)).andReturn(BigDecimal.valueOf(160));
expect(workTimeService.getRequiredWorkHours(badEmployee1, period)).andReturn(BigDecimal.valueOf(160));
expect(workTimeService.getRequiredWorkHours(badEmployee2, period)).andReturn(BigDecimal.valueOf(160));
expect(workTimeService.getActualWorkHours(goodEmployee, period)).andReturn(BigDecimal.valueOf(160));
expect(workTimeService.getActualWorkHours(badEmployee1, period)).andReturn(BigDecimal.valueOf(8));
expect(workTimeService.getActualWorkHours(badEmployee2, period)).andReturn(BigDecimal.valueOf(168));
notificationManager.notifyAboutIncorrectTimesheet(badEmployee1, period);
notificationManager.notifyAboutIncorrectTimesheet(badEmployee2, period);
replay(notificationManager, workTimeService);
notificationManager.notifyAboutIncorrectTimesheet(employees, period);
verify(notificationManager, workTimeService);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyAboutUnapprovedHours.
@Test
public void testNotifyAboutUnapprovedHours() throws Exception {
notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("notifyAboutUnapprovedHours", Employee.class, Period.class).createMock();
setMockServices(notificationManager);
Date start = new GregorianCalendar(2020, 1, 1).getTime();
Date finish = new GregorianCalendar(2020, 1, 29).getTime();
Period period = new Period(start, finish);
Employee manager1 = new Employee("user1");
Employee manager2 = new Employee("user2");
;
List<Employee> managers = Arrays.asList(manager1, manager2);
notificationManager.notifyAboutUnapprovedHours(manager1, period);
notificationManager.notifyAboutUnapprovedHours(manager2, period);
replay(notificationManager);
notificationManager.notifyAboutUnapprovedHours(managers, period);
verify(notificationManager);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyAboutOwnTimeProblems.
@Test
public void testNotifyAboutOwnTimeProblems() throws 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<>();
timeProblems.put(employee, new HashMap<>());
Period period = new Period();
String comment = "comment";
String subject = "subject";
String body = "body";
EasyMock.expect(hourTypeService.findActualTime()).andReturn(new HourType());
EasyMock.expect(workTimeService.getWorkTimeDeviations(period, employees)).andReturn(timeProblems);
EasyMock.expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY.getFileName()), anyObject(Map.class))).andReturn(body);
EasyMock.expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
EasyMock.expect(settings.getSmtpUsername()).andReturn("username");
EasyMock.expect(settings.getSmtpSender()).andReturn("sender");
EasyMock.expect(settings.getApplicationBaseUrl()).andReturn("appHost");
mailingEngine.send(new Mail(subject, body, "sender", "iivanov@mail.com"));
String principalName = "someuser";
Principal principal = Mockito.mock(Principal.class);
Mockito.when(principal.getName()).thenReturn(principalName);
EasyMock.expect(employeeRepository.get(principalName)).andReturn(employee);
EasyMock.replay(hourTypeService, workTimeService, mailTemplateManager, mailingEngine, settings, employeeRepository, sessionContext);
notificationManager.notifyEmployees(employees, period, comment);
EasyMock.verify(hourTypeService, workTimeService, mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarServiceTest method testGetDays.
@Test
public void testGetDays() {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
Day day = new Day(new Date(), calendar);
expect(workdaysCalendarRepository.getSpecialDays(anyObject(), anyObject())).andReturn(new ArrayList<>());
replay(workdaysCalendarRepository);
List<Day> actual = workdaysCalendarService.getDays(calendar, period);
assertNotNull(actual);
assertEquals(3, actual.size());
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHours_ifHoursForFinishPeriod.
@Test
public void testGetActualHours_ifHoursForFinishPeriod() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
Employee employee = new Employee("employee");
Project project = new Project();
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
BigDecimal quantity = new BigDecimal(8);
Hours hours = createHours(project, employee, finish, actualType, quantity);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours);
List<Hours> actuals = hoursRepository.getActualHours(Collections.singletonList(employee), period, false);
assertEquals(Collections.singletonList(hours), actuals);
}
Aggregations