Search in sources :

Example 61 with Trip

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

the class RemoveNonRevenueStopsStrategyTest method test.

@Test
public void test() throws IOException {
    RemoveNonRevenueStopsStrategy _strategy = new RemoveNonRevenueStopsStrategy();
    _gtfs.putAgencies(1);
    _gtfs.putStops(3);
    _gtfs.putRoutes(1);
    _gtfs.putCalendars(1, "start_date=20120903", "end_date=20121016", "mask=1111100");
    _gtfs.putTrips(1, "r0", "sid0");
    _gtfs.putLines("stop_times.txt", "trip_id,stop_id,stop_sequence,arrival_time,departure_time,drop_off_type,pickup_type", "t0,s0,0,01:00:00,01:05:00,1,1", "t0,s1,1,01:30:00,01:30:00,0,0", "t0,s2,2,02:30:00,02:30:00,1,1", "t0,s0,3,03:00:00,03:00:00,0,0", "t0,s2,4,03:30:00,03:30:00,1,1");
    GtfsMutableRelationalDao dao = _gtfs.read();
    _strategy.run(new TransformContext(), dao);
    Trip trip = dao.getTripForId(_gtfs.id("t0"));
    assertEquals("sid0", trip.getServiceId().getId());
    List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
    assertEquals(2, stopTimes.size());
    assertEquals(0, stopTimes.get(1).getPickupType());
    assertEquals(0, stopTimes.get(0).getPickupType());
}
Also used : GtfsMutableRelationalDao(org.onebusaway.gtfs.services.GtfsMutableRelationalDao) Trip(org.onebusaway.gtfs.model.Trip) TransformContext(org.onebusaway.gtfs_transformer.services.TransformContext) StopTime(org.onebusaway.gtfs.model.StopTime) Test(org.junit.Test)

Example 62 with Trip

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

the class DeferredValueConverterTest method testEntity_AgencyAndId.

@Test
public void testEntity_AgencyAndId() {
    Route route = new Route();
    route.setId(new AgencyAndId("1", "10"));
    _reader.injectEntity(route);
    _dao.saveEntity(route);
    Trip trip = new Trip();
    Object value = convert(trip, "route", "10");
    assertEquals(route, value);
}
Also used : Trip(org.onebusaway.gtfs.model.Trip) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Route(org.onebusaway.gtfs.model.Route) Test(org.junit.Test)

Example 63 with Trip

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

the class PropertyPathExpressionValueSetterTest method test.

@Test
public void test() {
    PropertyPathExpression expression = new PropertyPathExpression("route.shortName");
    PropertyPathExpressionValueSetter setter = new PropertyPathExpressionValueSetter(_reader, _schemaCache, _dao, expression);
    Route route = new Route();
    route.setShortName("10");
    Trip trip = new Trip();
    trip.setRoute(route);
    setter.setValue(BeanWrapperFactory.wrap(trip), "tripShortName");
    assertEquals("10", trip.getTripShortName());
}
Also used : Trip(org.onebusaway.gtfs.model.Trip) PropertyPathExpression(org.onebusaway.collections.beans.PropertyPathExpression) Route(org.onebusaway.gtfs.model.Route) Test(org.junit.Test)

Example 64 with Trip

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

the class PropertyMethodResolverImplTest method testTripCalendarsVirtualMethod.

@Test
public void testTripCalendarsVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    Trip trip = new Trip();
    trip.setId(new AgencyAndId("1", "t0"));
    trip.setServiceId(new AgencyAndId("1", "sid0"));
    _dao.saveEntity(trip);
    ServiceCalendar calendar = new ServiceCalendar();
    calendar.setServiceId(trip.getServiceId());
    _dao.saveEntity(calendar);
    PropertyMethod method = _resolver.getPropertyMethod(Trip.class, "calendar");
    assertEquals(calendar, method.invoke(trip));
}
Also used : Trip(org.onebusaway.gtfs.model.Trip) PropertyMethod(org.onebusaway.collections.beans.PropertyMethod) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ServiceCalendar(org.onebusaway.gtfs.model.ServiceCalendar) Test(org.junit.Test)

Example 65 with Trip

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

the class TransformFactoryTest method testReplaceValueInUpdate.

@Test
public void testReplaceValueInUpdate() throws IOException, TransformSpecificationException {
    _factory.addModificationsFromString("{'op':'update', " + "'match':{'file':'trips.txt'}, " + "'update':{'trip_headsign': 's/Downtown/Uptown/'}}");
    GtfsTransformStrategy transform = _transformer.getLastTransform();
    TransformContext context = new TransformContext();
    GtfsMutableRelationalDao dao = new GtfsRelationalDaoImpl();
    Trip trip = new Trip();
    trip.setId(new AgencyAndId("1", "1"));
    trip.setTripHeadsign("Downtown Express");
    dao.saveEntity(trip);
    transform.run(context, dao);
    assertEquals("Uptown Express", trip.getTripHeadsign());
}
Also used : GtfsMutableRelationalDao(org.onebusaway.gtfs.services.GtfsMutableRelationalDao) Trip(org.onebusaway.gtfs.model.Trip) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) TransformContext(org.onebusaway.gtfs_transformer.services.TransformContext) GtfsTransformStrategy(org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy) GtfsRelationalDaoImpl(org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl) Test(org.junit.Test)

Aggregations

Trip (org.onebusaway.gtfs.model.Trip)166 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)89 Test (org.junit.Test)56 StopTime (org.onebusaway.gtfs.model.StopTime)52 Route (org.onebusaway.gtfs.model.Route)51 Stop (org.onebusaway.gtfs.model.Stop)40 ArrayList (java.util.ArrayList)34 List (java.util.List)23 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)21 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)20 Agency (org.onebusaway.gtfs.model.Agency)19 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)19 HashMap (java.util.HashMap)14 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)13 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)13 HashSet (java.util.HashSet)12 Vertex (org.opentripplanner.routing.graph.Vertex)12 FactoryMap (org.onebusaway.collections.FactoryMap)10 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)10 ShapePoint (org.onebusaway.gtfs.model.ShapePoint)10