summaryrefslogtreecommitdiffstats
path: root/engine-d/src
diff options
context:
space:
mode:
authorGuangrongFu <fu.guangrong@zte.com.cn>2020-07-27 19:34:57 +0800
committerGuangrongFu <fu.guangrong@zte.com.cn>2020-07-27 20:17:58 +0800
commitc4dc95bc729afd91c00cab49d0a69bceb102eed9 (patch)
treee570f534ae4c4524c4398ffc705eee69e578cd26 /engine-d/src
parenteadc4de80148f3457e75b06270370a33dc4751a4 (diff)
Trying to fix the Jenkins Job
Issue-ID: HOLMES-332 Change-Id: I3605ac6850226dc365460911c4e523f62ea117fc Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'engine-d/src')
-rw-r--r--engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java111
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java2
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java29
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/resources/EngineResources.java42
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/utils/AlarmUtil.java6
-rw-r--r--engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java8
-rw-r--r--engine-d/src/test/java/org/onap/holmes/engine/manager/DroolsEngineTest.java12
-rw-r--r--engine-d/src/test/java/org/onap/holmes/engine/resources/EngineResourcesTest.java6
-rw-r--r--engine-d/src/test/java/org/onap/holmes/engine/utils/AlarmUtilTest.java7
9 files changed, 102 insertions, 121 deletions
diff --git a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java
index be30153..e7d6669 100644
--- a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java
+++ b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2020 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,98 +15,73 @@
*/
package org.onap.holmes.dsa.dmaappolling;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.api.stat.AlarmAdditionalField;
import org.onap.holmes.common.api.stat.VesAlarm;
-import java.io.IOException;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import static org.onap.holmes.common.utils.GsonUtil.*;
+
@Service
public class DMaaPResponseUtil {
- public VesAlarm convertJsonToVesAlarm(String responseJson) throws IOException {
- JSONObject jsonNode = JSON.parseObject(responseJson);
+ public VesAlarm convertJsonToVesAlarm(String responseJson) {
+ JsonObject jsonNode = JsonParser.parseString(responseJson).getAsJsonObject();
VesAlarm vesAlarm = new VesAlarm();
- JSONObject eventJson = JSON.parseObject(jsonNode.get("event") +"");
- JSONObject commonEventHeaderJson = JSON.parseObject(eventJson.get("commonEventHeader") +"");
+ JsonObject eventJson = JsonParser.parseString(jsonNode.get("event").toString()).getAsJsonObject();
+ JsonObject commonEventHeaderJson = JsonParser.parseString(eventJson.get("commonEventHeader").toString())
+ .getAsJsonObject();
convertCommonEventHeaderJsonToEvent(commonEventHeaderJson, vesAlarm);
- JSONObject faultFieldsJson = JSON.parseObject(eventJson.get("faultFields") +"");
+ JsonObject faultFieldsJson = JsonParser.parseString(eventJson.get("faultFields").toString())
+ .getAsJsonObject();
convertFaultFieldsJsonToEvent(faultFieldsJson, vesAlarm);
return vesAlarm;
}
- private void convertCommonEventHeaderJsonToEvent(JSONObject commonEventHeaderJson,
+ private void convertCommonEventHeaderJsonToEvent(JsonObject commonEventHeaderJson,
VesAlarm vesAlarm) {
- vesAlarm.setDomain((String) commonEventHeaderJson.get("domain"));
- vesAlarm.setEventId((String) commonEventHeaderJson.get("eventId"));
- vesAlarm.setEventName((String) commonEventHeaderJson.get("eventName"));
+ vesAlarm.setDomain(getAsString(commonEventHeaderJson, "domain"));
+ vesAlarm.setEventId(getAsString(commonEventHeaderJson, "eventId"));
+ vesAlarm.setEventName(getAsString(commonEventHeaderJson, "eventName"));
vesAlarm.setAlarmIsCleared(vesAlarm.getEventName().endsWith("Cleared") ? 1 : 0);
- vesAlarm.setEventType(getTextElementByNode(commonEventHeaderJson, "eventType"));
- vesAlarm.setInternalHeaderFields(
- getTextElementByNode(commonEventHeaderJson, "internalHeaderFields"));
- vesAlarm.setLastEpochMicrosec(commonEventHeaderJson.getLong("lastEpochMicrosec"));
- vesAlarm.setNfcNamingCode(getTextElementByNode(commonEventHeaderJson, "nfcNamingCode"));
- vesAlarm.setNfNamingCode(getTextElementByNode(commonEventHeaderJson, "nfNamingCode"));
- vesAlarm.setPriority((String) commonEventHeaderJson.get("priority"));
- vesAlarm.setReportingEntityId(
- getTextElementByNode(commonEventHeaderJson, "reportingEntityId"));
- vesAlarm.setReportingEntityName( (String) commonEventHeaderJson.get("reportingEntityName"));
- vesAlarm.setSequence((Integer) commonEventHeaderJson.get("sequence"));
- vesAlarm.setSourceId(getTextElementByNode(commonEventHeaderJson, "sourceId"));
- vesAlarm.setSourceName( (String) commonEventHeaderJson.get("sourceName"));
- vesAlarm.setStartEpochMicrosec(commonEventHeaderJson.getLong("startEpochMicrosec"));
- vesAlarm.setVersion(commonEventHeaderJson.getLong("version"));
+ vesAlarm.setEventType(getAsString(commonEventHeaderJson, "eventType"));
+ vesAlarm.setInternalHeaderFields(getAsString(commonEventHeaderJson, "internalHeaderFields"));
+ vesAlarm.setLastEpochMicrosec(getAsLong(commonEventHeaderJson, "lastEpochMicrosec"));
+ vesAlarm.setNfcNamingCode(getAsString(commonEventHeaderJson, "nfcNamingCode"));
+ vesAlarm.setNfNamingCode(getAsString(commonEventHeaderJson, "nfNamingCode"));
+ vesAlarm.setPriority(getAsString(commonEventHeaderJson, "priority"));
+ vesAlarm.setReportingEntityId(getAsString(commonEventHeaderJson, "reportingEntityId"));
+ vesAlarm.setReportingEntityName(getAsString(commonEventHeaderJson, "reportingEntityName"));
+ vesAlarm.setSequence(getAsInt(commonEventHeaderJson, "sequence"));
+ vesAlarm.setSourceId(getAsString(commonEventHeaderJson, "sourceId"));
+ vesAlarm.setSourceName(getAsString(commonEventHeaderJson, "sourceName"));
+ vesAlarm.setStartEpochMicrosec(getAsLong(commonEventHeaderJson, "startEpochMicrosec"));
+ vesAlarm.setVersion(getAsLong(commonEventHeaderJson, "version"));
}
- private void convertFaultFieldsJsonToEvent(JSONObject faultFieldsJson, VesAlarm vesAlarm) {
+ private void convertFaultFieldsJsonToEvent(JsonObject faultFieldsJson, VesAlarm vesAlarm) {
vesAlarm.setAlarmAdditionalInformation(getListElementByNode(faultFieldsJson, "alarmAdditionalInformation"));
- vesAlarm.setAlarmCondition(faultFieldsJson.getString("alarmCondition"));
- vesAlarm.setAlarmInterfaceA(getTextElementByNode(faultFieldsJson, "alarmInterfaceA"));
- vesAlarm.setEventCategory(getTextElementByNode(faultFieldsJson,"eventCategory"));
- vesAlarm.setEventSeverity(faultFieldsJson.getString("eventSeverity"));
- vesAlarm.setEventSourceType(faultFieldsJson.getString("eventSourceType"));
- vesAlarm.setFaultFieldsVersion(faultFieldsJson.getLong("faultFieldsVersion"));
- vesAlarm.setSpecificProblem(faultFieldsJson.getString("specificProblem"));
- vesAlarm.setVfStatus(faultFieldsJson.getString("vfStatus"));
- }
-
- private String getTextElementByNode(JSONObject jsonNode,String name){
- if(jsonNode.get(name) != null){
- return jsonNode.getString(name);
- }
- return null;
- }
-
- private Long getLongElementByNode(JSONObject jsonNode, String name) {
- if(jsonNode.get(name) != null){
- return jsonNode.getLong(name);
- }
- return null;
+ vesAlarm.setAlarmCondition(getAsString(faultFieldsJson, "alarmCondition"));
+ vesAlarm.setAlarmInterfaceA(getAsString(faultFieldsJson, "alarmInterfaceA"));
+ vesAlarm.setEventCategory(getAsString(faultFieldsJson, "eventCategory"));
+ vesAlarm.setEventSeverity(getAsString(faultFieldsJson, "eventSeverity"));
+ vesAlarm.setEventSourceType(getAsString(faultFieldsJson, "eventSourceType"));
+ vesAlarm.setFaultFieldsVersion(getAsLong(faultFieldsJson, "faultFieldsVersion"));
+ vesAlarm.setSpecificProblem(getAsString(faultFieldsJson, "specificProblem"));
+ vesAlarm.setVfStatus(getAsString(faultFieldsJson, "vfStatus"));
}
- private List<AlarmAdditionalField> getListElementByNode(JSONObject jsonNode, String name){
- List<AlarmAdditionalField> alarms = new ArrayList<AlarmAdditionalField>();
- if (jsonNode.get(name) != null) {
- JSONArray alarmAdditionalInformations = jsonNode.getJSONArray(name);
- for (int i = 0; i < alarmAdditionalInformations.size(); i++) {
- JSONObject jsonObject = alarmAdditionalInformations.getJSONObject(i);
- if (jsonObject.get("name") != null
- && jsonObject.get("value") != null) {
- AlarmAdditionalField field = new AlarmAdditionalField();
- field.setName(getTextElementByNode(jsonObject, "name"));
- field.setValue(getTextElementByNode(jsonObject, "value"));
- alarms.add(field);
- }
- }
+ private List<AlarmAdditionalField> getListElementByNode(JsonObject jsonNode, String name) {
+ if (jsonNode.has(name) && !jsonNode.get(name).isJsonNull()) {
+ return jsonToList(jsonNode.get(name).toString(), AlarmAdditionalField.class);
}
- return alarms;
+ return Collections.emptyList();
}
}
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
index 9417242..49627fa 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
@@ -24,7 +24,6 @@ import org.onap.holmes.common.utils.HttpsUtils;
import org.onap.holmes.common.utils.MSBRegisterUtil;
import org.onap.holmes.common.utils.transactionid.TransactionIdFilter;
import org.onap.holmes.engine.dcae.DcaeConfigurationPolling;
-import org.onap.holmes.engine.resources.EngineResources;
import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
import org.onap.msb.sdk.discovery.entity.Node;
@@ -47,7 +46,6 @@ public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
public void run(EngineDAppConfig configuration, Environment environment) throws Exception {
super.run(configuration, environment);
- environment.jersey().register(new EngineResources());
try {
new MSBRegisterUtil().register2Msb(createMicroServiceInfo());
} catch (CorrelationException e) {
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java b/engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java
index f26a03d..6808e98 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java
@@ -26,16 +26,14 @@ import org.kie.api.builder.model.KieBaseModel;
import org.kie.api.builder.model.KieModuleModel;
import org.kie.api.builder.model.KieSessionModel;
import org.kie.api.conf.EqualityBehaviorOption;
-import org.kie.api.conf.EventProcessingOption;
import org.kie.api.io.Resource;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.conf.ClockTypeOption;
import org.kie.api.runtime.rule.FactHandle;
import org.onap.holmes.common.api.entity.AlarmInfo;
import org.onap.holmes.common.api.entity.CorrelationRule;
import org.onap.holmes.common.api.stat.VesAlarm;
-import org.onap.holmes.common.dmaap.DmaapService;
+import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;
import org.onap.holmes.common.exception.AlarmInfoException;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.DbDaoUtil;
@@ -56,20 +54,33 @@ import java.util.stream.Collectors;
@Service
public class DroolsEngine {
- @Inject
+ private final static int ENABLE = 1;
+ private final Map<String, String> deployed = new ConcurrentHashMap<>();
private RuleMgtWrapper ruleMgtWrapper;
- @Inject
private DbDaoUtil daoUtil;
-
- private final static int ENABLE = 1;
+ private ClosedLoopControlNameCache closedLoopControlNameCache;
private AlarmInfoDao alarmInfoDao;
- private final Map<String, String> deployed = new ConcurrentHashMap<>();
private KieServices ks = KieServices.Factory.get();
private ReleaseId releaseId = ks.newReleaseId("org.onap.holmes", "rules", "1.0.0-SNAPSHOT");
private ReleaseId compilationRelease = ks.newReleaseId("org.onap.holmes", "compilation", "1.0.0-SNAPSHOT");
private KieContainer container;
private KieSession session;
+ @Inject
+ public void setRuleMgtWrapper(RuleMgtWrapper ruleMgtWrapper) {
+ this.ruleMgtWrapper = ruleMgtWrapper;
+ }
+
+ @Inject
+ public void setDaoUtil(DbDaoUtil daoUtil) {
+ this.daoUtil = daoUtil;
+ }
+
+ @Inject
+ public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
+ this.closedLoopControlNameCache = closedLoopControlNameCache;
+ }
+
@PostConstruct
private void init() {
alarmInfoDao = daoUtil.getJdbiDaoByOnDemand(AlarmInfoDao.class);
@@ -120,7 +131,7 @@ public class DroolsEngine {
for (CorrelationRule rule : rules) {
if (!StringUtils.isEmpty(rule.getContent())) {
deployRule(rule.getContent());
- DmaapService.loopControlNames.put(rule.getPackageName(), rule.getClosedControlLoopName());
+ closedLoopControlNameCache.put(rule.getPackageName(), rule.getClosedControlLoopName());
}
}
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/resources/EngineResources.java b/engine-d/src/main/java/org/onap/holmes/engine/resources/EngineResources.java
index 3bfb2e8..0aa3a59 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/resources/EngineResources.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/resources/EngineResources.java
@@ -20,23 +20,9 @@ import com.codahale.metrics.annotation.Timed;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
import lombok.extern.slf4j.Slf4j;
import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.dmaap.DmaapService;
+import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.ExceptionUtil;
import org.onap.holmes.common.utils.LanguageUtil;
@@ -45,16 +31,30 @@ import org.onap.holmes.engine.request.CompileRuleRequest;
import org.onap.holmes.engine.request.DeployRuleRequest;
import org.onap.holmes.engine.response.CorrelationRuleResponse;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
@Service
@Path("/rule")
@Api(tags = {"Holmes Engine Management"})
@Produces(MediaType.APPLICATION_JSON)
@Slf4j
public class EngineResources {
- private Pattern packagePattern = Pattern.compile("package[\\s]+([^;]+)[;\\s]*");
-
@Inject
DroolsEngine droolsEngine;
+ private Pattern packagePattern = Pattern.compile("package[\\s]+([^;]+)[;\\s]*");
+ private ClosedLoopControlNameCache closedLoopControlNameCache;
+
+ @Inject
+ public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
+ this.closedLoopControlNameCache = closedLoopControlNameCache;
+ }
@PUT
@Produces(MediaType.APPLICATION_JSON)
@@ -74,13 +74,13 @@ public class EngineResources {
throw new CorrelationException("Could not find package name in rule: "+deployRuleRequest.getContent());
}
- DmaapService.loopControlNames
+ closedLoopControlNameCache
.put(packageName, deployRuleRequest.getLoopControlName());
String packageNameRet = droolsEngine.deployRule(deployRuleRequest);
if (!packageName.equals(packageNameRet)) {
log.info("The parsed package name is different from that returned by the engine.");
- DmaapService.loopControlNames.remove(packageName);
- DmaapService.loopControlNames
+ closedLoopControlNameCache.remove(packageName);
+ closedLoopControlNameCache
.put(packageNameRet, deployRuleRequest.getLoopControlName());
}
log.info("Rule deployed. Package name: " + packageNameRet);
@@ -108,7 +108,7 @@ public class EngineResources {
try {
droolsEngine.undeployRule(packageName);
- DmaapService.loopControlNames.remove(packageName);
+ closedLoopControlNameCache.remove(packageName);
} catch (CorrelationException correlationException) {
log.error(correlationException.getMessage(), correlationException);
throw ExceptionUtil.buildExceptionResponse(correlationException.getMessage());
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/utils/AlarmUtil.java b/engine-d/src/main/java/org/onap/holmes/engine/utils/AlarmUtil.java
index ca93066..c7eb02b 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/utils/AlarmUtil.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/utils/AlarmUtil.java
@@ -19,7 +19,6 @@ import java.util.HashMap;
import java.util.Map;
import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.api.stat.Alarm;
-import org.onap.holmes.common.producer.MQProducer;
@Service
public class AlarmUtil {
@@ -91,9 +90,4 @@ public class AlarmUtil {
rootPriorityMap.put(ruleId, map);
}
-
- public MQProducer getMqProducer() {
- MQProducer mqProducer = new MQProducer();
- return mqProducer;
- }
}
diff --git a/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java b/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java
index 85e3083..3b46fed 100644
--- a/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java
+++ b/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java
@@ -15,14 +15,12 @@
*/
package org.onap.holmes.dsa.dmaappolling;
-import com.alibaba.fastjson.JSONException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.holmes.common.api.stat.AlarmAdditionalField;
import org.onap.holmes.common.api.stat.VesAlarm;
-import org.onap.holmes.dsa.dmaappolling.DMaaPResponseUtil;
import org.powermock.core.classloader.annotations.PrepareForTest;
import java.io.IOException;
@@ -164,7 +162,7 @@ public class DMaaPResponseUtilTest {
@Test
public void testDMaaPResponseUtil_input_illegal() throws Exception {
String json = "***";
- thrown.expect(JSONException.class);
+ thrown.expect(Exception.class);
dMaaPResponseUtil.convertJsonToVesAlarm(json);
}
@@ -302,6 +300,10 @@ public class DMaaPResponseUtilTest {
List<AlarmAdditionalField> alarmAdditionalFields = new ArrayList<>();
AlarmAdditionalField alarmAdditionalField = new AlarmAdditionalField();
+ alarmAdditionalField.setName(null);
+ alarmAdditionalField.setValue("1111");
+ alarmAdditionalFields.add(alarmAdditionalField);
+ alarmAdditionalField = new AlarmAdditionalField();
alarmAdditionalField.setName("tian");
alarmAdditionalField.setValue("22222");
alarmAdditionalFields.add(alarmAdditionalField);
diff --git a/engine-d/src/test/java/org/onap/holmes/engine/manager/DroolsEngineTest.java b/engine-d/src/test/java/org/onap/holmes/engine/manager/DroolsEngineTest.java
index 8da4910..f7b7fbd 100644
--- a/engine-d/src/test/java/org/onap/holmes/engine/manager/DroolsEngineTest.java
+++ b/engine-d/src/test/java/org/onap/holmes/engine/manager/DroolsEngineTest.java
@@ -23,6 +23,7 @@ import org.junit.rules.ExpectedException;
import org.onap.holmes.common.api.entity.AlarmInfo;
import org.onap.holmes.common.api.entity.CorrelationRule;
import org.onap.holmes.common.api.stat.VesAlarm;
+import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.DbDaoUtil;
import org.onap.holmes.engine.db.AlarmInfoDao;
@@ -47,18 +48,21 @@ public class DroolsEngineTest {
private RuleMgtWrapper ruleMgtWrapper;
- private AlarmInfoDao alarmInfoDaoMock;
-
private DroolsEngine droolsEngine;
private DbDaoUtil dbDaoUtilStub;
+ private ClosedLoopControlNameCache closedLoopControlNameCache;
+
public DroolsEngineTest() throws Exception {
droolsEngine = new DroolsEngine();
ruleMgtWrapper = new RuleMgtWrapperStub();
dbDaoUtilStub = new DbDaoUtilStub();
- Whitebox.setInternalState(droolsEngine, "daoUtil", dbDaoUtilStub);
- Whitebox.setInternalState(droolsEngine, "ruleMgtWrapper", ruleMgtWrapper);
+ closedLoopControlNameCache = new ClosedLoopControlNameCache();
+ droolsEngine.setClosedLoopControlNameCache(closedLoopControlNameCache);
+ droolsEngine.setDaoUtil(dbDaoUtilStub);
+ droolsEngine.setRuleMgtWrapper(ruleMgtWrapper);
+
Whitebox.invokeMethod(droolsEngine, "init");
}
diff --git a/engine-d/src/test/java/org/onap/holmes/engine/resources/EngineResourcesTest.java b/engine-d/src/test/java/org/onap/holmes/engine/resources/EngineResourcesTest.java
index a09eb3a..aa2052d 100644
--- a/engine-d/src/test/java/org/onap/holmes/engine/resources/EngineResourcesTest.java
+++ b/engine-d/src/test/java/org/onap/holmes/engine/resources/EngineResourcesTest.java
@@ -20,6 +20,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.engine.manager.DroolsEngine;
import org.onap.holmes.engine.request.CompileRuleRequest;
@@ -36,13 +37,16 @@ import static org.easymock.EasyMock.*;
public class EngineResourcesTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- DroolsEngine droolsEngine;
+ private DroolsEngine droolsEngine;
private EngineResources engineResources;
+ private ClosedLoopControlNameCache closedLoopControlNameCache;
@Before
public void setUp() {
droolsEngine = PowerMock.createMock(DroolsEngine.class);
+ closedLoopControlNameCache = new ClosedLoopControlNameCache();
engineResources = new EngineResources();
+ engineResources.setClosedLoopControlNameCache(closedLoopControlNameCache);
Whitebox.setInternalState(engineResources,"droolsEngine", droolsEngine);
PowerMock.resetAll();
diff --git a/engine-d/src/test/java/org/onap/holmes/engine/utils/AlarmUtilTest.java b/engine-d/src/test/java/org/onap/holmes/engine/utils/AlarmUtilTest.java
index 97330a7..080ad2b 100644
--- a/engine-d/src/test/java/org/onap/holmes/engine/utils/AlarmUtilTest.java
+++ b/engine-d/src/test/java/org/onap/holmes/engine/utils/AlarmUtilTest.java
@@ -22,7 +22,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.holmes.common.api.stat.Alarm;
-import org.onap.holmes.common.producer.MQProducer;
import org.powermock.api.easymock.PowerMock;
import org.powermock.reflect.Whitebox;
@@ -127,10 +126,4 @@ public class AlarmUtilTest {
Integer priority = alarmUtil.getPriority(ruleId, probableCauseStr, rootAlarmFeatureStr, equipTypeStr, alarm);
Assert.assertThat(priority,IsEqual.equalTo(1));
}
-
- @Test
- public void getMqProducer() {
- MQProducer mqProducer = alarmUtil.getMqProducer();
- Assert.assertThat(mqProducer, IsNull.<MQProducer>notNullValue());
- }
}