Search in sources :

Example 96 with Filter

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);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 97 with Filter

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);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 98 with Filter

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);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 99 with Filter

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);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 100 with Filter

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));
}
Also used : Filter(com.artezio.arttime.filter.Filter) 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