summaryrefslogtreecommitdiffstats
path: root/holmes-actions
diff options
context:
space:
mode:
authortang peng <tang.peng5@zte.com.cn>2020-10-09 17:48:32 +0800
committertang peng <tang.peng5@zte.com.cn>2020-10-09 17:48:32 +0800
commitd2c6f5901291b458cc09b864c0eb140e5c636060 (patch)
tree3136e144dafa4af79ee9e5816b8c3f25ac644c62 /holmes-actions
parent38107cb7956b94100cbc5a766c7bbc12dc7154a2 (diff)
Added DB Query for Legacy Engine Instances
Issue-ID: HOLMES-365 Signed-off-by: tang peng <tang.peng5@zte.com.cn> Change-Id: I682c0e65b3382eda5d98bffd2459303e630828ca
Diffstat (limited to 'holmes-actions')
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java3
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java3
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java5
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java17
4 files changed, 22 insertions, 6 deletions
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java b/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java
index 42e0bf4..5ca38e0 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java
@@ -33,6 +33,9 @@ public interface EngineEntityDao {
@SqlQuery("SELECT * FROM ENGINE_ENTITY")
List<EngineEntity> getAllEntities();
+ @SqlQuery("SELECT DISTINCT(ENGINEINSTANCE) FROM APLUS_RULE")
+ List<String> getLegacyEngines();
+
@SqlUpdate("INSERT INTO ENGINE_ENTITY VALUES (:id, :ip, :port, :lastModified)")
void insertEntity(@BindBean EngineEntity entity);
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java b/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java
index 0baa4de..b913f38 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java
@@ -16,7 +16,7 @@
package org.onap.holmes.common.engine.service;
-import org.glassfish.jersey.spi.Contract;
+import org.jvnet.hk2.annotations.Contract;
import org.onap.holmes.common.engine.entity.EngineEntity;
import java.util.List;
@@ -25,6 +25,7 @@ import java.util.List;
public interface EngineEntityService {
EngineEntity getEntity(String id);
List<EngineEntity> getAllEntities();
+ List<String> getLegacyEngines();
void updateEntity(EngineEntity entity);
void insertEntity(EngineEntity entity);
void deleteEntity(String id);
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java b/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java
index 926af13..62d2388 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java
@@ -46,6 +46,11 @@ public class EngineEntityServiceImpl implements EngineEntityService {
}
@Override
+ public List<String> getLegacyEngines() {
+ return engineEntityDao.getLegacyEngines();
+ }
+
+ @Override
public void updateEntity(EngineEntity entity) {
engineEntityDao.updateEntity(entity);
}
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java
index 7058943..21a4025 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java
@@ -24,10 +24,7 @@ import org.onap.holmes.common.engine.entity.EngineEntity;
import org.onap.holmes.common.engine.service.EngineEntityService;
import org.onap.holmes.common.utils.DbDaoUtil;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import static com.google.common.base.Predicates.notNull;
import static org.hamcrest.core.Is.is;
@@ -35,10 +32,15 @@ import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.*;
public class EngineEntityServiceImplTest {
-
private EngineEntityService service = new EngineEntityServiceImpl(new DbDaoUtilStub());
@Test
+ public void getLegacyEngines() {
+ List<String> legacyEngines = service.getLegacyEngines();
+ assertThat(legacyEngines.size(), is(2));
+ }
+
+ @Test
public void getEntity() throws Exception {
EngineEntity entity = service.getEntity("org.onap.holmes_9201");
assertThat(entity, notNullValue());
@@ -103,6 +105,11 @@ class EngineEntityDaoStub implements EngineEntityDao {
}
@Override
+ public List<String> getLegacyEngines() {
+ return Arrays.asList("org.onap.holmes", "org.onap.holmes.legacy.1");
+ }
+
+ @Override
public void insertEntity(EngineEntity entity) {
entitySet.add(entity);
}