use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.
the class CalendarExtensionStrategyTest method testCalendarDateSelectiveExtension.
@Test
public void testCalendarDateSelectiveExtension() throws IOException {
/**
* Tuesday is only partially active for sid0
*/
_gtfs.putCalendarDates("sid0=20121210,20121211,20121212,20121213,20121214," + "20121217,20121219,20121220,20121221," + "20121224,20121226,20121227,20121228", "sid1=20121208,20121209,20121215,20121216");
GtfsMutableRelationalDao dao = _gtfs.read();
ServiceDate endDate = new ServiceDate(2013, 01, 06);
_strategy.setEndDate(endDate);
_strategy.run(_context, dao);
CalendarService service = CalendarServiceDataFactoryImpl.createService(dao);
{
Set<ServiceDate> dates = service.getServiceDatesForServiceId(new AgencyAndId("a0", "sid0"));
assertEquals(17, dates.size());
assertTrue(dates.contains(new ServiceDate(2012, 12, 31)));
assertFalse(dates.contains(new ServiceDate(2013, 01, 01)));
assertTrue(dates.contains(new ServiceDate(2013, 01, 02)));
assertTrue(dates.contains(new ServiceDate(2013, 01, 03)));
assertTrue(dates.contains(new ServiceDate(2013, 01, 04)));
}
{
Set<ServiceDate> dates = service.getServiceDatesForServiceId(new AgencyAndId("a0", "sid1"));
assertEquals(4, dates.size());
}
}
use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.
the class CalendarExtensionStrategyTest method setup.
@Before
public void setup() throws IOException {
_gtfs = MockGtfs.create();
_gtfs.putAgencies(1);
_gtfs.putStops(2);
_gtfs.putRoutes(1);
_gtfs.putTrips(1, "r0", "sid0");
_gtfs.putStopTimes("t0", "s0,s1");
_strategy.setInactiveCalendarCutoff(new ServiceDate(2012, 12, 17));
}
use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.
the class CalendarSimplicationStrategyTest method testBasicSimplification.
@Test
public void testBasicSimplification() {
_gtfs.putAgencies(1);
_gtfs.putStops(1);
_gtfs.putRoutes(1);
_gtfs.putTrips(1, "r0", "sid0");
_gtfs.putStopTimes("t0", "s0");
_gtfs.putCalendars(1, "start_date=20120903", "end_date=20120916");
_gtfs.putCalendarDates("sid0=20120917,20120918,20120919,20120920,20120921,20120922,20120923");
GtfsRelationalDao dao = transform();
AgencyAndId serviceId = new AgencyAndId("a0", "sid0");
ServiceCalendar c = dao.getCalendarForServiceId(serviceId);
assertEquals(new ServiceDate(2012, 9, 3), c.getStartDate());
assertEquals(new ServiceDate(2012, 9, 23), c.getEndDate());
List<ServiceCalendarDate> serviceDates = dao.getCalendarDatesForServiceId(serviceId);
assertEquals(0, serviceDates.size());
}
use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.
the class VerifyBusService method createServiceDate.
private ServiceDate createServiceDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return new ServiceDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH));
}
use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.
the class DeferredValueConverterTest method testCsvFieldMappingServiceDate.
@Test
public void testCsvFieldMappingServiceDate() {
Object value = convert(new ServiceCalendar(), "startDate", "20130105");
assertEquals(new ServiceDate(2013, 1, 5), value);
}
Aggregations