summaryrefslogtreecommitdiffstats
path: root/engine-d/src/test/java
diff options
context:
space:
mode:
authorShiwei Tian <tian.shiwei@zte.com.cn>2018-03-15 12:21:15 +0800
committerShiwei Tian <tian.shiwei@zte.com.cn>2018-03-15 12:21:15 +0800
commit8754c29599ef6e59be3de0536514367f2256142f (patch)
tree0d135898f60ced4be847f23f61a07c8f833b4993 /engine-d/src/test/java
parentcbe0cf4e3070eeeb0edc7f3b7d61fc8a99f79e03 (diff)
Update the Drools Engine to Version 6.5.0
Issue-ID: HOLMES-99 Change-Id: I69169d590055e1bce928de7b0ef998cbdcf46edb Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
Diffstat (limited to 'engine-d/src/test/java')
-rw-r--r--engine-d/src/test/java/org/onap/holmes/engine/manager/DroolsEngineTest.java58
1 files changed, 34 insertions, 24 deletions
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 dd0b55d..3325efa 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,15 +23,18 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
-import org.drools.KnowledgeBase;
-import org.drools.KnowledgeBaseConfiguration;
-import org.drools.KnowledgeBaseFactory;
-import org.drools.conf.EventProcessingOption;
-import org.drools.runtime.StatefulKnowledgeSession;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.kie.api.KieBase;
+import org.kie.api.KieServices;
+import org.kie.api.builder.KieBuilder;
+import org.kie.api.builder.KieFileSystem;
+import org.kie.api.builder.KieRepository;
+import org.kie.api.io.KieResources;
+import org.kie.api.runtime.KieContainer;
+import org.kie.api.runtime.KieSession;
import org.onap.holmes.common.api.stat.VesAlarm;
import org.onap.holmes.engine.request.DeployRuleRequest;
import org.onap.holmes.common.api.entity.CorrelationRule;
@@ -39,7 +42,6 @@ import org.onap.holmes.common.constant.AlarmConst;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.engine.wrapper.RuleMgtWrapper;
import org.powermock.api.easymock.PowerMock;
-import org.powermock.modules.junit4.rule.PowerMockRule;
import org.powermock.reflect.Whitebox;
public class DroolsEngineTest {
@@ -47,37 +49,45 @@ public class DroolsEngineTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- @Rule
- public PowerMockRule powerMockRule = new PowerMockRule();
-
private RuleMgtWrapper ruleMgtWrapper;
- private KnowledgeBase kbase;
-
- private KnowledgeBaseConfiguration kconf;
-
- private StatefulKnowledgeSession ksession;
+ private KieBase kieBase;
+ private KieSession kieSession;
+ private KieContainer kieContainer;
+ private KieFileSystem kfs;
+ private KieServices ks;
+ private KieBuilder kieBuilder;
+ private KieResources resources;
+ private KieRepository kieRepository;
private DroolsEngine droolsEngine;
@Before
- public void setUp() {
+ public void setUp() throws Exception {
droolsEngine = new DroolsEngine();
- this.kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
- this.kconf.setOption(EventProcessingOption.STREAM);
- this.kconf.setProperty("drools.assertBehaviour", "equality");
- this.kbase = KnowledgeBaseFactory.newKnowledgeBase("D-ENGINE", this.kconf);
- this.ksession = kbase.newStatefulKnowledgeSession();
+ ks = KieServices.Factory.get();
+ resources = ks.getResources();
+ kieRepository = ks.getRepository();
+ kfs = Whitebox.invokeMethod(droolsEngine, "createKieFileSystemWithKProject", ks);
+ kieBuilder = ks.newKieBuilder(kfs).buildAll();
+ kieContainer = ks.newKieContainer(kieRepository.getDefaultReleaseId());
+ kieBase = kieContainer.getKieBase();
+ kieSession = kieContainer.newKieSession();
ruleMgtWrapper = PowerMock.createMock(RuleMgtWrapper.class);
Whitebox.setInternalState(droolsEngine, "ruleMgtWrapper", ruleMgtWrapper);
- Whitebox.setInternalState(droolsEngine, "kconf", kconf);
- Whitebox.setInternalState(droolsEngine, "kbase", kbase);
- Whitebox.setInternalState(droolsEngine, "ksession", ksession);
+ Whitebox.setInternalState(droolsEngine, "kieBase", kieBase);
+ Whitebox.setInternalState(droolsEngine, "kieSession", kieSession);
+ Whitebox.setInternalState(droolsEngine, "kieContainer", kieContainer);
+ Whitebox.setInternalState(droolsEngine, "kfs", kfs);
+ Whitebox.setInternalState(droolsEngine, "ks", ks);
+ Whitebox.setInternalState(droolsEngine, "kieBuilder", kieBuilder);
+ Whitebox.setInternalState(droolsEngine, "resources", resources);
+ Whitebox.setInternalState(droolsEngine, "kieRepository", kieRepository);
PowerMock.resetAll();
}
@@ -87,7 +97,7 @@ public class DroolsEngineTest {
List<CorrelationRule> rules = new ArrayList<CorrelationRule>();
CorrelationRule rule = new CorrelationRule();
- rule.setContent("content");
+ rule.setContent("package content");
rule.setClosedControlLoopName("test");
rule.setPackageName("org.onap.holmes");
rules.add(rule);