StopBeanServiceImpl implements StopBeanService { @Cacheable public StopBean getStopForId(AgencyAndId id, ServiceDate serviceDate) { return getStopForIdForServiceDate(id, serviceDate); }  @Autowired void setTranstiGraphDao(TransitGraphDao transitGraphDao); @Autowired void setRouteService(RouteService routeService); @Autowired void setRouteBeanService(RouteBeanService routeBeanService); @Autowired void setNarrativeService(NarrativeService narrativeService); @Autowired void setConsolidatedStopsService(ConsolidatedStopsService consolidatedStopsService); @Cacheable /** serviceDate can be null. * If included, the routes returned in the stopBean will be filtered by service date **/ StopBean getStopForId(AgencyAndId id, ServiceDate serviceDate); @Cacheable StopBean getStopForIdForServiceDate(AgencyAndId id, ServiceDate serviceDate);  }
@Test public void testGetStopForId() { AgencyAndId stopId = new AgencyAndId("29", "1109"); StopEntryImpl stopEntry = new StopEntryImpl(stopId, 47.1, -122.1); Mockito.when(_transitGraphDao.getStopEntryForId(stopId)).thenReturn( stopEntry); StopNarrative.Builder builder = StopNarrative.builder(); builder.setCode("1109-b"); builder.setDescription("stop description"); builder.setLocationType(0); builder.setName("stop name"); builder.setUrl("http: builder.setDirection("N"); StopNarrative stop = builder.create(); Mockito.when(_narrativeService.getStopForId(stopId)).thenReturn(stop); AgencyAndId routeId = new AgencyAndId("1", "route"); Set<AgencyAndId> routeIds = new HashSet<AgencyAndId>(); routeIds.add(routeId); Mockito.when(_routeService.getRouteCollectionIdsForStop(stopId)).thenReturn( routeIds); RouteBean.Builder routeBuilder = RouteBean.builder(); routeBuilder.setId(AgencyAndIdLibrary.convertToString(routeId)); RouteBean route = routeBuilder.create(); Mockito.when(_routeBeanService.getRouteForId(routeId)).thenReturn(route); StopBean stopBean = _service.getStopForId(stopId, null); assertNotNull(stopBean); assertEquals(stopId.toString(), stopBean.getId()); assertEquals(stop.getName(), stopBean.getName()); assertEquals(stopEntry.getStopLat(), stopBean.getLat(), 0.0); assertEquals(stopEntry.getStopLon(), stopBean.getLon(), 0.0); assertEquals(stop.getCode(), stopBean.getCode()); assertEquals(stop.getLocationType(), stopBean.getLocationType()); List<RouteBean> routes = stopBean.getRoutes(); assertEquals(1, routes.size()); assertSame(route, routes.get(0)); }