/** * Deletes a search index if it exists. * * @param searchIndexName the name of the search index */ protected void deleteSearchIndexHelper(String searchIndexName) { if (indexFunctionsDao.isIndexExists(searchIndexName)) { indexFunctionsDao.deleteIndex(searchIndexName); } }
/** * Deletes a search index if it exists. * * @param searchIndexName the name of the search index */ protected void deleteSearchIndexHelper(String searchIndexName) { if (indexFunctionsDao.isIndexExists(searchIndexName)) { indexFunctionsDao.deleteIndex(searchIndexName); } }
@Test public void testDeleteSearchIndexHelperIndexNoExists() { // Mock the external calls. when(indexFunctionDao.isIndexExists(SEARCH_INDEX_NAME)).thenReturn(false); // Call a delete index method when a search index does not exists. searchIndexServiceImpl.deleteSearchIndexHelper(SEARCH_INDEX_NAME); verify(indexFunctionDao).isIndexExists(SEARCH_INDEX_NAME); verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper, indexFunctionDao, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper); } }
@Test public void testDeleteSearchIndexHelperIndexAlreadyExists() { // Mock the external calls. when(indexFunctionDao.isIndexExists(SEARCH_INDEX_NAME)).thenReturn(true); doNothing().when(indexFunctionDao).deleteIndex(SEARCH_INDEX_NAME); // Call a delete index method when a search index exists. searchIndexServiceImpl.deleteSearchIndexHelper(SEARCH_INDEX_NAME); verify(indexFunctionDao).isIndexExists(SEARCH_INDEX_NAME); verify(indexFunctionDao).deleteIndex(SEARCH_INDEX_NAME); verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper, indexFunctionDao, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper); }
@Test public void testDeleteSearchIndex() { // Create a search index key. SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME); // Create the search index entity. SearchIndexEntity searchIndexEntity = createTestSearchIndexEntity(); // Mock the external calls. when(indexFunctionsDao.isIndexExists(any())).thenReturn(true); when(alternateKeyHelper.validateStringParameter("Search index name", SEARCH_INDEX_NAME)).thenReturn(SEARCH_INDEX_NAME); when(searchIndexDaoHelper.getSearchIndexEntity(searchIndexKey)).thenReturn(searchIndexEntity); // Delete a search index. SearchIndex response = searchIndexService.deleteSearchIndex(searchIndexKey); // Verify the external calls. verify(alternateKeyHelper).validateStringParameter("Search index name", SEARCH_INDEX_NAME); verify(searchIndexDaoHelper).getSearchIndexEntity(searchIndexKey); verify(indexFunctionsDao).isIndexExists(any()); verify(indexFunctionsDao).deleteIndex(any()); verify(searchIndexDao).delete(searchIndexEntity); verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper, indexFunctionsDao, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper); // Validate the returned object. assertEquals( new SearchIndex(searchIndexKey, SEARCH_INDEX_TYPE_BDEF, SEARCH_INDEX_STATUS, SEARCH_INDEX_DEFAULT_ACTIVE_FLAG, NO_SEARCH_INDEX_STATISTICS, USER_ID, CREATED_ON, UPDATED_ON), response); }