Search in sources :

Example 46 with HourType

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

the class HoursRepositoryTest method testCreate.

@Test
public void testCreate() throws Exception {
    Employee employee = new Employee("employe");
    Project project = new Project();
    HourType hourType = new HourType();
    entityManager.persist(project);
    entityManager.persist(employee);
    entityManager.persist(hourType);
    Hours hours = new Hours(project, sdf.parse("1-01-2015"), employee, hourType);
    Hours actual = hoursRepository.create(hours);
    assertNotNull(actual.getId());
}
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 47 with HourType

use of com.artezio.arttime.datamodel.HourType 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);
}
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) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 48 with HourType

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

the class HoursRepositoryTest method testGetActualTimeByEmployeeAndApproval_byPeriod.

@Test
public void testGetActualTimeByEmployeeAndApproval_byPeriod() {
    Date start = new Date();
    Date finish = getOffsetDate(3);
    Period period = new Period(start, finish);
    Project project = new Project();
    Employee employee = new Employee("employee");
    HourType actualType = new HourType("actual type");
    actualType.setActualTime(true);
    BigDecimal quantity = new BigDecimal(8);
    Hours hours1 = createHours(project, employee, getOffsetDate(-1), actualType, quantity);
    Hours hours2 = createHours(project, employee, start, actualType, quantity);
    Hours hours3 = createHours(project, employee, getOffsetDate(2), actualType, quantity);
    Hours hours4 = createHours(project, employee, finish, actualType, quantity);
    Hours hours5 = createHours(project, employee, getOffsetDate(4), actualType, quantity);
    entityManager.persist(employee);
    entityManager.persist(project);
    entityManager.persist(actualType);
    entityManager.persist(hours1);
    entityManager.persist(hours2);
    entityManager.persist(hours3);
    entityManager.persist(hours4);
    entityManager.persist(hours5);
    Map<Employee, Map<Boolean, BigDecimal>> actual = hoursRepository.getActualTimeByEmployeeAndApproval(Arrays.asList(employee), period);
    assertEquals(24.0, actual.get(employee).get(false).doubleValue(), 0.0);
}
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) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 49 with HourType

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

the class HoursRepositoryTest method testGetManagersForApproveByEmployee_ifQuantityIsNull.

@Test
public void testGetManagersForApproveByEmployee_ifQuantityIsNull() {
    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 employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    HourType actualType = new HourType("actual type");
    actualType.setActualTime(true);
    Hours hours1 = createHours(project1, employee1, getOffsetDate(2), actualType, new BigDecimal(8));
    Hours hours2 = createHours(project2, employee1, getOffsetDate(2), actualType, null);
    Hours hours3 = createHours(project1, employee2, getOffsetDate(2), actualType, null);
    entityManager.persist(manager1);
    entityManager.persist(manager2);
    entityManager.persist(actualType);
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    entityManager.persist(project1);
    entityManager.persist(project2);
    entityManager.persist(hours1);
    entityManager.persist(hours2);
    entityManager.persist(hours3);
    Map<Employee, List<Employee>> actual = hoursRepository.getManagersForApproveByEmployee(Arrays.asList(employee1, employee2), period);
    assertEquals(1, actual.size());
    ListAssert.assertEquals(Arrays.asList(manager1), actual.get(employee1));
}
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) 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)

Example 50 with HourType

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

the class HoursRepositoryTest method testGetActualTimeByEmployeeAndApproval_ifNotActualTime.

@Test
public void testGetActualTimeByEmployeeAndApproval_ifNotActualTime() {
    Date start = new Date();
    Date finish = getOffsetDate(3);
    Period period = new Period(start, finish);
    Project project = new Project();
    Employee employee = new Employee("employee");
    HourType actualType = new HourType("actual type");
    actualType.setActualTime(true);
    HourType notActualType = new HourType("not actual type");
    Hours hours1 = createHours(project, employee, getOffsetDate(2), notActualType, new BigDecimal(7));
    Hours hours2 = createHours(project, employee, getOffsetDate(2), actualType, new BigDecimal(8));
    entityManager.persist(employee);
    entityManager.persist(project);
    entityManager.persist(actualType);
    entityManager.persist(notActualType);
    entityManager.persist(hours1);
    entityManager.persist(hours2);
    Map<Employee, Map<Boolean, BigDecimal>> actual = hoursRepository.getActualTimeByEmployeeAndApproval(Arrays.asList(employee), period);
    assertEquals(8.0, actual.get(employee).get(false).doubleValue(), 0.0);
}
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) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

HourType (com.artezio.arttime.datamodel.HourType)172 Test (org.junit.Test)158 Project (com.artezio.arttime.datamodel.Project)120 Employee (com.artezio.arttime.datamodel.Employee)115 Hours (com.artezio.arttime.datamodel.Hours)103 Date (java.util.Date)60 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)54 Period (com.artezio.arttime.datamodel.Period)45 BigDecimal (java.math.BigDecimal)41 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 HashMap (java.util.HashMap)16 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 Map (java.util.Map)11 Arrays.asList (java.util.Arrays.asList)10 List (java.util.List)10 Filter (com.artezio.arttime.filter.Filter)7 Mail (com.artezio.arttime.services.mailing.Mail)7 ArrayList (java.util.ArrayList)7 HourTypeRepository (com.artezio.arttime.repositories.HourTypeRepository)6 RangePeriodSelector (com.artezio.arttime.web.criteria.RangePeriodSelector)6