use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class CalendarServiceDataFactoryImplSyntheticTest method trip.
private Trip trip(String agencyId, String id, AgencyAndId serviceId) {
Trip trip = new Trip();
trip.setId(new AgencyAndId(agencyId, id));
trip.setServiceId(serviceId);
return trip;
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class DeferredValueSupportTest method testResolveAgencyAndId_ExistingAgencyId.
@Test
public void testResolveAgencyAndId_ExistingAgencyId() {
Stop stop = new Stop();
stop.setId(new AgencyAndId("a1", "2"));
BeanWrapper bean = BeanWrapperFactory.wrap(stop);
AgencyAndId id = _support.resolveAgencyAndId(bean, "id", "1");
assertEquals(new AgencyAndId("a1", "1"), id);
}
use of org.onebusaway.gtfs.model.AgencyAndId 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.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImplTest method testAgencyRoutesVirtualMethod.
@Test
public void testAgencyRoutesVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Agency agency = new Agency();
agency.setId("1");
Route route = new Route();
route.setId(new AgencyAndId("1", "r0"));
route.setAgency(agency);
_dao.saveEntity(route);
PropertyMethod method = _resolver.getPropertyMethod(Agency.class, "routes");
assertEquals(Arrays.asList(route), method.invoke(agency));
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsReaderExampleMain method main.
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.err.println("usage: gtfsPath");
System.exit(-1);
}
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(args[0]));
/**
* You can register an entity handler that listens for new objects as they
* are read
*/
reader.addEntityHandler(new GtfsEntityHandler());
/**
* Or you can use the internal entity store, which has references to all the
* loaded entities
*/
GtfsDaoImpl store = new GtfsDaoImpl();
reader.setEntityStore(store);
reader.run();
// Access entities through the store
Map<AgencyAndId, Route> routesById = store.getEntitiesByIdForEntityType(AgencyAndId.class, Route.class);
for (Route route : routesById.values()) {
System.out.println("route: " + route.getShortName());
}
}
Aggregations