Search in sources :

Example 91 with Employee

use of com.artezio.arttime.datamodel.Employee 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);
}
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 92 with Employee

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

the class HoursRepositoryTest method testGetApprovedActualHoursSum_ifHoursForStartPeriod.

@Test
public void testGetApprovedActualHoursSum_ifHoursForStartPeriod() 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, start, 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);
}
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 93 with Employee

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

the class HoursRepositoryTest method testGetDailyApprovedHoursSum.

@Test
public void testGetDailyApprovedHoursSum() {
    Employee employee = new Employee("employee");
    Project project = new Project();
    HourType actualTime = new HourType("actual");
    actualTime.setActualTime(true);
    Date date = getOffsetDate(-1);
    Hours hours1 = new Hours(project, date, employee, actualTime);
    hours1.setQuantity(new BigDecimal(1));
    Hours hours2 = new Hours(project, getOffsetDate(0), employee, actualTime);
    hours2.setQuantity(new BigDecimal(2));
    Hours hours3 = new Hours(project, getOffsetDate(1), employee, actualTime);
    hours3.setQuantity(new BigDecimal(3));
    Hours hours4 = new Hours(project, getOffsetDate(2), employee, actualTime);
    hours4.setQuantity(new BigDecimal(4));
    List<Hours> hours = asList(hours1, hours2, hours3, hours4);
    BigDecimal actual = hoursRepository.getDailyApprovedHoursSum(hours, date);
    assertEquals(new BigDecimal(1), 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) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 94 with Employee

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

the class WorkdaysCalendarRepositoryTest method testFindDefaultCalendar_ifNotFound.

@Test
public void testFindDefaultCalendar_ifNotFound() {
    Employee employee = new Employee();
    WorkdaysCalendar actual = workdaysCalendarRepository.findDefaultCalendar(employee);
    assertNull(actual);
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 95 with Employee

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

the class WorkdaysCalendarRepositoryTest method testRemoveWorkdaysCalendar_RemoveForbidden.

@Test(expected = PersistenceException.class)
public void testRemoveWorkdaysCalendar_RemoveForbidden() {
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
    Project project = new Project();
    Employee employee = new Employee("employee");
    employee.setCalendar(workdaysCalendar);
    project.addTeamMember(employee);
    entityManager.persist(workdaysCalendar);
    entityManager.persist(employee);
    entityManager.persist(project);
    workdaysCalendarRepository.remove(workdaysCalendar);
    entityManager.flush();
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Aggregations

Employee (com.artezio.arttime.datamodel.Employee)201 Test (org.junit.Test)173 Project (com.artezio.arttime.datamodel.Project)121 HourType (com.artezio.arttime.datamodel.HourType)74 Hours (com.artezio.arttime.datamodel.Hours)65 Date (java.util.Date)39 BigDecimal (java.math.BigDecimal)33 Period (com.artezio.arttime.datamodel.Period)28 Filter (com.artezio.arttime.filter.Filter)23 ArrayList (java.util.ArrayList)20 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)19 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)18 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)15 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)13 HashMap (java.util.HashMap)12 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)7 Mail (com.artezio.arttime.services.mailing.Mail)7 ProjectRepository (com.artezio.arttime.services.repositories.ProjectRepository)7 List (java.util.List)7 Map (java.util.Map)7