Search in sources :

Example 1 with WorkdaysCalendarService

use of com.artezio.arttime.services.WorkdaysCalendarService 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)

Aggregations

Filter (com.artezio.arttime.filter.Filter)1 WorkdaysCalendarService (com.artezio.arttime.services.WorkdaysCalendarService)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1