IndexerManagerBean implements IIndexerManagerLocal { @Override public boolean ping() { try { JestResult result = esClient.execute(new Health.Builder().build()); return result.isSucceeded(); } catch (IOException e) { return false; } }  @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 pingTest() throws IOException { Health health = new Health.Builder().build(); JestResult result = new JestResult(new Gson()); Mockito.when(esClient.execute(health)) .thenReturn(result); result.setSucceeded(false); Assert.assertFalse(indexerManagerBean.ping()); result.setSucceeded(true); Assert.assertTrue(indexerManagerBean.ping()); Mockito.when(esClient.execute(health)).thenThrow(new IOException()); Assert.assertFalse(indexerManagerBean.ping()); }