Search in sources :

Example 46 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class ReportedHoursIndicatorTest method testGetFilter.

@Test
public void testGetFilter() {
    hoursIndicator = new ReportedHoursIndicator();
    FacesContext facesContext = createMock(FacesContext.class);
    Application application = createMock(Application.class);
    FilterBean filterBean = createMock(FilterBean.class);
    Filter filter = new Filter();
    PowerMock.mockStatic(FacesContext.class);
    expect(FacesContext.getCurrentInstance()).andReturn(facesContext);
    expect(facesContext.getApplication()).andReturn(application);
    expect(application.evaluateExpressionGet(facesContext, "#{filterBean}", Object.class)).andReturn(filterBean);
    expect(filterBean.getCurrentFilter()).andReturn(filter);
    PowerMock.replayAll(FacesContext.class, facesContext, application, filterBean);
    Filter actual = hoursIndicator.getFilter();
    PowerMock.verifyAll();
    assertSame(filter, actual);
}
Also used : FacesContext(javax.faces.context.FacesContext) Filter(com.artezio.arttime.filter.Filter) Application(javax.faces.application.Application) FilterBean(com.artezio.arttime.web.FilterBean) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 47 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class SpreadSheetTest method setUp.

@Before
public void setUp() throws NoSuchFieldException, ParseException {
    filter = new Filter();
    createEmployees();
    spreadSheet = new SpreadSheet() {

        @Override
        protected List<SpreadSheetRow<?>> buildSpreadSheetRows() {
            return null;
        }

        @Override
        protected List<Integer> calculateKeysOfTotalsRows(SpreadSheetRow<?> updatedRow) {
            return null;
        }
    };
    setField(spreadSheet, "filter", filter);
    setField(spreadSheet, "availableEmployees", employees);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) Before(org.junit.Before)

Example 48 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class ManageEffortsBeanTest method testRequestReport.

@Test
public void testRequestReport() throws Exception {
    Filter filter = new Filter();
    Employee employee = new Employee();
    PowerMock.mockStatic(Faces.class);
    expect(Faces.getRequestParameter("recipientEmail")).andReturn("iivanov@mail.com");
    expect(filterBean.getCurrentFilter()).andReturn(filter);
    notificationManager.requestWorkTimeReport("iivanov@mail.com", filter.getPeriod());
    PowerMock.replayAll(Faces.class, filterBean, notificationManager);
    manageEffortsBean.requestReport();
    PowerMock.verifyAll();
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 49 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class ReportsBeanTest method testGetSelectedEmployeeUserNames_emptyParam.

@Test
public void testGetSelectedEmployeeUserNames_emptyParam() {
    List<Employee> employees = asList(new Employee("username1"), new Employee("username2"));
    Filter filter = new Filter();
    filter.setEmployees(Collections.emptyList());
    expect(employeeService.getEffortsEmployees(filter)).andReturn(employees);
    expect(filterBean.getCurrentFilter()).andReturn(filter).anyTimes();
    replay(filterBean, employeeService);
    String[] actual = reportsBean.getSelectedEmployeeUserNames();
    verify(filterBean, employeeService);
    Assert.assertArrayEquals(new String[] { "username1", "username2" }, actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 50 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class ReportsBeanTest method testGetSelectedProjectIds.

@Test
public void testGetSelectedProjectIds() throws NoSuchFieldException {
    Project selectedProject = new Project();
    setField(selectedProject, "id", 1L);
    List<Project> projects = asList(selectedProject);
    Filter filter = new Filter();
    filter.setProjects(asList(selectedProject));
    EasyMock.expect(filterBean.getCurrentFilter()).andReturn(filter).anyTimes();
    EasyMock.expect(hoursService.getHours(filter)).andReturn(emptyList());
    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 }, 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