IndexerManagerBean implements IIndexerManagerLocal { @Override @RolesAllowed({UserGroupMapping.ADMIN_ROLE_ID, UserGroupMapping.REGULAR_USER_ROLE_ID}) public void deleteWorkspaceIndex(String workspaceId) throws AccountNotFoundException { Account account = accountManager.getMyAccount(); try { indexManager.deleteIndices(workspaceId); } catch (IndexerNotAvailableException | IndexerRequestException e) { LOGGER.log(Level.WARNING, "Cannot delete index for workspace [" + workspaceId + "]. Consider deleting it manually."); LOGGER.log(Level.FINE, null, e); mailer.sendWorkspaceIndexationFailure(account, workspaceId, getString("IndexerNotAvailableException", account.getLocale())); } }  @Override boolean ping(); @Override @RolesAllowed({UserGroupMapping.ADMIN_ROLE_ID, UserGroupMapping.REGULAR_USER_ROLE_ID}) @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) void createWorkspaceIndex(String workspaceId); @Override @RolesAllowed({UserGroupMapping.ADMIN_ROLE_ID, UserGroupMapping.REGULAR_USER_ROLE_ID}) void deleteWorkspaceIndex(String workspaceId); @Override @Asynchronous @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) void indexDocumentIteration(DocumentIteration documentIteration); @Override @Asynchronous @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) void indexDocumentIterations(List<DocumentIteration> documentIterations); @Override @Asynchronous @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) void indexPartIteration(PartIteration partIteration); @Override @Asynchronous @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) void indexPartIterations(List<PartIteration> partIterations); @Override @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) void removeDocumentIterationFromIndex(DocumentIteration documentIteration); @Override @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) void removePartIterationFromIndex(PartIteration partIteration); @Override @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) List<DocumentRevision> searchDocumentRevisions(DocumentSearchQuery documentSearchQuery, int from, int size); @Override @RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID}) List<PartRevision> searchPartRevisions(PartSearchQuery partSearchQuery, int from, int size); @Override @RolesAllowed({UserGroupMapping.ADMIN_ROLE_ID}) void indexAllWorkspacesData(); @Override @RolesAllowed({UserGroupMapping.ADMIN_ROLE_ID, UserGroupMapping.REGULAR_USER_ROLE_ID}) void indexWorkspaceData(String workspaceId);  }
@Test public void deleteWorkspaceIndexTest() throws IndexerNotAvailableException, AccountNotFoundException, IndexerRequestException { Account account = new Account("foo", "name", "mail", "en", new Date(), "CET"); Mockito.when(accountManager.getMyAccount()).thenReturn(account); Mockito.doNothing().when(indexManager).deleteIndices(workspaceId); try { indexerManagerBean.deleteWorkspaceIndex(workspaceId); Mockito.verify(indexManager, times(1)).deleteIndices(workspaceId); } catch (Exception e) { Assert.assertTrue(e.getClass().isAssignableFrom(WorkspaceAlreadyExistsException.class)); } Mockito.doThrow(new IndexerNotAvailableException()).when(indexManager).deleteIndices(workspaceId); indexerManagerBean.deleteWorkspaceIndex(workspaceId); Mockito.verify(mailer, times(1)).sendWorkspaceIndexationFailure(Matchers.any(Account.class), Matchers.anyString(), Matchers.anyString()); }