Search in sources :

Example 91 with Filter

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

the class EffortsBeanTest method testInitByGetRequest_ifPeriodHasNullDate.

@Test
public void testInitByGetRequest_ifPeriodHasNullDate() throws Exception {
    Filter filter = new Filter();
    List<Employee> employees = Arrays.asList(new Employee());
    FilterBean filterBean = createMock(FilterBean.class);
    Period period = new Period(null, sdf.parse("15-01-2015"));
    setField(effortsBean, "filterBean", filterBean);
    setField(effortsBean, "period", period);
    setField(effortsBean, "employees", employees);
    effortsBean.initByGetRequest();
    assertNotEquals(period, filter.getPeriod());
    assertEquals(0, filter.getEmployees().size());
}
Also used : Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 92 with Filter

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

the class EffortsBeanTest method testGetDay_ifCalendarDaysNotCached.

@Test
public void testGetDay_ifCalendarDaysNotCached() throws Exception {
    Date date1 = sdf.parse("1-05-2015");
    Date date2 = sdf.parse("2-05-2015");
    WorkdaysCalendar calendar = new WorkdaysCalendar();
    Day day1 = new Day(date1, calendar, false);
    Day day2 = new Day(date2, calendar, false);
    Filter filter = new Filter();
    FilterBean filterBean = createMock(FilterBean.class);
    WorkdaysCalendarService workdaysCalendarService = createMock(WorkdaysCalendarService.class);
    setField(effortsBean, "filterBean", filterBean);
    setField(effortsBean, "workdaysCalendarService", workdaysCalendarService);
    expect(filterBean.getCurrentFilter()).andReturn(filter);
    expect(workdaysCalendarService.getDays(calendar, filter.getPeriod())).andReturn(Arrays.asList(day1, day2));
    replay(filterBean, workdaysCalendarService);
    Day actual = effortsBean.getDay(calendar, date1);
    verify(filterBean, workdaysCalendarService);
    assertSame(day1, actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) WorkdaysCalendarService(com.artezio.arttime.services.WorkdaysCalendarService) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 93 with Filter

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

the class EffortsBeanTest method testInitByGetRequest_ifEmployeesIsNull.

@Test
public void testInitByGetRequest_ifEmployeesIsNull() throws Exception {
    Filter filter = new Filter();
    List<Employee> employees = null;
    FilterBean filterBean = createMock(FilterBean.class);
    Period period = new Period(sdf.parse("1-01-2015"), sdf.parse("15-01-2015"));
    setField(effortsBean, "filterBean", filterBean);
    setField(effortsBean, "period", period);
    setField(effortsBean, "employees", employees);
    expect(filterBean.getCurrentFilter()).andReturn(filter);
    replay(filterBean);
    effortsBean.initByGetRequest();
    verify(filterBean);
    assertEquals(period, filter.getPeriod());
    assertEquals(Collections.emptyList(), filter.getEmployees());
}
Also used : Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 94 with Filter

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

the class FilterBeanTest method testGetSelectedProjects_noneSelected.

@Test
public void testGetSelectedProjects_noneSelected() throws NoSuchFieldException {
    Filter filter = new Filter();
    filter.setProjects(Collections.emptyList());
    setField(filterBean, "currentFilter", filter);
    List<Project> actual = filterBean.getSelectedProjects();
    assertTrue(actual.isEmpty());
}
Also used : Project(com.artezio.arttime.datamodel.Project) Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 95 with Filter

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

the class ReportsBeanTest method testGetSelectedStartDate.

@Test
public void testGetSelectedStartDate() throws Exception {
    Filter filter = new Filter();
    Date expected = new Date(1000);
    filter.setRangePeriodSelector(new RangePeriodSelector(new Period(expected, new Date(2000))));
    expect(filterBean.getCurrentFilter()).andReturn(filter);
    replay(filterBean);
    Date actual = reportsBean.getSelectedStartDate();
    verify(filterBean);
    assertEquals(expected, actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) RangePeriodSelector(com.artezio.arttime.web.criteria.RangePeriodSelector) Date(java.sql.Date) 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