use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHours_noHoursInPeriod.
@Test
public void testGetActualHours_noHoursInPeriod() 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(3), actualType, quantity);
Hours hours2 = createHours(project, employee, getOffsetDate(-1), actualType, quantity);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours1);
entityManager.persist(hours2);
List<Hours> actuals = hoursRepository.getActualHours(Collections.singletonList(employee), period, false);
assertTrue(actuals.isEmpty());
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHoursSum.
@Test
public void testGetActualHoursSum() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Employee employee = new Employee("username");
Date start = sdf.parse("2014-11-01");
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
Project project = createActiveProjectWithTeamMember(employee, calendar);
HourType actualType = new HourType("actual");
actualType.setActualTime(true);
HourType notActualType = new HourType("not_actual");
Hours approved = createHours(project, employee, sdf.parse("2014-11-02"), actualType, new BigDecimal("8"));
approved.setApproved(true);
Hours notApproved1 = createHours(project, employee, sdf.parse("2014-11-03"), actualType, new BigDecimal("8"));
Hours notApproved2 = createHours(project, employee, sdf.parse("2014-11-04"), actualType, new BigDecimal("8"));
Hours notActual = createHours(project, employee, sdf.parse("2014-11-05"), notActualType, new BigDecimal("8"));
Hours beforePeriod = createHours(project, employee, sdf.parse("2014-10-31"), actualType, new BigDecimal("8"));
entityManager.persist(actualType);
entityManager.persist(notActualType);
entityManager.persist(approved);
entityManager.persist(notApproved1);
entityManager.persist(notApproved2);
entityManager.persist(notActual);
entityManager.persist(beforePeriod);
Period period = new Period(start, sdf.parse("2014-11-30"));
BigDecimal actual = hoursRepository.getActualHoursSum(employee, period);
assertEquals(new BigDecimal("24.00"), actual);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHours_ifHoursForStartPeriod.
@Test
public void testGetActualHours_ifHoursForStartPeriod() 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, start, 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);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHours_unexpectedEmployee.
@Test
public void testGetActualHours_unexpectedEmployee() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
Employee expectedEmployee = new Employee("expected employee");
Employee unexpectedEmployee = new Employee("unexpected employee");
Project project = new Project();
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
BigDecimal quantity = new BigDecimal(8);
Hours hours = createHours(project, unexpectedEmployee, getOffsetDate(1), actualType, quantity);
entityManager.persist(expectedEmployee);
entityManager.persist(unexpectedEmployee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours);
List<Hours> actuals = hoursRepository.getActualHours(Collections.singletonList(expectedEmployee), period, false);
assertTrue(actuals.isEmpty());
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetApprovedActualHoursSum.
@Test
public void testGetApprovedActualHoursSum() 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 quantity1 = new BigDecimal(8);
BigDecimal quantity2 = new BigDecimal(8);
Hours hours1 = createHours(project, employee, getOffsetDate(1), actualType, quantity1);
Hours hours2 = createHours(project, employee, getOffsetDate(2), actualType, quantity2);
hours1.setApproved(true);
hours2.setApproved(true);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours1);
entityManager.persist(hours2);
BigDecimal actual = hoursRepository.getApprovedActualHoursSum(employee, period);
assertEquals(new BigDecimal("16.00"), actual);
}
Aggregations