@Test
public void testGenerateStopSearchIndex() throws CorruptIndexException,
IOException, ParseException {
RouteCollectionEntryImpl routeA = routeCollection("routeA");
RouteCollectionEntryImpl routeB = routeCollection("routeB");
RouteCollectionEntryImpl routeC = routeCollection("routeC");
RouteCollectionNarrative.Builder routeNarrativeA = RouteCollectionNarrative.builder();
routeNarrativeA.setShortName("10");
routeNarrativeA.setLongName("El Diez");
RouteCollectionNarrative.Builder routeNarrativeB = RouteCollectionNarrative.builder();
routeNarrativeB.setShortName("11");
routeNarrativeB.setLongName("El Once");
RouteCollectionNarrative.Builder routeNarrativeC = RouteCollectionNarrative.builder();
routeNarrativeC.setShortName("100");
Mockito.when(_transitGraphDao.getAllRouteCollections()).thenReturn(
Arrays.asList((RouteCollectionEntry) routeA, routeB, routeC));
Mockito.when(_narrativeService.getRouteCollectionForId(routeA.getId())).thenReturn(
routeNarrativeA.create());
Mockito.when(_narrativeService.getRouteCollectionForId(routeB.getId())).thenReturn(
routeNarrativeB.create());
Mockito.when(_narrativeService.getRouteCollectionForId(routeC.getId())).thenReturn(
routeNarrativeC.create());
_task.run();
Mockito.verify(_refreshService).refresh(
RefreshableResources.ROUTE_COLLECTION_SEARCH_DATA);
RouteCollectionSearchServiceImpl searchService = new RouteCollectionSearchServiceImpl();
searchService.setBundle(_bundle);
searchService.initialize();
SearchResult<AgencyAndId> ids = searchService.searchForRoutesByName("10",
10, MIN_SCORE);
assertEquals(1, ids.size());
assertEquals(routeA.getId(), ids.getResult(0));
ids = searchService.searchForRoutesByName("el diez", 10, MIN_SCORE);
assertEquals(1, ids.size());
assertEquals(routeA.getId(), ids.getResult(0));
ids = searchService.searchForRoutesByName("diez", 10, MIN_SCORE);
assertEquals(1, ids.size());
assertEquals(routeA.getId(), ids.getResult(0));
ids = searchService.searchForRoutesByName("11", 10, MIN_SCORE);
assertEquals(1, ids.size());
assertEquals(routeB.getId(), ids.getResult(0));
ids = searchService.searchForRoutesByName("100", 10, MIN_SCORE);
assertEquals(1, ids.size());
assertEquals(routeC.getId(), ids.getResult(0));
}