Searcher { public SearchResult search(String term) { if (term == null || term.trim().isEmpty()) { LOGGER.debug("No query term supplied, returning empty results."); return new SearchResult(); } THROTTLE.acquire(); String normalizedTerm = term.toLowerCase(); final List<ConferenceSession> content = loader.load(); Iterable<ConferenceSession> filteredResults = Iterables.filter(content, new Predicate<ConferenceSession>() { @Override public boolean apply(@Nullable ConferenceSession input) { boolean tagsContainTerm = false; try { for (String tag : input.getTags()) { if (tag.toLowerCase().contains(normalizedTerm)) { tagsContainTerm = true; break; } } } catch (Exception ex) { LOGGER.debug("Unable to search tags as part of the [{}] result (for query: [{}])", input.getTitle(), term); } return input.getTitle().toLowerCase().contains(normalizedTerm) || input.getAbstract().toLowerCase().contains(normalizedTerm) || tagsContainTerm; } }); return new SearchResult(Lists.newArrayList( Iterables.transform(filteredResults, new Function<ConferenceSession, SearchResultElement>() { @Nullable @Override public SearchResultElement apply(ConferenceSession input) { return new SearchResultElement(input.getTitle(), input.getPresenter().getName(), input.getSessionType(), input.getAsciiArt(), input.getSessionId()); } }))); } Searcher(ConferenceSessionLoader loader); SearchResult search(String term);  }
@Test public void testSearch() { setupMock(); Searcher searcher = new Searcher(new ConferenceSessionLoader(getConfiguration())); SearchResult result = searcher.search("clojure"); assertNotNull(result); assertTrue(result.getResults().size() > 0); }