Search in sources :

Example 36 with Filter

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

the class IntegrationFacadeTest method testGetHours.

@Test
public void testGetHours() {
    List<Hours> expecteds = new ArrayList<>();
    Project project = new Project();
    project.setCode("TEST-PROJECT");
    Date from = new GregorianCalendar(2011, 1, 5).getTime();
    Date to = new GregorianCalendar(2011, 1, 15).getTime();
    Period period = new Period(from, to);
    Filter expectedFilter = new Filter();
    expectedFilter.setProjects(asList(project));
    expectedFilter.setApproved(null);
    RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(period);
    expectedFilter.setRangePeriodSelector(rangePeriodSelector);
    HoursSearchCriteria hoursSearchCriteria = new HoursSearchCriteria(from, to, true, asList("TEST-PROJECT"));
    Project anotherProject = new Project();
    anotherProject.setCode("OtherProject");
    List<Project> allProjects = Arrays.asList(project, anotherProject);
    expect(projectService.getAll()).andReturn(allProjects).anyTimes();
    EasyMock.expect(hoursService.getHours(expectedFilter)).andReturn(expecteds);
    EasyMock.replay(projectService, hoursService);
    List<Hours> actuals = facade.getHours(hoursSearchCriteria);
    verify(projectService, hoursService);
    assertSame(expecteds, actuals);
}
Also used : Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector) Test(org.junit.Test)

Example 37 with Filter

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

the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifEmployeesAreEmpty.

@Test
public void testGetEmployeesByDepartments_ifEmployeesAreEmpty() {
    Employee employee1 = new Employee("employee1", "test1", "test1", "department1");
    Employee employee2 = new Employee("employee2", "test2", "test2", "department2");
    Filter filter = new Filter();
    filter.setEmployees(Collections.emptyList());
    filter.setDepartments(Arrays.asList("department1", "department2"));
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    List<Employee> expected = filter.getEmployees();
    List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
    ListAssert.assertEquals(expected, actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 38 with Filter

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

the class EmployeeRepositoryTest method testGetEmployeesByDepartments.

@Test
public void testGetEmployeesByDepartments() {
    Employee employee1 = new Employee("employee1");
    employee1.setDepartment("department1");
    Employee employee2 = new Employee("employee2");
    employee2.setDepartment("department2");
    Employee employee3 = new Employee("employee3");
    employee3.setDepartment("department3");
    Project project1 = new Project();
    project1.addTeamMember(employee1);
    project1.addTeamMember(employee2);
    Project project2 = new Project();
    project2.addTeamMember(employee1);
    project2.addTeamMember(employee3);
    entityManager.persist(project1);
    entityManager.persist(project2);
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    entityManager.persist(employee3);
    Filter filter = new Filter();
    filter.setProjects(Arrays.asList(project1, project2));
    filter.setEmployees(Arrays.asList(employee1, employee2, employee3));
    filter.setDepartments(Arrays.asList("department1", "department2", "department3"));
    List<Employee> expected = Arrays.asList(employee1, employee2, employee3);
    List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
    ListAssert.assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 39 with Filter

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

the class FilterRepositoryTest method testCreate.

@Test
public void testCreate() {
    Filter expected = new Filter();
    Filter actual = filterRepository.create(expected);
    assertSame(expected, actual);
    assertNotNull(actual.getId());
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 40 with Filter

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

the class FilterRepositoryTest method testUpdate.

@Test
public void testUpdate() {
    Filter expected = new Filter();
    expected.setName("old filter name");
    entityManager.persist(expected);
    entityManager.flush();
    entityManager.clear();
    expected.setName("new filter name");
    filterRepository.update(expected);
    Filter actual = entityManager.find(Filter.class, expected.getId());
    assertEquals(expected.getName(), actual.getName());
}
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