use of org.onebusaway.gtfs.model.Stop in project onebusaway-gtfs-modules by OneBusAway.
the class ExtensionsTest method testExtensionWrite.
@Test
public void testExtensionWrite() throws IOException {
DefaultEntitySchemaFactory factory = GtfsEntitySchemaFactory.createEntitySchemaFactory();
factory.addExtension(Stop.class, StopExtension.class);
{
MockGtfs gtfs = MockGtfs.create();
gtfs.putMinimal();
gtfs.putStops(2, "label=a,b");
GtfsReader reader = new GtfsReader();
reader.setEntitySchemaFactory(factory);
GtfsMutableRelationalDao dao = gtfs.read(reader);
Stop stop = dao.getStopForId(new AgencyAndId("a0", "s0"));
StopExtension extension = stop.getExtension(StopExtension.class);
assertEquals("a", extension.getLabel());
GtfsWriter writer = new GtfsWriter();
writer.setEntitySchemaFactory(factory);
writer.setOutputLocation(_tmpDirectory);
writer.run(dao);
writer.close();
}
{
GtfsReader reader2 = new GtfsReader();
reader2.setEntitySchemaFactory(factory);
reader2.setInputLocation(_tmpDirectory);
GtfsRelationalDaoImpl dao2 = new GtfsRelationalDaoImpl();
reader2.setDefaultAgencyId("a0");
reader2.setEntityStore(dao2);
reader2.readEntities(Stop.class);
Stop stop2 = dao2.getStopForId(new AgencyAndId("a0", "s0"));
StopExtension extension2 = stop2.getExtension(StopExtension.class);
assertEquals("a", extension2.getLabel());
}
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-gtfs-modules by OneBusAway.
the class GenericDaoImplTest method testSaveOrUpdate.
@Test
public void testSaveOrUpdate() {
GenericDaoImpl impl = new GenericDaoImpl();
AgencyAndId id = new AgencyAndId("1", "stopA");
Stop entity = impl.getEntityForId(Stop.class, id);
assertNull(entity);
Stop stopA = new Stop();
stopA.setId(id);
impl.saveOrUpdateEntity(stopA);
entity = impl.getEntityForId(Stop.class, id);
assertSame(stopA, entity);
impl.saveOrUpdateEntity(stopA);
entity = impl.getEntityForId(Stop.class, id);
assertSame(stopA, entity);
Stop stopB = new Stop();
stopB.setId(id);
impl.saveOrUpdateEntity(stopB);
entity = impl.getEntityForId(Stop.class, id);
assertSame(stopB, entity);
Collection<Stop> entities = impl.getAllEntitiesForType(Stop.class);
assertEquals(1, entities.size());
assertSame(stopB, entities.iterator().next());
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-gtfs-modules by OneBusAway.
the class DeferredValueSupportTest method testResolveAgencyAndId_DefaultAgencyId.
@Test
public void testResolveAgencyAndId_DefaultAgencyId() {
Stop stop = new Stop();
BeanWrapper bean = BeanWrapperFactory.wrap(stop);
AgencyAndId id = _support.resolveAgencyAndId(bean, "id", "1");
assertEquals(new AgencyAndId("a0", "1"), id);
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImplTest method testTripStopTimesVirtualMethod.
@Test
public void testTripStopTimesVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Trip trip = new Trip();
trip.setId(new AgencyAndId("1", "t0"));
_dao.saveEntity(trip);
StopTime stopTime = new StopTime();
stopTime.setTrip(trip);
stopTime.setStop(new Stop());
_dao.saveEntity(stopTime);
PropertyMethod method = _resolver.getPropertyMethod(Trip.class, "stop_times");
assertEquals(Arrays.asList(stopTime), method.invoke(trip));
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-gtfs-modules by OneBusAway.
the class DeferredValueConverterTest method testInteger.
@Test
public void testInteger() {
Object value = convert(new Stop(), "locationType", "1");
assertEquals(new Integer(1), value);
}
Aggregations