Search in sources :

Example 1 with EmployeeService

use of com.artezio.arttime.services.EmployeeService in project ART-TIME by Artezio.

the class FilterBeanTest method testGetEmployees.

@Test
public void testGetEmployees() throws NoSuchFieldException {
    EmployeeService employeeService = mock(EmployeeService.class);
    Employee currentEmployee = new Employee("current");
    currentEmployee.setFormer(false);
    Employee formerEmployee = new Employee("former");
    formerEmployee.setFormer(true);
    setField(filterBean, "employeeService", employeeService);
    EasyMock.expect(employeeService.getAll()).andReturn(asList(currentEmployee, formerEmployee));
    EasyMock.replay(employeeService);
    List<Employee> actual = filterBean.getEmployees();
    EasyMock.verify(employeeService);
    assertTrue(actual.contains(currentEmployee));
    assertFalse(actual.contains(formerEmployee));
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) EmployeeService(com.artezio.arttime.services.EmployeeService) Test(org.junit.Test)

Example 2 with EmployeeService

use of com.artezio.arttime.services.EmployeeService in project ART-TIME by Artezio.

the class ManageEffortsBeanTest method testInitProjectEffortsSpreadSheet.

@Test
public void testInitProjectEffortsSpreadSheet() throws Exception {
    manageEffortsBean = new ManageEffortsBean();
    ProjectEffortsSpreadSheetBuildingStrategy strategy = createMock(ProjectEffortsSpreadSheetBuildingStrategy.class);
    EmployeeService employeeService = mock(EmployeeService.class);
    setField(strategy, "employeeService", employeeService);
    Filter filter = createMock(Filter.class);
    setField(manageEffortsBean, "grouping", BY_PROJECTS);
    setField(manageEffortsBean, "filterBean", filterBean);
    setField(manageEffortsBean, "employeeService", employeeService);
    EasyMock.expect(filterService.getActiveProjectsFilter()).andReturn(filter);
    EasyMock.expect(filterBean.getCurrentFilter()).andReturn(filter);
    expect(employeeService.getEffortsEmployees()).andReturn(Collections.emptyList());
    replay(employeeService, filterBean, strategy);
    SpreadSheet actual = manageEffortsBean.initSpreadSheet();
    verify(employeeService, filterBean, strategy);
    assertEquals(ProjectEffortsSpreadSheet.class, actual.getClass());
}
Also used : Filter(com.artezio.arttime.filter.Filter) SpreadSheet(com.artezio.arttime.web.spread_sheet.SpreadSheet) EmployeeEffortsSpreadSheet(com.artezio.arttime.web.spread_sheet.EmployeeEffortsSpreadSheet) ProjectEffortsSpreadSheet(com.artezio.arttime.web.spread_sheet.ProjectEffortsSpreadSheet) ProjectEffortsSpreadSheetBuildingStrategy(com.artezio.arttime.web.spread_sheet.strategies.ProjectEffortsSpreadSheetBuildingStrategy) EmployeeService(com.artezio.arttime.services.EmployeeService) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with EmployeeService

use of com.artezio.arttime.services.EmployeeService in project ART-TIME by Artezio.

the class ManageEffortsBeanTest method testInitEmployeeEffortsSpreadSheet.

@Test
public void testInitEmployeeEffortsSpreadSheet() throws Exception {
    manageEffortsBean = new ManageEffortsBean();
    EmployeeService employeeService = mock(EmployeeService.class);
    EmployeeEffortsSpreadSheetBuildingStrategy strategy = createMock(EmployeeEffortsSpreadSheetBuildingStrategy.class);
    setField(strategy, "employeeService", employeeService);
    Filter filter = createMock(Filter.class);
    setField(manageEffortsBean, "grouping", BY_EMPLOYEES);
    setField(manageEffortsBean, "filterBean", filterBean);
    setField(manageEffortsBean, "employeeService", employeeService);
    expect(employeeService.getEffortsEmployees()).andReturn(Collections.emptyList());
    EasyMock.expect(filterBean.getCurrentFilter()).andReturn(filter);
    replay(employeeService, filterBean, strategy);
    SpreadSheet actual = manageEffortsBean.initSpreadSheet();
    verify(employeeService, filterBean, strategy);
    assertEquals(EmployeeEffortsSpreadSheet.class, actual.getClass());
}
Also used : EmployeeEffortsSpreadSheetBuildingStrategy(com.artezio.arttime.web.spread_sheet.strategies.EmployeeEffortsSpreadSheetBuildingStrategy) Filter(com.artezio.arttime.filter.Filter) SpreadSheet(com.artezio.arttime.web.spread_sheet.SpreadSheet) EmployeeEffortsSpreadSheet(com.artezio.arttime.web.spread_sheet.EmployeeEffortsSpreadSheet) ProjectEffortsSpreadSheet(com.artezio.arttime.web.spread_sheet.ProjectEffortsSpreadSheet) EmployeeService(com.artezio.arttime.services.EmployeeService) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with EmployeeService

use of com.artezio.arttime.services.EmployeeService in project ART-TIME by Artezio.

the class ReportedHoursIndicatorTest method setUp.

@Before
public void setUp() throws Exception {
    loggedEmployee = new Employee(userName);
    hoursIndicator = createMockBuilder(ReportedHoursIndicator.class).addMockedMethod("getFilter").createMock();
    period = new Period();
    workTimeService = createMock(WorkTimeService.class);
    employeeService = createMock(EmployeeService.class);
    filter = createMock(Filter.class);
    hourTypeService = createMock(HourTypeService.class);
    expect(employeeService.getLoggedEmployee()).andReturn(Optional.of(loggedEmployee)).anyTimes();
    replay(employeeService);
    setField(hoursIndicator, "workTimeService", workTimeService);
    setField(hoursIndicator, "employeeService", employeeService);
    setField(hoursIndicator, "hourTypeService", hourTypeService);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) WorkTimeService(com.artezio.arttime.services.WorkTimeService) Filter(com.artezio.arttime.filter.Filter) HourTypeService(com.artezio.arttime.services.HourTypeService) Period(com.artezio.arttime.datamodel.Period) EmployeeService(com.artezio.arttime.services.EmployeeService) Before(org.junit.Before)

Aggregations

EmployeeService (com.artezio.arttime.services.EmployeeService)4 Filter (com.artezio.arttime.filter.Filter)3 Test (org.junit.Test)3 Employee (com.artezio.arttime.datamodel.Employee)2 EmployeeEffortsSpreadSheet (com.artezio.arttime.web.spread_sheet.EmployeeEffortsSpreadSheet)2 ProjectEffortsSpreadSheet (com.artezio.arttime.web.spread_sheet.ProjectEffortsSpreadSheet)2 SpreadSheet (com.artezio.arttime.web.spread_sheet.SpreadSheet)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Period (com.artezio.arttime.datamodel.Period)1 HourTypeService (com.artezio.arttime.services.HourTypeService)1 WorkTimeService (com.artezio.arttime.services.WorkTimeService)1 EmployeeEffortsSpreadSheetBuildingStrategy (com.artezio.arttime.web.spread_sheet.strategies.EmployeeEffortsSpreadSheetBuildingStrategy)1 ProjectEffortsSpreadSheetBuildingStrategy (com.artezio.arttime.web.spread_sheet.strategies.ProjectEffortsSpreadSheetBuildingStrategy)1 Before (org.junit.Before)1