use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testRequestReport.
@Test
public void testRequestReport() throws Exception {
setMockServices(notificationManager);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.REQUEST_REPORT_BODY.getFileName()), anyObject(Map.class))).andReturn("body");
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.REQUEST_REPORT_SUBJECT.getFileName()), anyObject(Map.class))).andReturn("subject");
Period period = new Period();
Employee pm = new Employee("ppetrov");
pm.setEmail("ppetrov@mail.com");
mailingEngine.send(new Mail("subject", "body", "ppetrov@mail.com", "iivanov@mail.com"));
String principalName = "someuser";
Principal principal = Mockito.mock(Principal.class);
Mockito.when(principal.getName()).thenReturn(principalName);
expect(sessionContext.getCallerPrincipal()).andReturn(principal);
expect(employeeRepository.get(principalName)).andReturn(pm);
expect(settings.getApplicationBaseUrl()).andReturn("appHost");
replay(mailTemplateManager, mailingEngine, employeeRepository, settings, sessionContext);
notificationManager.requestWorkTimeReport("iivanov@mail.com", period);
verify(mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetManagersForApproveByEmployee_ifNotActualTime.
@Test
public void testGetManagersForApproveByEmployee_ifNotActualTime() {
Date start = new Date();
Date finish = getOffsetDate(3);
Period period = new Period(start, finish);
Employee manager1 = new Employee("manager1");
Employee manager2 = new Employee("manager2");
Project project1 = new Project();
project1.setManagers(Arrays.asList(manager1));
Project project2 = new Project();
project2.setManagers(Arrays.asList(manager2));
Employee employee = new Employee("employee");
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
HourType notActualType = new HourType("not actual type");
Hours hours1 = createHours(project1, employee, getOffsetDate(2), notActualType, new BigDecimal(8));
Hours hours2 = createHours(project2, employee, getOffsetDate(2), actualType, new BigDecimal(8));
entityManager.persist(manager1);
entityManager.persist(manager2);
entityManager.persist(actualType);
entityManager.persist(notActualType);
entityManager.persist(employee);
entityManager.persist(project1);
entityManager.persist(project2);
entityManager.persist(hours1);
entityManager.persist(hours2);
Map<Employee, List<Employee>> actual = hoursRepository.getManagersForApproveByEmployee(Arrays.asList(employee), period);
ListAssert.assertEquals(Arrays.asList(manager2), actual.get(employee));
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualTimeByEmployeeAndApproval_ifQuantityIsNull.
@Test
public void testGetActualTimeByEmployeeAndApproval_ifQuantityIsNull() {
Date start = new Date();
Date finish = getOffsetDate(3);
Period period = new Period(start, finish);
Project project = new Project();
Employee employee1 = new Employee("employee1");
Employee employee2 = new Employee("employee2");
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
Hours hours1 = createHours(project, employee1, getOffsetDate(1), actualType, new BigDecimal(7));
Hours hours2 = createHours(project, employee1, getOffsetDate(2), actualType, null);
Hours hours3 = createHours(project, employee2, getOffsetDate(2), actualType, null);
entityManager.persist(employee1);
entityManager.persist(employee2);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours1);
entityManager.persist(hours2);
entityManager.persist(hours3);
Map<Employee, Map<Boolean, BigDecimal>> actual = hoursRepository.getActualTimeByEmployeeAndApproval(Arrays.asList(employee1, employee2), period);
assertEquals(1, actual.size());
assertEquals(7.0, actual.get(employee1).get(false).doubleValue(), 0.0);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetManagersForUnapprovedHours.
@Test
public void testGetManagersForUnapprovedHours() {
Date start = new GregorianCalendar(2020, 2, 1).getTime();
Date finish = new GregorianCalendar(2020, 2, 29).getTime();
Period period = new Period(start, finish);
Employee manager1 = new Employee("manager1");
Employee manager2 = new Employee("manager2");
Employee manager3 = new Employee("manager3");
Project project1 = new Project();
project1.setManagers(Arrays.asList(manager1, manager2));
Project project2 = new Project();
project2.setManagers(Arrays.asList(manager2, manager3));
Hours hours1 = new Hours();
hours1.setApproved(false);
hours1.setDate(new GregorianCalendar(2020, 2, 15).getTime());
hours1.setProject(project1);
hours1.setQuantity(BigDecimal.valueOf(8));
Hours hours2 = new Hours();
hours2.setApproved(false);
hours2.setDate(new GregorianCalendar(2020, 2, 10).getTime());
hours2.setProject(project2);
hours2.setQuantity(BigDecimal.valueOf(1));
entityManager.persist(manager1);
entityManager.persist(manager2);
entityManager.persist(manager3);
entityManager.persist(project1);
entityManager.persist(project2);
entityManager.persist(hours1);
entityManager.persist(hours2);
List<Employee> actual = hoursRepository.new HoursQuery(true).getManagers();
// List<Employee> actual = hoursRepository.getManagersForUnapprovedHours(period);
List<Employee> expected = Arrays.asList(manager1, manager2, manager3);
ListAssert.assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHours.
@Test
public void testGetActualHours() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
Employee employee1 = new Employee("employee1");
Employee employee2 = new Employee("employee2");
Project project = new Project();
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
BigDecimal quantity = new BigDecimal(8);
Hours hours1 = createHours(project, employee1, getOffsetDate(1), actualType, quantity);
Hours hours2 = createHours(project, employee1, getOffsetDate(2), actualType, quantity);
Hours hours3 = createHours(project, employee2, getOffsetDate(0), actualType, quantity);
hours1.setApproved(true);
hours2.setApproved(false);
hours3.setApproved(true);
entityManager.persist(employee1);
entityManager.persist(employee2);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours1);
entityManager.persist(hours2);
entityManager.persist(hours3);
List<Employee> employees = asList(employee1, employee2);
List<Hours> actualHours = hoursRepository.getActualHours(employees, period, false);
List<Hours> approvedActualHours = hoursRepository.getActualHours(employees, period, true);
ListAssert.assertEquals(asList(hours1, hours2, hours3), actualHours);
ListAssert.assertEquals(asList(hours1, hours3), approvedActualHours);
}
Aggregations