AgencyEntriesFactory { public void processAgencies(TransitGraphImpl graph) { Collection<Agency> agencies = _gtfsDao.getAllAgencies(); for (Agency agency : agencies) { AgencyEntryImpl agencyEntry = new AgencyEntryImpl(); agencyEntry.setId(_uniqueService.unique(agency.getId())); graph.putAgencyEntry(agencyEntry); } graph.refreshAgencyMapping(); }  @Autowired void setUniqueService(UniqueService uniqueService); @Autowired void setGtfsDao(GtfsRelationalDao gtfsDao); void processAgencies(TransitGraphImpl graph);  }
@Test public void testProcessAgencies() { GtfsRelationalDao gtfsDao = Mockito.mock(GtfsRelationalDao.class); Agency agencyA = new Agency(); agencyA.setId("A"); Agency agencyB = new Agency(); agencyB.setId("B"); Mockito.when(gtfsDao.getAllAgencies()).thenReturn( Arrays.asList(agencyA, agencyB)); TransitGraphImpl graph = new TransitGraphImpl(); AgencyEntriesFactory factory = new AgencyEntriesFactory(); factory.setGtfsDao(gtfsDao); factory.setUniqueService(new UniqueServiceImpl()); factory.processAgencies(graph); AgencyEntry agencyEntryA = graph.getAgencyForId("A"); assertEquals("A", agencyEntryA.getId()); AgencyEntry agencyEntryB = graph.getAgencyForId("B"); assertEquals("B", agencyEntryB.getId()); List<AgencyEntry> agencies = graph.getAllAgencies(); assertEquals(2, agencies.size()); assertTrue(agencies.contains(agencyEntryA)); assertTrue(agencies.contains(agencyEntryB)); }