GenerateNarrativesTask implements Runnable { public void generateRouteNarratives(NarrativeProviderImpl provider) { for (RouteCollectionEntry routeCollectionEntry : _transitGraphDao.getAllRouteCollections()) { List<Route> routes = new ArrayList<Route>(); Counter<Route> tripCounts = new Counter<Route>(); for (RouteEntry routeEntry : routeCollectionEntry.getChildren()) { Route route = _gtfsDao.getRouteForId(routeEntry.getId()); routes.add(route); int tripCount = routeEntry.getTrips().size(); tripCounts.increment(route, tripCount); } RouteCollectionNarrative.Builder builder = RouteCollectionNarrative.builder(); setPropertiesOfRouteCollectionFromRoutes(routes, tripCounts, builder); provider.setNarrativeForRouteCollectionId(routeCollectionEntry.getId(), builder.create()); } }  @Autowired void setBundle(FederatedTransitDataBundle bundle); @Autowired void setGtfsDao(GtfsRelationalDao gtfsDao); @Autowired void setTransitGraphDao(TransitGraphDao transitGraphDao); @Autowired void setBlockIndexService(BlockIndexService blockIndexService); @Autowired void setModifications(Modifications modifications); @Autowired void setShapePointHelper(ShapePointHelper shapePointHelper); @Autowired void setUniqueService(UniqueService uniqueService); @Autowired void setRefreshService(RefreshService refreshService); void setStopDirectionStandardDeviationThreshold(
      double stopDirectionStandardDeviationThreshold); @Override void run(); void generateAgencyNarratives(NarrativeProviderImpl provider); void generateRouteNarratives(NarrativeProviderImpl provider); void generateShapePointNarratives(NarrativeProviderImpl provider); void generateStopNarratives(NarrativeProviderImpl provider); void generateTripNarratives(NarrativeProviderImpl provider);  }
@Test public void testGenerateRouteNarratives() { RouteEntryImpl r1 = route("routeA1"); RouteEntryImpl r2 = route("routeA2"); RouteCollectionEntryImpl rc = routeCollection("routeA", r1, r2); TripEntry t1 = trip("t1"); TripEntry t2 = trip("t2"); TripEntry t3 = trip("t3"); r1.setTrips(Arrays.asList(t1)); r2.setTrips(Arrays.asList(t2, t3)); Mockito.when(_transitGraphDao.getAllRouteCollections()).thenReturn( Arrays.asList((RouteCollectionEntry) rc)); Route route1 = new Route(); route1.setId(r1.getId()); route1.setBikesAllowed(0); route1.setColor("#000000"); route1.setDesc("Route One Desc"); route1.setLongName("Route One"); route1.setShortName("One"); route1.setTextColor("#ff0000"); route1.setType(3); route1.setUrl("http: Route route2 = new Route(); route2.setId(r2.getId()); route2.setBikesAllowed(1); route2.setColor("#0000ff"); route2.setDesc("Route Two Desc"); route2.setLongName("Route Two"); route2.setShortName("Two"); route2.setTextColor("#000000"); route2.setType(3); route2.setUrl("http: Mockito.when(_gtfsDao.getRouteForId(r1.getId())).thenReturn(route1); Mockito.when(_gtfsDao.getRouteForId(r2.getId())).thenReturn(route2); _task.generateRouteNarratives(_provider); RouteCollectionNarrative narrative = _provider.getNarrativeForRouteCollectionId(rc.getId()); assertEquals(route2.getColor(), narrative.getColor()); assertEquals(route2.getDesc(), narrative.getDescription()); assertEquals(route2.getLongName(), narrative.getLongName()); assertEquals(route2.getShortName(), narrative.getShortName()); assertEquals(route2.getTextColor(), narrative.getTextColor()); assertEquals(route2.getType(), narrative.getType()); assertEquals(route2.getUrl(), narrative.getUrl()); }