Search in sources :

Example 1 with Filter

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

the class FilterService method createPredefinedFilter.

private Filter createPredefinedFilter(String name, String owner, List<Project> projects) {
    Filter result = new Filter(name, owner, true);
    result.setProjects(projects);
    return result;
}
Also used : Filter(com.artezio.arttime.filter.Filter)

Example 2 with Filter

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

the class ManageEffortsBean method initSpreadSheet.

protected SpreadSheet initSpreadSheet() {
    Filter currentFilter = filterBean.getCurrentFilter();
    filterRepository.fetchProjects(currentFilter);
    return getSpreadSheetBuildingStrategy().buildSpreadSheet(currentFilter);
}
Also used : Filter(com.artezio.arttime.filter.Filter)

Example 3 with Filter

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

the class FilterBeanTest method testSetSelectedProjects_FilterHasFilledProjectList_EmployeeIsPM.

@Test
public void testSetSelectedProjects_FilterHasFilledProjectList_EmployeeIsPM() throws NoSuchFieldException {
    Project project1 = createProject(1L, null, "project1");
    Project project11 = createProject(2L, project1, "project11");
    Project project12 = createProject(3L, project1, "project12");
    Project project2 = createProject(5L, null, "project2");
    List<Project> projects = Arrays.asList(project11, project12, project2);
    Filter filter = new Filter();
    setField(filterBean, "currentFilter", filter);
    expect(externalContext.isUserInRole("exec")).andReturn(false);
    expect(projectService.getSubprojectsByProjects(projects)).andReturn(projects);
    replay(externalContext, projectService);
    filterBean.setSelectedProjects(projects);
    verify(externalContext, projectService);
    assertSame(projects, filter.getProjects());
}
Also used : Project(com.artezio.arttime.datamodel.Project) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with Filter

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

the class FilterBeanTest method testGetCurrentFilter_CurrentFilterIsNull.

@Test
public final void testGetCurrentFilter_CurrentFilterIsNull() throws NoSuchFieldException {
    setField(filterBean, "currentFilter", null);
    Filter expected = new Filter();
    List<Project> projects = Collections.emptyList();
    expected.setProjects(projects);
    expect(filterService.getActiveProjectsFilter(loggedEmployee)).andReturn(expected);
    expect(filterRepository.fetchDetails(expected)).andReturn(expected);
    expect(projectService.getSubprojectsByProjects(projects)).andReturn(projects).anyTimes();
    replay(filterService, filterRepository, externalContext, projectService);
    Filter actual = filterBean.getCurrentFilter();
    verify(filterService, filterRepository, externalContext, projectService);
    assertSame(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with Filter

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

the class FilterBeanTest method testSetSelectedProjects_FilterHasEmptyProjectList.

@Test
public void testSetSelectedProjects_FilterHasEmptyProjectList() throws NoSuchFieldException {
    List<Project> emptyProjectList = Collections.emptyList();
    Filter filter = new Filter();
    setField(filterBean, "currentFilter", filter);
    expect(projectService.getSubprojectsByProjects(emptyProjectList)).andReturn(Collections.emptyList()).anyTimes();
    replay(externalContext, projectService);
    filterBean.setSelectedProjects(emptyProjectList);
    verify(externalContext, projectService);
    ListAssert.assertEquals(emptyProjectList, filter.getProjects());
}
Also used : Project(com.artezio.arttime.datamodel.Project) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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