Search in sources :

Example 26 with AgencyAndId

use of org.onebusaway.gtfs.model.AgencyAndId 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());
}
Also used : ServiceCalendarDate(org.onebusaway.gtfs.model.ServiceCalendarDate) GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ServiceCalendar(org.onebusaway.gtfs.model.ServiceCalendar) Test(org.junit.Test)

Example 27 with AgencyAndId

use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.

the class ServiceCalendarDateComparator method compare.

@Override
public int compare(ServiceCalendarDate o1, ServiceCalendarDate o2) {
    AgencyAndId id1 = o1.getServiceId();
    AgencyAndId id2 = o2.getServiceId();
    int c = id1.compareTo(id2);
    if (c != 0)
        return c;
    ServiceDate d1 = o1.getDate();
    ServiceDate d2 = o2.getDate();
    return d1.compareTo(d2);
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId)

Example 28 with AgencyAndId

use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.

the class GtfsTransformerTest method testUpdateTrips.

@Test
public void testUpdateTrips() throws Exception {
    GtfsRelationalDao dao = transform("{'op':'update', 'match':{'file':'trips.txt', 'route_id':'r0'}, 'update':{'route_id': 'r1'}}");
    assertEquals(2, dao.getTripsForRoute(dao.getRouteForId(new AgencyAndId("a0", "r1"))).size());
}
Also used : GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Test(org.junit.Test)

Example 29 with AgencyAndId

use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.

the class GtfsTransformerTest method testRetainCalendarCollection.

@Test
public void testRetainCalendarCollection() throws Exception {
    GtfsRelationalDao dao = transform("{'op':'retain', 'match':{'collection':'calendar', 'service_id':'sid1'}}");
    assertNull(dao.getCalendarForServiceId(new AgencyAndId("a0", "sid0")));
    assertNull(dao.getTripForId(new AgencyAndId("a0", "t0")));
}
Also used : GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Test(org.junit.Test)

Example 30 with AgencyAndId

use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.

the class GtfsTransformerTest method testRemoveRoute.

@Test
public void testRemoveRoute() throws Exception {
    GtfsRelationalDao dao = transform("{'op':'remove', 'match':{'file':'routes.txt', 'route_id':'r0'}}");
    assertNull(dao.getRouteForId(new AgencyAndId("a0", "r0")));
    assertNotNull(dao.getRouteForId(new AgencyAndId("a0", "r1")));
    assertNull(dao.getTripForId(new AgencyAndId("a0", "t0")));
    assertNotNull(dao.getTripForId(new AgencyAndId("a0", "t1")));
    assertEquals(2, dao.getAllStopTimes().size());
}
Also used : GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Test(org.junit.Test)

Aggregations

AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)102 Test (org.junit.Test)63 Trip (org.onebusaway.gtfs.model.Trip)37 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)25 Stop (org.onebusaway.gtfs.model.Stop)24 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)17 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)16 ArrayList (java.util.ArrayList)15 Route (org.onebusaway.gtfs.model.Route)15 StopTime (org.onebusaway.gtfs.model.StopTime)15 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)15 Agency (org.onebusaway.gtfs.model.Agency)13 ShapePoint (org.onebusaway.gtfs.model.ShapePoint)12 GtfsRelationalDao (org.onebusaway.gtfs.services.GtfsRelationalDao)11 HashSet (java.util.HashSet)10 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)10 List (java.util.List)9 Frequency (org.onebusaway.gtfs.model.Frequency)9 CalendarService (org.onebusaway.gtfs.services.calendar.CalendarService)7 Set (java.util.Set)6