RouteEntriesFactory { public void processRoutes(TransitGraphImpl graph) { Collection<Route> routes = _gtfsDao.getAllRoutes(); int numRoutes = routes.size(); int logInterval = LoggingIntervalUtil.getAppropriateLoggingInterval(numRoutes); int routeIndex = 0; for (Route route : routes) { if (routeIndex % logInterval == 0 ){ _log.info("route processed: " + routeIndex + "/" + numRoutes); } routeIndex++; processRoute(graph, route); } graph.refreshRouteMapping(); }  @Autowired void setUniqueService(UniqueService uniqueService); @Autowired void setGtfsDao(GtfsRelationalDao gtfsDao); void processRoutes(TransitGraphImpl graph);  }
@Test public void testProcessRoutes() { GtfsRelationalDao gtfsDao = Mockito.mock(GtfsRelationalDao.class); Agency agency = new Agency(); agency.setId("A"); Route routeA = new Route(); routeA.setAgency(agency); routeA.setId(new AgencyAndId("A", "routeA")); Route routeB = new Route(); routeB.setAgency(agency); routeB.setId(new AgencyAndId("A", "routeB")); Mockito.when(gtfsDao.getAllRoutes()).thenReturn( Arrays.asList(routeA, routeB)); TransitGraphImpl graph = new TransitGraphImpl(); RouteEntriesFactory factory = new RouteEntriesFactory(); factory.setGtfsDao(gtfsDao); factory.setUniqueService(new UniqueServiceImpl()); factory.processRoutes(graph); RouteEntryImpl routeEntryA = graph.getRouteForId(routeA.getId()); RouteEntryImpl routeEntryB = graph.getRouteForId(routeB.getId()); List<RouteEntry> routes = graph.getAllRoutes(); assertEquals(2, routes.size()); assertTrue(routes.contains(routeEntryA)); assertTrue(routes.contains(routeEntryB)); }