use of org.onebusaway.transit_data_federation.bundle.tasks.transit_graph.StopEntriesFactory in project onebusaway-application-modules by camsys.
the class StopEntriesFactoryTest method test.
@Test
public void test() {
Stop stopA = new Stop();
stopA.setId(new AgencyAndId("1", "stopA"));
stopA.setCode("A");
stopA.setDesc("Stop A Description");
stopA.setLat(47.0);
stopA.setLon(-122.0);
stopA.setLocationType(0);
stopA.setName("Stop A");
Stop stopB = new Stop();
stopB.setId(new AgencyAndId("1", "stopB"));
stopB.setCode("B");
stopB.setDesc("Stop B Description");
stopB.setLat(47.1);
stopB.setLon(-122.1);
stopB.setLocationType(0);
stopB.setName("Stop B");
GtfsRelationalDao dao = Mockito.mock(GtfsRelationalDao.class);
Mockito.when(dao.getAllStops()).thenReturn(Arrays.asList(stopA, stopB));
StopEntriesFactory factory = new StopEntriesFactory();
factory.setGtfsDao(dao);
TransitGraphImpl graph = new TransitGraphImpl();
AgencyEntryImpl agency = new AgencyEntryImpl();
agency.setId("1");
graph.putAgencyEntry(agency);
graph.refreshAgencyMapping();
factory.processStops(graph);
StopEntryImpl stopEntryA = graph.getStopEntryForId(stopA.getId());
assertEquals(stopA.getId(), stopEntryA.getId());
assertEquals(stopA.getLat(), stopEntryA.getStopLat(), 0);
assertEquals(stopA.getLon(), stopEntryA.getStopLon(), 0);
StopEntryImpl stopEntryB = graph.getStopEntryForId(stopB.getId());
assertEquals(stopB.getId(), stopEntryB.getId());
assertEquals(stopB.getLat(), stopEntryB.getStopLat(), 0);
assertEquals(stopB.getLon(), stopEntryB.getStopLon(), 0);
List<StopEntry> stops = graph.getAllStops();
assertEquals(2, stops.size());
assertTrue(stops.contains(stopEntryA));
assertTrue(stops.contains(stopEntryB));
stops = agency.getStops();
assertTrue(stops.contains(stopEntryA));
assertTrue(stops.contains(stopEntryB));
}
Aggregations