use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetApprovedActualHoursSum_ifHoursForFinishPeriod.
@Test
public void testGetApprovedActualHoursSum_ifHoursForFinishPeriod() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
Employee employee = new Employee("expected 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);
hours.setApproved(true);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours);
BigDecimal actual = hoursRepository.getApprovedActualHoursSum(employee, period);
assertEquals(new BigDecimal("8.00"), actual);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetHours_FilterHasProjectsAndHasNoHourTypes.
@Test
public void testGetHours_FilterHasProjectsAndHasNoHourTypes() {
HourType hourType = new HourType("1");
List<HourType> hourTypes = Collections.singletonList(hourType);
Project project = new Project();
project.setAccountableHours(hourTypes);
Hours hour = new Hours(project, new Date(), null, hourType);
entityManager.persist(hourType);
entityManager.persist(project);
entityManager.persist(hour);
RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(createPeriod(-1, 1));
Filter filter = new Filter();
filter.setRangePeriodSelector(rangePeriodSelector);
filter.setHourTypes(Collections.emptyList());
filter.setProjects(Collections.singletonList(project));
List<Hours> actual = hoursRepository.getHours(filter);
List<Hours> expected = Collections.singletonList(hour);
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetApprovedActualHoursSum_unexpectedEmployee.
@Test
public void testGetApprovedActualHoursSum_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);
BigDecimal actual = hoursRepository.getApprovedActualHoursSum(expectedEmployee, period);
assertEquals(BigDecimal.ZERO, actual);
}
use of com.artezio.arttime.datamodel.HourType 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.HourType 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);
}
Aggregations