use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class HoursRepositoryTest method testFindHours_whenNoSuchHoursExist_expectNull.
@Test
public void testFindHours_whenNoSuchHoursExist_expectNull() throws Exception {
Employee employee = new Employee("employ");
Project project = new Project();
project.setCode("SomeCode");
HourType hourType = new HourType();
Date date = getOffsetDate(1);
Hours persisted = new Hours(project, date, employee, hourType);
entityManager.persist(project);
entityManager.persist(employee);
entityManager.persist(hourType);
entityManager.persist(persisted);
Hours actual = hoursRepository.findHours("Invalid name", project.getCode() + "XXX", hourType.getId() - 1, date);
assertNull(actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHours_unexpectedHourType.
@Test
public void testGetActualHours_unexpectedHourType() 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);
HourType unexpectedType = new HourType("type");
actualType.setActualTime(false);
BigDecimal quantity = new BigDecimal(8);
Hours hours = createHours(project, employee, getOffsetDate(1), unexpectedType, quantity);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(unexpectedType);
entityManager.persist(hours);
List<Hours> actuals = hoursRepository.getActualHours(Collections.singletonList(employee), period, false);
assertTrue(actuals.isEmpty());
}
use of com.artezio.arttime.datamodel.Project 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);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetApprovedActualHoursSum_unexpectedHourType.
@Test
public void testGetApprovedActualHoursSum_unexpectedHourType() 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);
HourType unexpectedType = new HourType("type");
actualType.setActualTime(false);
BigDecimal quantity = new BigDecimal(8);
Hours hours = createHours(project, employee, getOffsetDate(1), unexpectedType, quantity);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(unexpectedType);
entityManager.persist(hours);
BigDecimal actual = hoursRepository.getApprovedActualHoursSum(employee, period);
assertEquals(BigDecimal.ZERO, actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetHours_FilterHasNoProjectsAndHasHourTypes.
@Test
public void testGetHours_FilterHasNoProjectsAndHasHourTypes() {
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(hourTypes);
filter.setProjects(Collections.emptyList());
List<Hours> actual = hoursRepository.getHours(filter);
List<Hours> expected = Collections.singletonList(hour);
assertEquals(expected, actual);
}
Aggregations