Search in sources :

Example 76 with Filter

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

the class FilterBeanTest method testGetCurrentFilter.

@Test
public final void testGetCurrentFilter() throws NoSuchFieldException {
    Filter expected = createMock(Filter.class);
    setField(filterBean, "currentFilter", expected);
    Filter actual = filterBean.getCurrentFilter();
    assertSame(expected, actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 77 with Filter

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

the class FilterBeanTest method testSetCurrentFilter.

@Test
public final void testSetCurrentFilter() throws NoSuchFieldException {
    Employee employee = new Employee("ownerName");
    Project project = new Project();
    project.setTeam(Collections.singletonList(employee));
    List<Project> projects = Collections.singletonList(project);
    Filter expected = new Filter();
    expected.setName("filterName");
    expected.setOwner("ownerName");
    expected.setProjects(projects);
    setField(filterBean, "currentFilter", new Filter());
    EasyMock.expect(projectService.getProjectHierarchy(project)).andReturn(projects);
    EasyMock.replay(filterService, projectService);
    filterBean.setCurrentFilter(expected);
    EasyMock.verify(filterService, projectService);
    assertSame(expected, filterBean.getCurrentFilter());
}
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 78 with Filter

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

the class FilterBeanTest method testSetCurrentFilter_CurrentFilterIsNotNull.

@Test
public void testSetCurrentFilter_CurrentFilterIsNotNull() throws NoSuchFieldException {
    Employee employee = new Employee("ownerName");
    Project project = new Project();
    project.setTeam(Collections.singletonList(employee));
    List<Project> projects = Collections.singletonList(project);
    Filter currentFilter = new Filter();
    currentFilter.setOwner("ownerName");
    currentFilter.setProjects(projects);
    setField(filterBean, "currentFilter", currentFilter);
    Filter expected = new Filter();
    expected.setOwner("ownerName");
    expected.setProjects(projects);
    EasyMock.expect(projectService.getProjectHierarchy(project)).andReturn(projects);
    EasyMock.replay(filterService, projectService);
    filterBean.setCurrentFilter(expected);
    EasyMock.verify(filterService, projectService);
    assertSame(expected, filterBean.getCurrentFilter());
    assertSame(currentFilter.getRangePeriodSelector(), expected.getRangePeriodSelector());
}
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 79 with Filter

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

the class FilterBeanTest method testGetProjects_SelectedCustomFilter_FilterContainsClosedProjects.

@Test
public void testGetProjects_SelectedCustomFilter_FilterContainsClosedProjects() throws NoSuchFieldException {
    Project project1 = createProject(1L, null, "XXYY");
    Project subproject1 = createProject(55L, null, "123");
    Project project2 = createProject(2L, null, "AABB");
    project2.setStatus(CLOSED);
    project2.addManager(loggedEmployee);
    List<Project> projects = asList(project1, subproject1);
    List<Project> expected = asList(project1, subproject1, project2);
    projects.forEach(project -> project.addManager(loggedEmployee));
    Filter filter = new Filter();
    filter.getProjects().add(project2);
    setField(filterBean, "currentFilter", filter);
    EasyMock.expect(projectService.getAll()).andReturn(projects);
    EasyMock.expect(projectService.fetchComplete(projects)).andReturn(projects);
    EasyMock.replay(projectService);
    List<Project> actual = filterBean.getProjects();
    EasyMock.verify(projectService);
    ListAssert.assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 80 with Filter

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

the class FilterBeanTest method testGetSelectedProjects.

@Test
public void testGetSelectedProjects() throws NoSuchFieldException {
    Project project1 = createProject(1L, null, "project1");
    project1.setStatus(FROZEN);
    Project project2 = createProject(5L, null, "project2");
    List<Project> expected = asList(project2, project1);
    Filter filter = new Filter();
    filter.setProjects(expected);
    setField(filterBean, "currentFilter", filter);
    EasyMock.expect(projectService.fetchComplete(anyObject(List.class))).andReturn(expected);
    EasyMock.replay(projectService);
    List<Project> actual = filterBean.getSelectedProjects();
    EasyMock.verify(projectService);
    ListAssert.assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Filter(com.artezio.arttime.filter.Filter) List(java.util.List) Arrays.asList(java.util.Arrays.asList) 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