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());
}
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);
}
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());
}
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));
}
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());
}
Aggregations