@Test(expectedExceptions = SystemException.class) public void testDeleteDocFromIndexWhenCannotDeleteShouldThrowException() throws IOException { given(termFactory.createTerm(FIELD_NAME, TEXT)).willReturn(term); willThrow(new IOException()).given(indexWriter).deleteDocuments(term); underTest.deleteDocFromIndex(TEXT); }
public void deleteDocFromIndex(final String fileName) { try { Term term = termFactory.createTerm(fieldName, fileName); indexWriter.deleteDocuments(term); } catch (IOException e) { throw new SystemException("Could not delete file " + fileName + " from the index. Reason:" + e.getMessage()); } }
LuceneDeleteEngine { public void deleteDocFromIndex(final String fileName) { try { Term term = termFactory.createTerm(fieldName, fileName); indexWriter.deleteDocuments(term); } catch (IOException e) { throw new SystemException("Could not delete file " + fileName + " from the index. Reason:" + e.getMessage()); } } }
LuceneDeleteEngine { public void deleteDocFromIndex(final String fileName) { try { Term term = termFactory.createTerm(fieldName, fileName); indexWriter.deleteDocuments(term); } catch (IOException e) { throw new SystemException("Could not delete file " + fileName + " from the index. Reason:" + e.getMessage()); } }  }
LuceneDeleteEngine { public void deleteDocFromIndex(final String fileName) { try { Term term = termFactory.createTerm(fieldName, fileName); indexWriter.deleteDocuments(term); } catch (IOException e) { throw new SystemException("Could not delete file " + fileName + " from the index. Reason:" + e.getMessage()); } }  void deleteDocFromIndex(final String fileName); }
LuceneDeleteEngine { public void deleteDocFromIndex(final String fileName) { try { Term term = termFactory.createTerm(fieldName, fileName); indexWriter.deleteDocuments(term); } catch (IOException e) { throw new SystemException("Could not delete file " + fileName + " from the index. Reason:" + e.getMessage()); } }  void deleteDocFromIndex(final String fileName);  }