SearchIndexDaoHelper { public void activateSearchIndex(SearchIndexEntity currentSearchIndexEntity) { List<SearchIndexEntity> searchIndexEntities = searchIndexDao.getSearchIndexEntities(currentSearchIndexEntity.getType()); searchIndexEntities.stream().filter(searchIndexEntity -> !currentSearchIndexEntity.equals(searchIndexEntity)).collect(Collectors.toList()) .forEach(searchIndexEntity -> { searchIndexEntity.setActive(Boolean.FALSE); searchIndexDao.saveAndRefresh(searchIndexEntity); }); currentSearchIndexEntity.setActive(Boolean.TRUE); searchIndexDao.saveAndRefresh(currentSearchIndexEntity); }  SearchIndexEntity getSearchIndexEntity(SearchIndexKey searchIndexKey); void updateSearchIndexStatus(SearchIndexKey searchIndexKey, String searchIndexStatus); void activateSearchIndex(SearchIndexEntity currentSearchIndexEntity); String getActiveSearchIndex(String indexType);  }
@Test public void testActivateSearchIndexEntitySingleEntity() { SearchIndexEntity searchIndexEntity = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS); searchIndexDaoHelper.activateSearchIndex(searchIndexEntity); assertEquals(Boolean.TRUE, searchIndexEntity.getActive()); }
@Test public void testActivateSearchIndexEntity() { SearchIndexEntity searchIndexEntity = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS); SearchIndexEntity searchIndexEntity1 = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME_2, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS); searchIndexDaoHelper.activateSearchIndex(searchIndexEntity); assertEquals(Boolean.TRUE, searchIndexEntity.getActive()); assertEquals(Boolean.FALSE, searchIndexEntity1.getActive()); }