use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.
the class TripMapperTest method mapTrip.
@Test
public void mapTrip() {
OtpTransitServiceBuilder transitBuilder = new OtpTransitServiceBuilder();
Route route = new Route();
route.setId(ID_FACTORY.createId(ROUTE_ID));
transitBuilder.getRoutes().add(route);
TripMapper tripMapper = new TripMapper(ID_FACTORY, transitBuilder.getRoutes(), new HierarchicalMapById<>(), new HierarchicalMapById<>(), Collections.emptySet());
ServiceJourney serviceJourney = createExampleServiceJourney();
serviceJourney.setLineRef(LINE_REF);
Trip trip = tripMapper.mapServiceJourney(serviceJourney);
assertEquals(trip.getId(), ID_FACTORY.createId(SERVICE_JOURNEY_ID));
}
use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.
the class NetexLoaderSmokeTest method assertTripPatterns.
private void assertTripPatterns(Collection<TripPattern> patterns) {
Map<FeedScopedId, TripPattern> map = patterns.stream().collect(Collectors.toMap(TripPattern::getId, s -> s));
TripPattern p = map.get(fId("RUT:JourneyPattern:12-1"));
assertEquals("Jernbanetorget", p.getDirection());
assertEquals("RB", p.getFeedId());
assertEquals("[<Stop RB:NSR:Quay:7203>, <Stop RB:NSR:Quay:8027>]", p.getStops().toString());
assertEquals("[<Trip RB:RUT:ServiceJourney:12-101375-1000>]", p.getTrips().toString());
// TODO OTP2 - Why?
assertNull(p.getServices());
assertEquals(4, patterns.size());
}
use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.
the class GtfsGraphBuilderModuleTest method testNoBikesByDefault.
@Test
public void testNoBikesByDefault() throws IOException {
// We configure two trip: one with unknown bikes_allowed and the second with bikes
// allowed.
MockGtfs gtfs = getSimpleGtfs();
gtfs.putTrips(2, "r0", "sid0", "bikes_allowed=0,1");
gtfs.putStopTimes("t0,t1", "s0,s1");
List<GtfsBundle> bundleList = getGtfsAsBundleList(gtfs);
bundleList.get(0).setDefaultBikesAllowed(false);
builder = new GtfsModule(bundleList, ServiceDateInterval.unbounded());
Graph graph = new Graph();
builder.buildGraph(graph, _extra);
graph.index();
// Feed id is used instead of the agency id for OBA entities.
GtfsBundle gtfsBundle = bundleList.get(0);
GtfsFeedId feedId = gtfsBundle.getFeedId();
Trip trip = graph.index.getTripForId().get(new FeedScopedId(feedId.getId(), "t0"));
TripPattern pattern = graph.index.getPatternForTrip().get(trip);
List<Trip> trips = pattern.getTrips();
assertEquals(BikeAccess.UNKNOWN, BikeAccess.fromTrip(withId(trips, new FeedScopedId(feedId.getId(), "t0"))));
assertEquals(BikeAccess.ALLOWED, BikeAccess.fromTrip(withId(trips, new FeedScopedId(feedId.getId(), "t1"))));
}
use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.
the class RoutingServiceTest method testPatternsCoherent.
/**
* Check that bidirectional relationships between TripPatterns and Trips, Routes, and Stops are coherent.
*/
public void testPatternsCoherent() {
for (Trip trip : graph.index.getTripForId().values()) {
TripPattern pattern = graph.index.getPatternForTrip().get(trip);
assertTrue(pattern.getTrips().contains(trip));
}
/* This one depends on a feed where each TripPattern appears on only one route. */
for (Route route : graph.index.getAllRoutes()) {
for (TripPattern pattern : graph.index.getPatternsForRoute().get(route)) {
assertEquals(pattern.route, route);
}
}
for (Stop stop : graph.index.getAllStops()) {
for (TripPattern pattern : graph.index.getPatternsForStop(stop)) {
assertTrue(pattern.stopPattern.containsStop(stop.getId().toString()));
}
}
}
use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.
the class TripTimesTest method testApply.
@Test
public void testApply() {
Trip trip = new Trip();
trip.setId(tripId);
List<StopTime> stopTimes = new LinkedList<StopTime>();
StopTime stopTime0 = new StopTime();
StopTime stopTime1 = new StopTime();
StopTime stopTime2 = new StopTime();
Stop stop0 = Stop.stopForTest(stops[0].getId(), 0.0, 0.0);
Stop stop1 = Stop.stopForTest(stops[1].getId(), 0.0, 0.0);
Stop stop2 = Stop.stopForTest(stops[2].getId(), 0.0, 0.0);
stopTime0.setStop(stop0);
stopTime0.setDepartureTime(0);
stopTime0.setStopSequence(0);
stopTime1.setStop(stop1);
stopTime1.setArrivalTime(30);
stopTime1.setDepartureTime(60);
stopTime1.setStopSequence(1);
stopTime2.setStop(stop2);
stopTime2.setArrivalTime(90);
stopTime2.setStopSequence(2);
stopTimes.add(stopTime0);
stopTimes.add(stopTime1);
stopTimes.add(stopTime2);
TripTimes differingTripTimes = new TripTimes(trip, stopTimes, new Deduplicator());
TripTimes updatedTripTimesA = new TripTimes(differingTripTimes);
updatedTripTimesA.updateArrivalTime(1, 89);
updatedTripTimesA.updateDepartureTime(1, 98);
assertFalse(updatedTripTimesA.timesIncreasing());
}
Aggregations