use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ReportsBeanTest method testGetSelectedDepartmens.
@Test
public void testGetSelectedDepartmens() throws NoSuchFieldException {
String[] expected = new String[] { "Minsk" };
Filter filter = new Filter();
filter.setDepartments(asList(expected));
expect(filterBean.getCurrentFilter()).andReturn(filter).times(2);
filter.getDepartments();
replay(filterBean);
String[] actual = reportsBean.getSelectedDepartments();
verify(filterBean);
Assert.assertArrayEquals(expected, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ReportsBeanTest method testGetSelectedProjectIds_emptyParam.
@Test
public void testGetSelectedProjectIds_emptyParam() throws NoSuchFieldException {
Project project1 = new Project();
setField(project1, "id", 1L);
Project project2 = new Project();
setField(project2, "id", 2L);
List<Project> projects = asList(project1, project2);
Filter filter = new Filter();
EasyMock.expect(filterBean.getCurrentFilter()).andReturn(filter).anyTimes();
EasyMock.expect(hoursService.getHours(filter)).andReturn(emptyList());
EasyMock.expect(projectService.getEffortsProjects(filter)).andReturn(projects);
EasyMock.replay(hoursService, filterBean, projectService);
Long[] actual = reportsBean.getSelectedProjectIds();
verify(hoursService, filterBean, projectService);
Assert.assertArrayEquals(new Long[] { 1L, 2L }, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ReportsBeanTest method testGetSelectedProjectIds_noProjectsSelected.
@Test
public void testGetSelectedProjectIds_noProjectsSelected() throws NoSuchFieldException {
Project activeProject = new Project();
activeProject.setStatus(Project.Status.ACTIVE);
setField(activeProject, "id", 1L);
Project inactiveProject = new Project();
inactiveProject.setStatus(Project.Status.CLOSED);
setField(inactiveProject, "id", 2L);
Project inactiveProjectWithReportedHours = new Project();
inactiveProjectWithReportedHours.setStatus(Project.Status.CLOSED);
setField(inactiveProjectWithReportedHours, "id", 3L);
List<Project> projects = asList(activeProject, inactiveProject, inactiveProjectWithReportedHours);
Hours reportedHours = new Hours(inactiveProjectWithReportedHours, null, null, null);
Filter filter = new Filter();
EasyMock.expect(filterBean.getCurrentFilter()).andReturn(filter).anyTimes();
EasyMock.expect(hoursService.getHours(filter)).andReturn(asList(reportedHours));
EasyMock.expect(projectService.getEffortsProjects(filter)).andReturn(projects);
EasyMock.replay(hoursService, projectService, filterBean);
Long[] actual = reportsBean.getSelectedProjectIds();
EasyMock.verify(hoursService, projectService, filterBean);
Assert.assertArrayEquals(new Long[] { 1L, 3L }, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ReportsBeanTest method testGetSelectedProjectIds_savedFilterWithInactiveProjects.
@Test
public void testGetSelectedProjectIds_savedFilterWithInactiveProjects() throws NoSuchFieldException {
Project selectedInactiveProject = new Project();
setField(selectedInactiveProject, "id", 1L);
selectedInactiveProject.setStatus(Project.Status.CLOSED);
Project nonSelectedActiveProject = new Project();
setField(nonSelectedActiveProject, "id", 2L);
nonSelectedActiveProject.setStatus(Project.Status.ACTIVE);
List<Project> selectedProjects = asList(selectedInactiveProject);
Filter filter = new Filter();
filter.setName("Filter Name");
filter.setProjects(asList(selectedInactiveProject));
EasyMock.expect(filterBean.getCurrentFilter()).andReturn(filter).anyTimes();
EasyMock.expect(hoursService.getHours(filter)).andReturn(emptyList());
EasyMock.expect(projectService.getEffortsProjects(filter)).andReturn(selectedProjects);
EasyMock.replay(hoursService, projectService, filterBean);
Long[] actual = reportsBean.getSelectedProjectIds();
EasyMock.verify(hoursService, projectService, filterBean);
Assert.assertArrayEquals(new Long[] { selectedInactiveProject.getId() }, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ReportsBeanTest method testGetSelectedEmployeeUserNames.
@Test
public void testGetSelectedEmployeeUserNames() throws NoSuchFieldException {
List<Employee> employees = asList(new Employee("username1"), new Employee("username2"));
Filter filter = new Filter();
filter.setEmployees(employees);
expect(employeeService.getEffortsEmployees(filter)).andReturn(employees);
expect(filterBean.getCurrentFilter()).andReturn(filter).anyTimes();
replay(filterBean, employeeService);
String[] actual = reportsBean.getSelectedEmployeeUserNames();
verify(filterBean, employeeService);
ListAssert.assertEquals(Arrays.asList("username1", "username2"), Arrays.asList(actual));
}
Aggregations