Search in sources :

Example 21 with CalendarServiceData

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);
    }
}
Also used : CalendarServiceData(org.onebusaway.gtfs.model.calendar.CalendarServiceData) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Calendar(java.util.Calendar) GtfsRelationalDaoImpl(org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Date(java.util.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 22 with CalendarServiceData

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);
}
Also used : CalendarServiceData(org.onebusaway.gtfs.model.calendar.CalendarServiceData) ServiceIdIntervals(org.onebusaway.gtfs.model.calendar.ServiceIdIntervals) Before(org.junit.Before)

Example 23 with CalendarServiceData

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);
}
Also used : CalendarServiceData(org.onebusaway.gtfs.model.calendar.CalendarServiceData) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) TransitGraphDao(org.onebusaway.transit_data_federation.services.transit_graph.TransitGraphDao) CalendarServiceImpl(org.onebusaway.gtfs.impl.calendar.CalendarServiceImpl) ServiceInterval(org.onebusaway.gtfs.model.calendar.ServiceInterval) Before(org.junit.Before)

Example 24 with CalendarServiceData

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);
}
Also used : CalendarServiceData(org.onebusaway.gtfs.model.calendar.CalendarServiceData) ExtendedCalendarServiceImpl(org.onebusaway.transit_data_federation.impl.ExtendedCalendarServiceImpl) CalendarServiceImpl(org.onebusaway.gtfs.impl.calendar.CalendarServiceImpl) ExtendedCalendarServiceImpl(org.onebusaway.transit_data_federation.impl.ExtendedCalendarServiceImpl) Before(org.junit.Before)

Aggregations

CalendarServiceData (org.onebusaway.gtfs.model.calendar.CalendarServiceData)24 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)14 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)10 CalendarServiceImpl (org.onebusaway.gtfs.impl.calendar.CalendarServiceImpl)7 Date (java.util.Date)6 Test (org.junit.Test)6 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)6 Before (org.junit.Before)5 Agency (org.onebusaway.gtfs.model.Agency)5 LocalizedServiceId (org.onebusaway.gtfs.model.calendar.LocalizedServiceId)5 ArrayList (java.util.ArrayList)4 TimeZone (java.util.TimeZone)4 HashSet (java.util.HashSet)3 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)3 IOException (java.io.IOException)2 CalendarServiceDataFactoryImpl (org.onebusaway.gtfs.impl.calendar.CalendarServiceDataFactoryImpl)2 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)2 Trip (org.onebusaway.gtfs.model.Trip)2 ServiceInterval (org.onebusaway.gtfs.model.calendar.ServiceInterval)2 TransitGraphDao (org.onebusaway.transit_data_federation.services.transit_graph.TransitGraphDao)2