use of org.opentripplanner.api.model.Itinerary in project OpenTripPlanner by opentripplanner.
the class TestIntermediatePlaces method handleRequest.
private void handleRequest(GenericLocation from, GenericLocation to, GenericLocation[] via, String modes, boolean arriveBy) {
RoutingRequest request = new RoutingRequest(modes);
request.setDateTime("2016-04-20", "13:00", timeZone);
request.setArriveBy(arriveBy);
request.from = from;
request.to = to;
for (GenericLocation intermediateLocation : via) {
request.addIntermediatePlace(intermediateLocation);
}
List<GraphPath> pathList = graphPathFinder.graphPathFinderEntryPoint(request);
assertNotNull(pathList);
assertFalse(pathList.isEmpty());
TripPlan plan = GraphPathToTripPlanConverter.generatePlan(pathList, request);
assertLocationIsVeryCloseToPlace(from, plan.from);
assertLocationIsVeryCloseToPlace(to, plan.to);
assertTrue(1 <= plan.itinerary.size());
for (Itinerary itinerary : plan.itinerary) {
validateIntermediatePlacesVisited(itinerary, via);
assertTrue(via.length < itinerary.legs.size());
validateLegsTemporally(request, itinerary);
validateLegsSpatially(plan, itinerary);
if (modes.contains("TRANSIT")) {
assert itinerary.transitTime > 0;
}
}
}
use of org.opentripplanner.api.model.Itinerary in project OpenTripPlanner by opentripplanner.
the class GraphPathToTripPlanConverterTest method testEndWithLegSwitch.
/**
* Test that a LEG_SWITCH mode at the end of a graph path does not generate an extra leg.
* Also test that such a LEG_SWITCH mode does not show up as part of the itinerary.
*/
@Test
public void testEndWithLegSwitch() {
// Reuse testGenerateItinerary()'s graph path, but shorten it
GraphPath graphPath = new GraphPath(buildPaths()[0].states.get(3), false);
Itinerary itinerary = GraphPathToTripPlanConverter.generateItinerary(graphPath, false, false, locale);
assertEquals(1, itinerary.legs.size());
assertEquals("WALK", itinerary.legs.get(0).mode);
}
Aggregations