use of org.onebusaway.gtfs.model.calendar.CalendarServiceData in project onebusaway-gtfs-modules by OneBusAway.
the class CalendarServiceImplTest method test.
@Test
public void test() throws IOException {
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
GtfsTestData.readGtfs(dao, GtfsTestData.getIslandGtfs(), "26");
CalendarServiceDataFactoryImpl factory = new CalendarServiceDataFactoryImpl();
factory.setGtfsDao(dao);
CalendarServiceData data = factory.createData();
CalendarServiceImpl service = new CalendarServiceImpl();
service.setData(data);
ServiceDate from = new ServiceDate(2008, 10, 27);
ServiceDate to = new ServiceDate(2009, 9, 27);
Set<ServiceDate> toExclude = new HashSet<ServiceDate>();
toExclude.add(new ServiceDate(2009, 1, 1));
// 23,1,1,1,1,1,0,0,20081027,20090927
Set<ServiceDate> dates = service.getServiceDatesForServiceId(new AgencyAndId("26", "23"));
assertEquals(239, dates.size());
Date fromDate = from.getAsDate();
Date toDate = to.getAsDate();
Calendar c = Calendar.getInstance();
c.setTime(fromDate);
while (c.getTime().compareTo(toDate) <= 0) {
ServiceDate day = new ServiceDate(c);
int dow = c.get(Calendar.DAY_OF_WEEK);
if (!(dow == Calendar.SATURDAY || dow == Calendar.SUNDAY || toExclude.contains(day))) {
assertTrue(dates.contains(day));
}
c.add(Calendar.DAY_OF_YEAR, 1);
}
}
use of org.onebusaway.gtfs.model.calendar.CalendarServiceData in project onebusaway-gtfs-modules by OneBusAway.
the class CalendarServiceImplSyntheticTest method setup.
@Before
public void setup() {
CalendarServiceData data = new CalendarServiceData();
data.putTimeZoneForAgencyId("A", tz);
putServiceDatesForServiceId(data, lsid1, Arrays.asList(d1, d2));
putServiceDatesForServiceId(data, lsid2, Arrays.asList(d2, d3));
putServiceDatesForServiceId(data, lsid3, Arrays.asList(d1, d3));
intervals = new ServiceIdIntervals();
intervals.addStopTime(lsid1, hourToSec(6), hourToSec(6));
intervals.addStopTime(lsid1, hourToSec(25), hourToSec(25));
intervals.addStopTime(lsid2, hourToSec(4), hourToSec(5));
intervals.addStopTime(lsid2, hourToSec(30), hourToSec(30));
intervals.addStopTime(lsid3, hourToSec(7), hourToSec(7));
intervals.addStopTime(lsid3, hourToSec(23), hourToSec(23));
service = new CalendarServiceImpl();
service.setData(data);
}
use of org.onebusaway.gtfs.model.calendar.CalendarServiceData in project onebusaway-application-modules by camsys.
the class ExtendedCalendarServiceImplTest method before.
@Before
public void before() {
_calendarService = new CalendarServiceImpl();
CalendarServiceData data = new CalendarServiceData();
_calendarService.setData(data);
addServiceDates(data, "sA", new ServiceDate(2010, 9, 10), new ServiceDate(2010, 9, 11));
addServiceDates(data, "sB", new ServiceDate(2010, 9, 11), new ServiceDate(2010, 9, 12));
addServiceDates(data, "sC", new ServiceDate(2010, 9, 12), new ServiceDate(2010, 9, 13));
addServiceDates(data, "sD", new ServiceDate(2010, 9, 13));
interval = new ServiceInterval(time(9, 00), time(9, 05), time(10, 00), time(10, 05));
_transitGraphDao = Mockito.mock(TransitGraphDao.class);
_service = new ExtendedCalendarServiceImpl();
_service.setCalendarService(_calendarService);
_service.setTransitGraphDao(_transitGraphDao);
}
use of org.onebusaway.gtfs.model.calendar.CalendarServiceData in project onebusaway-application-modules by camsys.
the class BlockCalendarServiceImplTest method before.
@Before
public void before() {
_service = new BlockCalendarServiceImpl();
_calendarData = new CalendarServiceData();
_calendarService = new CalendarServiceImpl();
_calendarService.setData(_calendarData);
_extendedCalendarService = new ExtendedCalendarServiceImpl();
_extendedCalendarService.setCalendarService(_calendarService);
_service.setCalendarService(_extendedCalendarService);
}
Aggregations