Search in sources :

Example 51 with Filter

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

Example 52 with Filter

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

Example 53 with Filter

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

Example 54 with Filter

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

Example 55 with Filter

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