GtfsRelationalDaoImpl extends GtfsDaoImpl implements
    GtfsMutableRelationalDao { @Override public List<String> getTripAgencyIdsReferencingServiceId(AgencyAndId serviceId) { if (_tripAgencyIdsByServiceId == null) { Map<AgencyAndId, Set<String>> agencyIdsByServiceIds = new HashMap<AgencyAndId, Set<String>>(); for (Trip trip : getAllTrips()) { AgencyAndId tripId = trip.getId(); String tripAgencyId = tripId.getAgencyId(); AgencyAndId tripServiceId = trip.getServiceId(); Set<String> agencyIds = agencyIdsByServiceIds.get(tripServiceId); if (agencyIds == null) { agencyIds = new HashSet<String>(); agencyIdsByServiceIds.put(tripServiceId, agencyIds); } agencyIds.add(tripAgencyId); } _tripAgencyIdsByServiceId = new HashMap<AgencyAndId, List<String>>(); for (Map.Entry<AgencyAndId, Set<String>> entry : agencyIdsByServiceIds.entrySet()) { AgencyAndId tripServiceId = entry.getKey(); List<String> agencyIds = new ArrayList<String>(entry.getValue()); Collections.sort(agencyIds); _tripAgencyIdsByServiceId.put(tripServiceId, agencyIds); } } List<String> agencyIds = _tripAgencyIdsByServiceId.get(serviceId); if (agencyIds == null) agencyIds = new ArrayList<String>(); return agencyIds; }  void clearAllCaches(); @Override List<String> getTripAgencyIdsReferencingServiceId(AgencyAndId serviceId); @Override List<Route> getRoutesForAgency(Agency agency); @Override List<Stop> getStopsForStation(Stop station); @Override List<AgencyAndId> getAllShapeIds(); @Override List<ShapePoint> getShapePointsForShapeId(AgencyAndId shapeId); @Override List<StopTime> getStopTimesForTrip(Trip trip); @Override List<StopTime> getStopTimesForStop(Stop stop); @Override List<Trip> getTripsForRoute(Route route); @Override List<Trip> getTripsForShapeId(AgencyAndId shapeId); @Override List<Trip> getTripsForServiceId(AgencyAndId serviceId); @Override List<Trip> getTripsForBlockId(AgencyAndId blockId); @Override List<Frequency> getFrequenciesForTrip(Trip trip); @Override List<AgencyAndId> getAllServiceIds(); @Override List<ServiceCalendarDate> getCalendarDatesForServiceId(
      AgencyAndId serviceId); @Override ServiceCalendar getCalendarForServiceId(AgencyAndId serviceId); @Override List<FareRule> getFareRulesForFareAttribute(FareAttribute fareAttribute); @Override List<Ridership> getRidershipForTrip(AgencyAndId tripId);  }
@Test public void testSyntheticGetTripAgencyIdsReferencingServiceId() { GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl(); AgencyAndId serviceId = new AgencyAndId("C", "serviceId"); Trip tripA = new Trip(); tripA.setId(new AgencyAndId("A", "tripId")); tripA.setServiceId(serviceId); dao.saveEntity(tripA); Trip tripB = new Trip(); tripB.setId(new AgencyAndId("B", "tripId")); tripB.setServiceId(serviceId); dao.saveEntity(tripB); List<String> agencyIds = dao.getTripAgencyIdsReferencingServiceId(serviceId); assertEquals(2, agencyIds.size()); assertTrue(agencyIds.contains("A")); assertTrue(agencyIds.contains("B")); }