GenerateNarrativesTask implements Runnable { public void generateTripNarratives(NarrativeProviderImpl provider) { int tripIndex = 0; Collection<Trip> trips = _gtfsDao.getAllTrips(); int logInterval = LoggingIntervalUtil.getAppropriateLoggingInterval(trips.size()); for (Trip trip : trips) { if (tripIndex % logInterval == 0) { _log.info("trips=" + tripIndex + " of " + trips.size()); } tripIndex++; TripNarrative tripNarrative = getTripNarrative(trip); provider.setNarrativeForTripId(trip.getId(), tripNarrative); List<StopTime> stopTimes = _gtfsDao.getStopTimesForTrip(trip); int stopTimeIndex = 0; for (StopTime stopTime : stopTimes) { StopTimeNarrative stopTimeNarrative = getStopTimeNarrative(stopTime); provider.setNarrativeForStopTimeEntry(trip.getId(), stopTimeIndex++, stopTimeNarrative); } } }  @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 testGenerateTripNarratives() { Trip trip = new Trip(); trip.setId(aid("trip")); trip.setRouteShortName("R1"); trip.setTripHeadsign("Where are we going?"); trip.setTripShortName("LOCAL"); StopTime stopTime = new StopTime(); stopTime.setRouteShortName("R1X"); stopTime.setStopHeadsign("Here"); Mockito.when(_gtfsDao.getAllTrips()).thenReturn(Arrays.asList(trip)); Mockito.when(_gtfsDao.getStopTimesForTrip(trip)).thenReturn( Arrays.asList(stopTime)); _task.generateTripNarratives(_provider); TripNarrative narrative = _provider.getNarrativeForTripId(trip.getId()); assertEquals(trip.getRouteShortName(), narrative.getRouteShortName()); assertEquals(trip.getTripHeadsign(), narrative.getTripHeadsign()); assertEquals(trip.getTripShortName(), narrative.getTripShortName()); StopEntryImpl stopEntry = stop("stop", 47.0, -122.0); TripEntryImpl tripEntry = trip("trip"); StopTimeEntryImpl stopTimeEntry = stopTime(0, stopEntry, tripEntry, 0, 0.0); StopTimeNarrative stopTimeNarrative = _provider.getNarrativeForStopTimeEntry(stopTimeEntry); assertEquals(stopTime.getRouteShortName(), stopTimeNarrative.getRouteShortName()); assertEquals(stopTime.getStopHeadsign(), stopTimeNarrative.getStopHeadsign()); }