Search in sources :

Example 81 with Filter

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

the class FilterBeanTest method testGetProjects_SelectedCustomFilter_FilterContainsClosedProjectsWithSubprojects.

@Test
public void testGetProjects_SelectedCustomFilter_FilterContainsClosedProjectsWithSubprojects() throws NoSuchFieldException {
    Project project1 = createProject(1L, null, "XXYY");
    project1.setStatus(CLOSED);
    project1.addManager(loggedEmployee);
    Project subproject1 = createProject(55L, project1, "123");
    subproject1.setStatus(CLOSED);
    subproject1.addManager(loggedEmployee);
    Project project2 = createProject(2L, null, "AABB");
    project2.addManager(loggedEmployee);
    List<Project> projects = asList(project2);
    List<Project> expected = asList(project1, project2);
    Filter filter = new Filter();
    filter.setProjects(asList(project1, subproject1));
    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 82 with Filter

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

the class FilterBeanTest method testRemove.

@Test
public void testRemove() throws NoSuchFieldException {
    Filter filter = new Filter("filter", "user", false);
    Filter currentFilter = new Filter("currentFilter", "user", false);
    setField(filterBean, "currentFilter", currentFilter);
    filterService.remove(filter);
    EasyMock.replay(filterService);
    filterBean.remove(filter);
    EasyMock.verify(filterService);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 83 with Filter

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

the class FilterBeanTest method testGetSelectedProjects_OnlySubprojectAvailable.

@Test
public void testGetSelectedProjects_OnlySubprojectAvailable() throws NoSuchFieldException {
    Project project1 = createProject(1L, null, "project1");
    Project subproject = createProject(5L, project1, "subproject");
    subproject.addManager(loggedEmployee);
    List<Project> expected = asList(subproject);
    Filter filter = new Filter();
    filter.setProjects(expected);
    setField(filterBean, "currentFilter", filter);
    EasyMock.expect(projectService.fetchComplete(anyObject(List.class))).andReturn(expected);
    expect(employeeService.getLoggedEmployee()).andReturn(Optional.of(loggedEmployee));
    EasyMock.replay(projectService, employeeService);
    List<Project> actual = filterBean.getSelectedProjects();
    EasyMock.verify(projectService, employeeService);
    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)

Example 84 with Filter

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

the class FilterBeanTest method testGetProjects_MasterAndSubprojectAvailable.

@Test
public void testGetProjects_MasterAndSubprojectAvailable() throws NoSuchFieldException {
    Project project1 = createProject(1L, null, "XXYY");
    Project subproject1 = createProject(55L, project1, "123");
    Project project2 = createProject(2L, null, "AABB");
    List<Project> projects = asList(project1, project2, subproject1);
    List<Project> expected = asList(project1, project2);
    projects.forEach(project -> project.addManager(loggedEmployee));
    Filter filter = new Filter();
    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 85 with Filter

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

the class FilterBeanTest method testGetSelectedProjects_MasterAndSubprojectAvailable.

@Test
public void testGetSelectedProjects_MasterAndSubprojectAvailable() throws NoSuchFieldException {
    Project project1 = createProject(1L, null, "project1");
    Project subproject = createProject(5L, project1, "subproject");
    project1.addManager(loggedEmployee);
    subproject.addManager(loggedEmployee);
    List<Project> expected = asList(project1);
    Filter filter = new Filter();
    filter.setProjects(asList(project1, subproject));
    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