Search in sources :

Example 6 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class WorkTimeServiceTest method testGetEmployees_FilterHasNoEmployeesAndHasNoDepartments.

@Test
public void testGetEmployees_FilterHasNoEmployeesAndHasNoDepartments() throws NoSuchFieldException {
    Employee emp1 = new Employee();
    emp1.setDepartment("dep1");
    Employee emp2 = new Employee();
    emp2.setDepartment("dep2");
    List<Employee> employees = Arrays.asList(emp1, emp2);
    Filter filter = new Filter();
    filter.setEmployees(Collections.emptyList());
    filter.setDepartments(Collections.emptyList());
    setField(workTimeService, "employeeRepository", employeeRepository);
    expect(employeeRepository.getEmployeesByDepartments(filter)).andReturn(employees);
    replay(employeeRepository);
    List<Employee> actual = workTimeService.getEmployees(filter);
    ListAssert.assertEquals(employees, actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 7 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class WorkTimeServiceTest method testGetEmployees_FilterHasEmployeesCorrespondingToDepartments.

@Test
public void testGetEmployees_FilterHasEmployeesCorrespondingToDepartments() {
    Employee emp1 = new Employee();
    emp1.setDepartment("dep1");
    Employee emp2 = new Employee();
    emp2.setDepartment("dep2");
    List<Employee> employees = Arrays.asList(emp1, emp2);
    List<String> departments = Arrays.asList("dep1", "dep2");
    Filter filter = new Filter();
    filter.setEmployees(employees);
    filter.setDepartments(departments);
    List<Employee> expected = filter.getEmployees();
    List<Employee> actual = workTimeService.getEmployees(filter);
    ListAssert.assertEquals(expected, actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 8 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class WorkTimeServiceTest method testGetApprovedWorkTimeProblems_existProblems.

@Test
public void testGetApprovedWorkTimeProblems_existProblems() throws NoSuchFieldException {
    Date start = new Date();
    Date finish = getOffsetDate(1);
    Period period = new Period(start, finish);
    WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
    Employee employee = new Employee("employee", "name", "lastname", "mail");
    employee.setCalendar(calendar);
    employee.setWorkLoad(100);
    List<Employee> employees = Arrays.asList(employee);
    Day day1 = new Day(new Date(), calendar, true);
    Day day2 = new Day(getOffsetDate(1), calendar, true);
    Project project = new Project();
    project.addTeamMember(employee);
    HourType actualType = new HourType("actual type");
    actualType.setActualTime(true);
    BigDecimal quantity1 = new BigDecimal(3);
    BigDecimal quantity2 = new BigDecimal(10);
    Hours hours1 = createHours(project, employee, new Date(), actualType, quantity1);
    Hours hours2 = createHours(project, employee, getOffsetDate(1), actualType, quantity2);
    hours1.setApproved(true);
    hours2.setApproved(true);
    Filter filter = new Filter();
    filter.setEmployees(employees);
    filter.setCustomPeriod(period);
    entityManager.persist(employee);
    entityManager.persist(calendar);
    entityManager.persist(actualType);
    entityManager.persist(project);
    entityManager.persist(hours1);
    entityManager.persist(hours2);
    entityManager.persist(day1);
    entityManager.persist(day2);
    entityManager.flush();
    entityManager.clear();
    setField(workTimeService, "employeeRepository", employeeRepository);
    expect(employeeRepository.getEmployeesByDepartments(filter)).andReturn(employees);
    replay(employeeRepository);
    List<WorkTimeService.Efforts> actuals = workTimeService.getEmployeesTimeProblems(filter);
    WorkTimeService.Efforts actual = actuals.get(0);
    assertEquals(1, actuals.size());
    assertEquals(employee, actual.getEmployee());
    assertEquals(new BigDecimal("16.00"), actual.getRequiredTime());
    assertEquals(new BigDecimal("13.00"), actual.getApprovedTime());
    assertEquals(new BigDecimal("-3.00"), actual.getTimeDeviation());
    assertEquals(BigDecimal.ZERO, actual.getUnapprovedTime());
}
Also used : Efforts(com.artezio.arttime.services.WorkTimeService.Efforts) BigDecimal(java.math.BigDecimal) Filter(com.artezio.arttime.filter.Filter) Efforts(com.artezio.arttime.services.WorkTimeService.Efforts) Test(org.junit.Test)

Example 9 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class WorkTimeServiceTest method testGetEmployees_FilterHasNoEmployeesAndHasDepartments.

@Test
public void testGetEmployees_FilterHasNoEmployeesAndHasDepartments() throws NoSuchFieldException {
    Employee emp1 = new Employee();
    emp1.setDepartment("dep1");
    Employee emp2 = new Employee();
    emp2.setDepartment("dep2");
    List<Employee> employees = Arrays.asList(emp1, emp2);
    List<String> departments = Arrays.asList("dep1", "dep2");
    Filter filter = new Filter();
    filter.setEmployees(Collections.emptyList());
    filter.setDepartments(departments);
    setField(workTimeService, "employeeRepository", employeeRepository);
    expect(employeeRepository.getEmployeesByDepartments(filter)).andReturn(employees);
    replay(employeeRepository);
    List<Employee> actual = workTimeService.getEmployees(filter);
    ListAssert.assertEquals(employees, actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 10 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class WorkTimeServiceTest method testGetEmployees_FilterHasEmployeesNotCorrespondingToDepartments.

@Test
public void testGetEmployees_FilterHasEmployeesNotCorrespondingToDepartments() {
    Employee emp1 = new Employee();
    emp1.setDepartment("dep1");
    Employee emp2 = new Employee();
    emp2.setDepartment("dep2");
    List<Employee> employees = Arrays.asList(emp1, emp2);
    List<String> departments = Arrays.asList("dep3", "dep4");
    Filter filter = new Filter();
    filter.setEmployees(employees);
    filter.setDepartments(departments);
    List<Employee> result = workTimeService.getEmployees(filter);
    assertTrue(result.isEmpty());
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Aggregations

Filter (com.artezio.arttime.filter.Filter)126 Test (org.junit.Test)110 Project (com.artezio.arttime.datamodel.Project)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 Employee (com.artezio.arttime.datamodel.Employee)24 RangePeriodSelector (com.artezio.arttime.web.criteria.RangePeriodSelector)16 Date (java.util.Date)9 BigDecimal (java.math.BigDecimal)8 Hours (com.artezio.arttime.datamodel.Hours)7 Arrays.asList (java.util.Arrays.asList)7 List (java.util.List)7 HourType (com.artezio.arttime.datamodel.HourType)5 Efforts (com.artezio.arttime.services.WorkTimeService.Efforts)5 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)5 ArrayList (java.util.ArrayList)4 Collections.emptyList (java.util.Collections.emptyList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Period (com.artezio.arttime.datamodel.Period)3 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)3