Search in sources :

Example 21 with Filter

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

the class FilterRepositoryTest method testRemove.

@Test
public void testRemove() {
    Filter filter = new Filter();
    entityManager.persist(filter);
    filterRepository.remove(filter);
    Filter actual = entityManager.find(Filter.class, filter.getId());
    assertNull(actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 22 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 filter = new Filter();
    Filter actual = filterRepository.create(filter);
    assertSame(filter, actual);
    assertNotNull(actual.getId());
}
Also used : Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 23 with Filter

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

the class HoursRepositoryTest method testGetHours_FilterHasNoProjectsAndHasHourTypes.

@Test
public void testGetHours_FilterHasNoProjectsAndHasHourTypes() {
    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.emptyList());
    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 24 with Filter

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

the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifEmployeesAreEmpty_FilterHasNotAllDepartments.

@Test
public void testGetEmployeesByDepartments_ifEmployeesAreEmpty_FilterHasNotAllDepartments() {
    Employee employee1 = new Employee("employee1");
    employee1.setDepartment("dep1");
    Employee employee2 = new Employee("employee2");
    employee2.setDepartment("dep2");
    Employee employee3 = new Employee("employee3");
    employee3.setDepartment("dep3");
    Filter filter = new Filter();
    filter.setEmployees(Arrays.asList(employee1, employee2));
    filter.setDepartments(Arrays.asList("dep1", "dep2"));
    entityManager.persist(employee1);
    entityManager.persist(employee2);
    entityManager.persist(employee3);
    List<Employee> expected = new ArrayList<>(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 25 with Filter

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

the class TimesheetBean method initSpreadSheet.

protected SpreadSheet initSpreadSheet() {
    Filter filter = filterService.getTimesheetFilter();
    filter.setRangePeriodSelector(filterBean.getCurrentFilter().getRangePeriodSelector());
    return new PersonalEffortsSpreadSheet(hoursService, projectService, employeeService, filter);
}
Also used : PersonalEffortsSpreadSheet(com.artezio.arttime.web.spread_sheet.PersonalEffortsSpreadSheet) Filter(com.artezio.arttime.filter.Filter)

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