use of org.onebusaway.gtfs_transformer.match.SimpleValueMatcher in project onebusaway-gtfs-modules by OneBusAway.
the class TrimTripTransformStrategyTest method testMatching.
@Test
public void testMatching() throws IOException {
_gtfs.putAgencies(1);
_gtfs.putStops(6);
_gtfs.putRoutes(2);
_gtfs.putTrips(2, "r0,r1", "sid0");
_gtfs.putStopTimes("t0,t1", "s0,s1,s2,s3,s4,s5");
GtfsMutableRelationalDao dao = _gtfs.read();
TrimOperation operation = new TrimOperation();
operation.setMatch(new TypedEntityMatch(Trip.class, new PropertyValueEntityMatch(new PropertyPathExpression("route.id.id"), new SimpleValueMatcher("r1"))));
operation.setFromStopId("s4");
_strategy.addOperation(operation);
_strategy.run(_context, dao);
{
Trip trip = dao.getTripForId(new AgencyAndId("a0", "t0"));
List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
assertEquals(6, stopTimes.size());
}
{
Trip trip = dao.getTripForId(new AgencyAndId("a0", "t1-s4"));
List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
assertEquals(4, stopTimes.size());
assertEquals("s0", stopTimes.get(0).getStop().getId().getId());
assertEquals("s3", stopTimes.get(3).getStop().getId().getId());
}
}
Aggregations