Search in sources :

Example 66 with Filter

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

the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifDepartmentsAreEmpty.

@Test
public void testGetEmployeesByDepartments_ifDepartmentsAreEmpty() {
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    Employee employee3 = new Employee("employee3");
    Filter filter = new Filter();
    filter.setEmployees(Arrays.asList(employee1, employee2, employee3));
    filter.setDepartments(Collections.emptyList());
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    entityManager.persist(employee3);
    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 67 with Filter

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

the class FilterRepositoryTest method testGetFiltersByOwner.

@Test
public void testGetFiltersByOwner() {
    Employee employee = new Employee("user1");
    Filter filter1 = createFilter("user1");
    Filter filter2 = createFilter("user2");
    entityManager.persist(filter1);
    entityManager.persist(filter2);
    List<Filter> expected = Arrays.asList(filter1);
    List<Filter> actual = filterRepository.getFilters(employee);
    ListAssert.assertEquals(expected, actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 68 with Filter

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

the class HoursRepositoryTest method testGetHours_FilterHasProjectsAndHasNoHourTypes.

@Test
public void testGetHours_FilterHasProjectsAndHasNoHourTypes() {
    HourType hourType = new HourType("1");
    List<HourType> hourTypes = Collections.singletonList(hourType);
    Project project = new Project();
    project.setAccountableHours(hourTypes);
    Hours hour = new Hours(project, new Date(), null, hourType);
    entityManager.persist(hourType);
    entityManager.persist(project);
    entityManager.persist(hour);
    RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(createPeriod(-1, 1));
    Filter filter = new Filter();
    filter.setRangePeriodSelector(rangePeriodSelector);
    filter.setHourTypes(Collections.emptyList());
    filter.setProjects(Collections.singletonList(project));
    List<Hours> actual = hoursRepository.getHours(filter);
    List<Hours> expected = Collections.singletonList(hour);
    assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 69 with Filter

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

the class HoursRepositoryTest method testGetHours_FilterHasNoProjectsAndHourTypes.

@Test
public void testGetHours_FilterHasNoProjectsAndHourTypes() {
    Project project = new Project();
    Hours hour = new Hours();
    hour.setProject(project);
    hour.setDate(new Date());
    entityManager.persist(project);
    entityManager.persist(hour);
    RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(createPeriod(-1, 1));
    Filter filter = new Filter();
    filter.setRangePeriodSelector(rangePeriodSelector);
    filter.setHourTypes(Collections.emptyList());
    filter.setProjects(Collections.emptyList());
    List<Hours> actual = hoursRepository.getHours(filter);
    List<Hours> expected = Collections.singletonList(hour);
    assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Hours(com.artezio.arttime.datamodel.Hours) Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 70 with Filter

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

the class HoursRepositoryTest method testGetHours_FilterHasProjectsAndHourTypes.

@Test
public void testGetHours_FilterHasProjectsAndHourTypes() {
    HourType hourType = new HourType("1");
    List<HourType> hourTypes = Collections.singletonList(hourType);
    Project project = new Project();
    project.setAccountableHours(hourTypes);
    Hours hour = new Hours(project, new Date(), null, hourType);
    entityManager.persist(hourType);
    entityManager.persist(project);
    entityManager.persist(hour);
    RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(createPeriod(-1, 1));
    Filter filter = new Filter();
    filter.setRangePeriodSelector(rangePeriodSelector);
    filter.setHourTypes(hourTypes);
    filter.setProjects(Collections.singletonList(project));
    List<Hours> actual = hoursRepository.getHours(filter);
    List<Hours> expected = Collections.singletonList(hour);
    assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) 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