### Question:
SearchEngineManager extends AbstractService implements ICmsSearchEngineManager, PublicContentChangedObserver, EntityTypesChangingObserver { @Override public void updateFromPublicContentChanged(PublicContentChangedEvent event) { if (this.getStatus() == STATUS_RELOADING_INDEXES_IN_PROGRESS) { this.publicContentChangedEventQueue.add(0, event); } else { this.manageEvent(event); } }  @Override void init(); @Override void refresh(); @Override void updateFromPublicContentChanged(PublicContentChangedEvent event); @Override Thread startReloadContentsReferences(); @Override Thread startReloadContentsReferences(String subDirectory); @Override void updateFromEntityTypesChanging(EntityTypesChangingEvent event); @Override void addEntityToIndex(IApsEntity entity); @Override void deleteIndexedEntity(String entityId); @Override LastReloadInfo getLastReloadInfo(); @Override List<String> searchId(String sectionCode, String langCode,
            String word, Collection<String> allowedGroups); @Override List<String> searchEntityId(String langCode, String word,
            Collection<String> allowedGroups); List<String> searchEntityId(SearchEngineFilter[] filters, Collection<ITreeNode> categories, Collection<String> allowedGroups); @Override FacetedContentsResult searchFacetedEntities(SearchEngineFilter[] filters, Collection<ITreeNode> categories, Collection<String> allowedGroups); @Override FacetedContentsResult searchFacetedEntities(SearchEngineFilter[] filters, SearchEngineFilter[] categories, Collection<String> allowedGroups); @Override List<String> loadContentsId(SearchEngineFilter[] filters, SearchEngineFilter[] facetNodeCodes, List<String> allowedGroups); @Override int getStatus(); @Override void updateIndexedEntity(IApsEntity entity); void setFactory(ISearchEngineDAOFactory factory); void setContentManager(IContentManager contentManager); static final String RELOAD_THREAD_NAME_PREFIX; }### Answer:
@Test public void updateContentNotify() throws Exception { when(this.factory.checkCurrentSubfolder()).thenReturn(false); Content content = Mockito.mock(Content.class); when(content.getId()).thenReturn("ART123"); PublicContentChangedEvent event = new PublicContentChangedEvent(); event.setContent(content); event.setOperationCode(PublicContentChangedEvent.UPDATE_OPERATION_CODE); this.searchEngineManager.updateFromPublicContentChanged(event); Mockito.verify(indexerDao, Mockito.times(1)).add(content); Mockito.verify(indexerDao, Mockito.times(1)).delete(IIndexerDAO.CONTENT_ID_FIELD_NAME, "ART123"); Mockito.verifyZeroInteractions(searcherDao); }
@Test public void updateContentNotify_withError() throws Exception { when(this.factory.checkCurrentSubfolder()).thenReturn(true); Mockito.doThrow(ApsSystemException.class).when(this.indexerDao).delete(Mockito.anyString(), Mockito.anyString()); Content content = Mockito.mock(Content.class); when(content.getId()).thenReturn("ART124"); PublicContentChangedEvent event = new PublicContentChangedEvent(); event.setContent(content); event.setOperationCode(PublicContentChangedEvent.UPDATE_OPERATION_CODE); this.searchEngineManager.updateFromPublicContentChanged(event); Mockito.verify(indexerDao, Mockito.times(1)).delete(IIndexerDAO.CONTENT_ID_FIELD_NAME, "ART124"); Mockito.verify(indexerDao, Mockito.times(0)).add(content); Mockito.verifyZeroInteractions(searcherDao); }
@Test public void deleteContentNotify() throws Exception { when(this.factory.checkCurrentSubfolder()).thenReturn(false); Content content = Mockito.mock(Content.class); when(content.getId()).thenReturn("ART125"); PublicContentChangedEvent event = new PublicContentChangedEvent(); event.setContent(content); event.setOperationCode(PublicContentChangedEvent.REMOVE_OPERATION_CODE); this.searchEngineManager.updateFromPublicContentChanged(event); Mockito.verify(indexerDao, Mockito.times(0)).add(content); Mockito.verify(indexerDao, Mockito.times(1)).delete(IIndexerDAO.CONTENT_ID_FIELD_NAME, "ART125"); Mockito.verifyZeroInteractions(searcherDao); }