use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ReportsBeanTest method testGetSelectedHourTypeIds.
@Test
public void testGetSelectedHourTypeIds() throws NoSuchFieldException {
HourType hourType1 = new HourType();
setField(hourType1, "id", 1L);
HourType hourType2 = new HourType();
setField(hourType2, "id", 2L);
List<HourType> hourTypes = asList(hourType1, hourType2);
Filter filter = new Filter();
filter.setHourTypes(hourTypes);
expect(filterBean.getCurrentFilter()).andReturn(filter).times(2);
filter.getHourTypes();
replay(filterBean);
Long[] actual = reportsBean.getSelectedHourTypeIds();
verify(filterBean);
Assert.assertArrayEquals(new Long[] { 1L, 2L }, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testInit.
@Test
public void testInit() {
Filter activeProjectsFilter = mock(Filter.class);
expect(filterService.getActiveProjectsFilter()).andReturn(activeProjectsFilter);
replay(filterService);
filterBean.init();
verify(filterService);
assertNotSame(activeProjectsFilter, filterBean.getCurrentFilter());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testRemove_ifCurrentFilter.
@Test
public void testRemove_ifCurrentFilter() throws NoSuchFieldException {
Filter currentFilter = new Filter("currentFilter", "user", false);
setField(currentFilter, "id", 1L);
setField(filterBean, "currentFilter", currentFilter);
filterService.remove(currentFilter);
EasyMock.replay(filterService);
filterBean.remove(currentFilter);
Filter actual = (Filter) getField(filterBean, "currentFilter");
EasyMock.verify(filterService);
assertNull(actual.getId());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testGetProjects_MasterAvailable.
@Test
public void testGetProjects_MasterAvailable() throws NoSuchFieldException {
Project project1 = createProject(1L, null, "XXYY");
Project project2 = createProject(2L, null, "AABB");
List<Project> projects = 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(projects, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterBeanTest method testGetProjects_SelectedCustomFilter_FilterContainsActiveProjects.
@Test
public void testGetProjects_SelectedCustomFilter_FilterContainsActiveProjects() throws NoSuchFieldException {
Project project1 = createProject(1L, null, "XXYY");
Project subproject1 = createProject(55L, null, "123");
Project project2 = createProject(2L, null, "AABB");
List<Project> projects = asList(project1, project2, subproject1);
projects.forEach(project -> project.addManager(loggedEmployee));
Filter filter = new Filter();
filter.setProjects(projects);
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(projects, actual);
}
Aggregations