use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class GtfsGraphBuilderModuleTest method testBikesByDefault.
@Test
public void testBikesByDefault() throws IOException {
// We configure two trip: one with unknown bikes_allowed and the second with no bikes
// allowed.
MockGtfs gtfs = getSimpleGtfs();
gtfs.putTrips(2, "r0", "sid0", "bikes_allowed=0,2");
gtfs.putStopTimes("t0,t1", "s0,s1");
List<GtfsBundle> bundleList = getGtfsAsBundleList(gtfs);
bundleList.get(0).setDefaultBikesAllowed(true);
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.ALLOWED, BikeAccess.fromTrip(withId(trips, new FeedScopedId(feedId.getId(), "t0"))));
assertEquals(BikeAccess.NOT_ALLOWED, BikeAccess.fromTrip(withId(trips, new FeedScopedId(feedId.getId(), "t1"))));
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class LocationStringParserTest method testWithId.
@Test
public void testWithId() {
GenericLocation loc = LocationStringParser.fromOldStyleString("name::aFeed:A1B2C3");
assertEquals("name", loc.label);
assertEquals(loc.stopId, new FeedScopedId("aFeed", "A1B2C3"));
assertNull(loc.lat);
assertNull(loc.lng);
assertNull(loc.getCoordinate());
loc = LocationStringParser.fromOldStyleString("feed:4321");
assertNull(loc.label);
assertEquals(loc.stopId, new FeedScopedId("feed", "4321"));
assertNull(loc.lat);
assertNull(loc.lng);
assertNull(loc.getCoordinate());
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class FeedScopedIdMapperTest method testMapAgencyAndId.
@Test
public void testMapAgencyAndId() throws Exception {
org.onebusaway.gtfs.model.AgencyAndId inputId = new org.onebusaway.gtfs.model.AgencyAndId("A", "1");
FeedScopedId mappedId = mapAgencyAndId(inputId);
assertEquals("A", mappedId.getFeedId());
assertEquals("1", mappedId.getId());
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class TestBanning method getTestRoutes.
private Collection<Route> getTestRoutes() {
Route route1 = new Route();
route1.setId(new FeedScopedId("RB", "RUT:Route:1"));
route1.setLongName("");
Route route2 = new Route();
route2.setId(new FeedScopedId("RB", "RUT:Route:2"));
route2.setLongName("");
Route route3 = new Route();
route3.setId(new FeedScopedId("RB", "RUT:Route:3"));
route3.setLongName("");
Agency agency1 = new Agency(new FeedScopedId("RB", "RUT:Agency:1"), "A", "Europe/Paris");
Agency agency2 = new Agency(new FeedScopedId("RB", "RUT:Agency:2"), "B", "Europe/Paris");
route1.setAgency(agency1);
route2.setAgency(agency1);
route3.setAgency(agency2);
return Arrays.asList(route1, route2, route3);
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class TestBanning method testSetBannedOnRequest.
@Test
public void testSetBannedOnRequest() {
Collection<Route> routes = getTestRoutes();
RoutingRequest routingRequest = new RoutingRequest();
routingRequest.setBannedRoutesFromSting("RB__RUT:Route:1");
routingRequest.setBannedAgenciesFromSting("RB:RUT:Agency:2");
Collection<FeedScopedId> bannedRoutes = routingRequest.getBannedRoutes(routes);
Assert.assertEquals(2, bannedRoutes.size());
Assert.assertTrue(bannedRoutes.contains(new FeedScopedId("RB", "RUT:Route:1")));
Assert.assertTrue(bannedRoutes.contains(new FeedScopedId("RB", "RUT:Route:3")));
}
Aggregations