use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testSetSelectedProjects_FilterHasFilledProjectList_EmployeeIsExec.
@Test
public void testSetSelectedProjects_FilterHasFilledProjectList_EmployeeIsExec() 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> selectedProjects = Arrays.asList(project11, project12, project2);
List<Project> projects = Arrays.asList(project1, project2);
Filter filter = new Filter();
setField(filterBean, "currentFilter", filter);
expect(externalContext.isUserInRole("exec")).andReturn(true);
expect(projectService.getRootProjects(selectedProjects)).andReturn(projects).anyTimes();
expect(projectService.getSubprojectsByProjects(projects)).andReturn(projects).anyTimes();
replay(externalContext, projectService);
filterBean.setSelectedProjects(selectedProjects);
verify(externalContext, projectService);
assertSame(projects, filter.getProjects());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testSave.
@Test
public void testSave() throws NoSuchFieldException {
String newFilterName = "newFilterName";
Filter currentFilter = new Filter("filterName", "user", false);
Filter newFilter = new Filter(currentFilter);
newFilter.setName(newFilterName);
filterBean = createMockBuilder(FilterBean.class).addMockedMethod("setCurrentFilter", Filter.class).createMock();
setField(filterBean, "newFilterName", newFilterName);
setField(filterBean, "currentFilter", currentFilter);
setField(filterBean, "filterService", filterService);
expect(filterService.save(newFilter)).andReturn(newFilter);
filterBean.setCurrentFilter(newFilter);
replay(filterService, filterBean);
filterBean.save();
verify(filterService, filterBean);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testSetSelectedProjects_FilterHasNullProjectList_EmployeeIsExec.
/*
* The filter has null project list when it is formed on the client side and there are not selected projects
*/
@Test
public void testSetSelectedProjects_FilterHasNullProjectList_EmployeeIsExec() throws NoSuchFieldException {
List<Project> expected = new ArrayList<>();
Filter filter = new Filter();
setField(filterBean, "currentFilter", filter);
expect(projectService.getSubprojectsByProjects(expected)).andReturn(expected).anyTimes();
replay(externalContext, projectService);
filterBean.setSelectedProjects(null);
verify(externalContext, projectService);
assertTrue(filter.getProjects().isEmpty());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testSetSelectedProjects_FilterHasEmptyProjectList_EmployeeIsExec.
/*
* The filter has empty project list when it is formed on a server
*/
@Test
public void testSetSelectedProjects_FilterHasEmptyProjectList_EmployeeIsExec() throws NoSuchFieldException {
List<Project> emptyProjectList = new ArrayList<>();
Filter filter = new Filter();
setField(filterBean, "currentFilter", filter);
expect(projectService.getSubprojectsByProjects(emptyProjectList)).andReturn(emptyProjectList).anyTimes();
replay(externalContext, projectService);
filterBean.setSelectedProjects(emptyProjectList);
verify(externalContext, projectService);
assertTrue(filter.getProjects().isEmpty());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testSetSelectedProjects_FilterHasNullProjectList_EmployeeIsPM.
@Test
public void testSetSelectedProjects_FilterHasNullProjectList_EmployeeIsPM() throws NoSuchFieldException {
Filter filter = new Filter();
setField(filterBean, "currentFilter", filter);
expect(projectService.getSubprojectsByProjects(Collections.emptyList())).andReturn(Collections.emptyList()).anyTimes();
replay(externalContext, projectService);
filterBean.setSelectedProjects(null);
verify(externalContext, projectService);
assertEquals(Collections.emptyList(), filter.getProjects());
}
Aggregations