use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetManagersForApproveByEmployee_ifApproved.
@Test
public void testGetManagersForApproveByEmployee_ifApproved() {
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);
Hours hours1 = createHours(project1, employee, getOffsetDate(2), actualType, new BigDecimal(8), false);
Hours hours2 = createHours(project2, employee, getOffsetDate(2), actualType, new BigDecimal(8), true);
entityManager.persist(manager1);
entityManager.persist(manager2);
entityManager.persist(actualType);
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(manager1), actual.get(employee));
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursRepositoryTest method testUpdate.
@Test
public void testUpdate() throws Exception {
Employee employee = new Employee("employe");
Project project = new Project();
HourType hourType = new HourType();
Hours hours = new Hours(project, sdf.parse("1-01-2015"), employee, hourType);
entityManager.persist(project);
entityManager.persist(employee);
entityManager.persist(hourType);
entityManager.persist(hours);
hours.setQuantity(BigDecimal.TEN);
Hours actual = hoursRepository.update(hours);
assertEquals(BigDecimal.TEN, actual.getQuantity());
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualTimeByEmployeeAndApproval_byEmployees.
@Test
public void testGetActualTimeByEmployeeAndApproval_byEmployees() {
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(2), actualType, new BigDecimal(7));
Hours hours2 = createHours(project, employee2, getOffsetDate(2), actualType, new BigDecimal(8));
entityManager.persist(employee1);
entityManager.persist(employee2);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours1);
entityManager.persist(hours2);
Map<Employee, Map<Boolean, BigDecimal>> actual = hoursRepository.getActualTimeByEmployeeAndApproval(Arrays.asList(employee1), period);
assertEquals(1, actual.size());
assertEquals(7.0, actual.get(employee1).get(false).doubleValue(), 0.0);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetManagersForApproveByEmployee_byPeriod.
@Test
public void testGetManagersForApproveByEmployee_byPeriod() {
Date start = new Date();
Date finish = getOffsetDate(3);
Period period = new Period(start, finish);
Employee manager1 = new Employee("manager1");
Employee manager2 = new Employee("manager2");
Employee manager3 = new Employee("manager3");
Employee manager4 = new Employee("manager4");
Employee manager5 = new Employee("manager5");
Project project1 = new Project();
project1.setManagers(Arrays.asList(manager1));
Project project2 = new Project();
project2.setManagers(Arrays.asList(manager2));
Project project3 = new Project();
project3.setManagers(Arrays.asList(manager3));
Project project4 = new Project();
project4.setManagers(Arrays.asList(manager4));
Project project5 = new Project();
project5.setManagers(Arrays.asList(manager5));
Employee employee = new Employee("employee");
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
Hours hours1 = createHours(project1, employee, getOffsetDate(-1), actualType, new BigDecimal(8));
Hours hours2 = createHours(project2, employee, start, actualType, new BigDecimal(8));
Hours hours3 = createHours(project3, employee, getOffsetDate(2), actualType, new BigDecimal(8));
Hours hours4 = createHours(project4, employee, finish, actualType, new BigDecimal(8));
Hours hours5 = createHours(project5, employee, getOffsetDate(4), actualType, new BigDecimal(8));
entityManager.persist(manager1);
entityManager.persist(manager2);
entityManager.persist(manager3);
entityManager.persist(manager4);
entityManager.persist(manager5);
entityManager.persist(actualType);
entityManager.persist(employee);
entityManager.persist(project1);
entityManager.persist(project2);
entityManager.persist(project3);
entityManager.persist(project4);
entityManager.persist(project5);
entityManager.persist(hours1);
entityManager.persist(hours2);
entityManager.persist(hours3);
entityManager.persist(hours4);
entityManager.persist(hours5);
Map<Employee, List<Employee>> actual = hoursRepository.getManagersForApproveByEmployee(Arrays.asList(employee), period);
ListAssert.assertEquals(Arrays.asList(manager2, manager3, manager4), actual.get(employee));
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHours_ifEmployeesIsEmpty.
@Test
public void testGetActualHours_ifEmployeesIsEmpty() 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 hours1 = createHours(project, employee, getOffsetDate(1), actualType, quantity);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours1);
List<Hours> actuals = hoursRepository.getActualHours(Collections.emptyList(), period, false);
assertTrue(actuals.isEmpty());
}
Aggregations