@Test(expectedExceptions = SystemException.class) public void testSearchForTextWhenCannotCreateIndexReadertShouldThrowException() throws IOException { given(readerFactory.create(true)).willThrow(new IOException()); underTest.searchForText(TEXT); }
public List<String> searchForText(final String text) { List<String> fileNames = new ArrayList<>(); getNewReaderAndSearcherUsingWriter(); Query query = createQuery(text); try { TopDocs queryResult = doSearch(query); fileNames = getFileNames(queryResult); closeIndexReader(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } return fileNames; }
LuceneSearchEngine { public List<String> searchForText(final String text) { List<String> fileNames = new ArrayList<>(); getNewReaderAndSearcherUsingWriter(); Query query = createQuery(text); try { TopDocs queryResult = doSearch(query); fileNames = getFileNames(queryResult); closeIndexReader(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } return fileNames; } }
LuceneSearchEngine { public List<String> searchForText(final String text) { List<String> fileNames = new ArrayList<>(); getNewReaderAndSearcherUsingWriter(); Query query = createQuery(text); try { TopDocs queryResult = doSearch(query); fileNames = getFileNames(queryResult); closeIndexReader(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } return fileNames; }  }
LuceneSearchEngine { public List<String> searchForText(final String text) { List<String> fileNames = new ArrayList<>(); getNewReaderAndSearcherUsingWriter(); Query query = createQuery(text); try { TopDocs queryResult = doSearch(query); fileNames = getFileNames(queryResult); closeIndexReader(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } return fileNames; }  @PostConstruct void initQueryParserProperties(); List<String> searchForText(final String text); }
LuceneSearchEngine { public List<String> searchForText(final String text) { List<String> fileNames = new ArrayList<>(); getNewReaderAndSearcherUsingWriter(); Query query = createQuery(text); try { TopDocs queryResult = doSearch(query); fileNames = getFileNames(queryResult); closeIndexReader(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } return fileNames; }  @PostConstruct void initQueryParserProperties(); List<String> searchForText(final String text);  }