Search in sources :

Example 56 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class HoursRepositoryTest method testFindHours.

@Test
public void testFindHours() throws Exception {
    Employee employee = new Employee("employ");
    Project project = new Project();
    project.setCode("PrCode");
    HourType hourType = new HourType();
    Date date = getOffsetDate(1);
    Hours expected = new Hours(project, date, employee, hourType);
    entityManager.persist(project);
    entityManager.persist(employee);
    entityManager.persist(hourType);
    entityManager.persist(expected);
    Hours actual = hoursRepository.findHours(employee.getUserName(), project.getCode(), hourType.getId(), date);
    assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 57 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class HoursRepositoryTest method testRemove.

@Test
public void testRemove() 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);
    hoursRepository.remove(hours);
    Hours actual = entityManager.find(Hours.class, hours.getId());
    assertNull(actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Test(org.junit.Test)

Example 58 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class HoursRepositoryTest method testGetActualHours_ifHoursForFinishPeriod.

@Test
public void testGetActualHours_ifHoursForFinishPeriod() 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, finish, 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);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 59 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class HoursRepositoryTest method createActiveProjectWithTeamMember.

private Project createActiveProjectWithTeamMember(Employee employee, WorkdaysCalendar calendar) {
    employee.setCalendar(calendar);
    Project project = new Project();
    project.addTeamMember(employee);
    project.setStatus(Status.ACTIVE);
    entityManager.persist(calendar);
    entityManager.persist(employee);
    entityManager.persist(project);
    return project;
}
Also used : Project(com.artezio.arttime.datamodel.Project)

Example 60 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class HoursRepositoryTest method testGetActualHoursLists.

@Test
public void testGetActualHoursLists() {
    Date start = new Date();
    Date finish = getOffsetDate(2);
    Period period = new Period(start, finish);
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    Employee employee3 = new Employee("employee3");
    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(employee3);
    entityManager.persist(project);
    entityManager.persist(actualType);
    entityManager.persist(hours1);
    entityManager.persist(hours2);
    entityManager.persist(hours3);
    List<Employee> employees = asList(employee1, employee2, employee3);
    Map<Employee, List<Hours>> actualHours = hoursRepository.getActualHoursLists(employees, period, false);
    Map<Employee, List<Hours>> approvedActualHours = hoursRepository.getActualHoursLists(employees, period, true);
    ListAssert.assertEquals(asList(hours1, hours2), actualHours.get(employee1));
    ListAssert.assertEquals(Collections.singletonList(hours3), actualHours.get(employee2));
    assertTrue(actualHours.get(employee3).isEmpty());
    ListAssert.assertEquals(Collections.singletonList(hours1), approvedActualHours.get(employee1));
    ListAssert.assertEquals(Collections.singletonList(hours3), approvedActualHours.get(employee2));
    assertTrue(approvedActualHours.get(employee3).isEmpty());
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Project (com.artezio.arttime.datamodel.Project)310 Test (org.junit.Test)278 Employee (com.artezio.arttime.datamodel.Employee)195 HourType (com.artezio.arttime.datamodel.HourType)119 Hours (com.artezio.arttime.datamodel.Hours)108 Date (java.util.Date)61 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)56 Period (com.artezio.arttime.datamodel.Period)43 BigDecimal (java.math.BigDecimal)39 Filter (com.artezio.arttime.filter.Filter)33 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 ArrayList (java.util.ArrayList)18 Arrays.asList (java.util.Arrays.asList)18 ProjectRepository (com.artezio.arttime.repositories.ProjectRepository)17 List (java.util.List)17 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 HashMap (java.util.HashMap)13 Map (java.util.Map)11