summaryrefslogtreecommitdiffstats
path: root/controlloop/templates
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-10-23 18:41:52 +0000
committerGerrit Code Review <gerrit@onap.org>2017-10-23 18:41:52 +0000
commitd0bbf403e259c97cd174fd3deebcb6ab5796cc61 (patch)
treed8839cd854ee088edd07184df3301bdf5b1f33da /controlloop/templates
parent11eaa447e8bf8f14e836a964a86934266c908072 (diff)
parent140980d872f84e854d636a21ca872b251b15891b (diff)
Merge "Fix handling of aai 'get' errors"
Diffstat (limited to 'controlloop/templates')
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl1
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java46
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java92
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java146
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java41
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java101
6 files changed, 311 insertions, 116 deletions
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 705bbcd25..65a601188 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -585,6 +585,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
$params.getClosedLoopControlName(),
drools.getRule().getName());
if ("SO".equals($operation.policy.getActor())) {
+ retract($opTimer);
retract($operation);
modify($manager) {finishOperation($operation)};
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
index f07ecbfae..9b3fbfe72 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
@@ -62,8 +62,8 @@ public class ControlLoopFailureTest implements TopicListener {
private static List<? extends TopicSink> noopTopics;
- private KieSession kieSession;
- private Util.Pair<ControlLoopPolicy, String> pair;
+ private static KieSession kieSession;
+ private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestId;
private UUID requestId2;
private UUID requestId3;
@@ -96,12 +96,34 @@ public class ControlLoopFailureTest implements TopicListener {
} catch (Exception e) {
fail(e.getMessage());
}
+
+ /*
+ * Start the kie session
+ */
+ try {
+ kieSession = startSession("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
+ "service=ServiceDemo;resource=Res1Demo;type=operational",
+ "CL_vCPE",
+ "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
+ } catch (IOException e) {
+ e.printStackTrace();
+ logger.debug("Could not create kieSession");
+ fail("Could not create kieSession");
+ }
}
@AfterClass
public static void tearDownSimulator() {
+ /*
+ * Gracefully shut down the kie session
+ */
+ kieSession.dispose();
+
HttpServletServer.factory.destroy();
PolicyEngine.manager.shutdown();
+ TopicEndpoint.manager.shutdown();
+ PolicyEngine.manager.stop();
}
/**
@@ -118,20 +140,6 @@ public class ControlLoopFailureTest implements TopicListener {
*/
@Test
public void targetLockedTest() {
- /*
- * Start the kie session
- */
- try {
- kieSession = startSession("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational",
- "CL_vCPE",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
/*
* Allows the PolicyEngine to callback to this object to
@@ -187,10 +195,6 @@ public class ControlLoopFailureTest implements TopicListener {
*/
dumpFacts(kieSession);
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
}
/**
@@ -210,7 +214,7 @@ public class ControlLoopFailureTest implements TopicListener {
* @return the kieSession to be used to insert facts
* @throws IOException
*/
- private KieSession startSession(String droolsTemplate,
+ private static KieSession startSession(String droolsTemplate,
String yamlFile,
String policyScope,
String policyName,
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
index ae8bcb4e4..bae7a5155 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
@@ -62,8 +62,8 @@ public class VCPEControlLoopTest implements TopicListener {
private static List<? extends TopicSink> noopTopics;
- private KieSession kieSession;
- private Util.Pair<ControlLoopPolicy, String> pair;
+ private static KieSession kieSession;
+ private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestID;
static {
@@ -93,16 +93,6 @@ public class VCPEControlLoopTest implements TopicListener {
} catch (Exception e) {
fail(e.getMessage());
}
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- PolicyEngine.manager.shutdown();
- }
-
- @Test
- public void successTest() {
/*
* Start the kie session
*/
@@ -117,6 +107,23 @@ public class VCPEControlLoopTest implements TopicListener {
logger.debug("Could not create kieSession");
fail("Could not create kieSession");
}
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ /*
+ * Gracefully shut down the kie session
+ */
+ kieSession.dispose();
+
+ HttpServletServer.factory.destroy();
+ PolicyEngine.manager.shutdown();
+ TopicEndpoint.manager.shutdown();
+ PolicyEngine.manager.stop();
+ }
+
+ @Test
+ public void successTest() {
/*
* Allows the PolicyEngine to callback to this object to
@@ -152,11 +159,46 @@ public class VCPEControlLoopTest implements TopicListener {
* Print what's left in memory
*/
dumpFacts(kieSession);
+ }
+
+ @Test
+ public void aaiGetFailTest() {
/*
- * Gracefully shut down the kie session
+ * Allows the PolicyEngine to callback to this object to
+ * notify that there is an event ready to be pulled
+ * from the queue
*/
- kieSession.dispose();
+ for (TopicSink sink : noopTopics) {
+ assertTrue(sink.start());
+ sink.register(this);
+ }
+
+ /*
+ * Create a unique requestId
+ */
+ requestID = UUID.randomUUID();
+
+ /*
+ * Simulate an onset event the policy engine will
+ * receive from DCAE to kick off processing through
+ * the rules
+ */
+ sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "getFail");
+
+
+ kieSession.fireUntilHalt();
+
+ /*
+ * The only fact in memory should be Params
+ */
+ assertEquals(1, kieSession.getFactCount());
+
+ /*
+ * Print what's left in memory
+ */
+ dumpFacts(kieSession);
+
}
/**
@@ -176,7 +218,7 @@ public class VCPEControlLoopTest implements TopicListener {
* @return the kieSession to be used to insert facts
* @throws IOException
*/
- private KieSession startSession(String droolsTemplate,
+ private static KieSession startSession(String droolsTemplate,
String yamlFile,
String policyScope,
String policyName,
@@ -234,7 +276,13 @@ public class VCPEControlLoopTest implements TopicListener {
String policyName = notification.policyName;
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-id"))) {
+ assertEquals(ControlLoopNotificationType.REJECTED, notification.notification);
+ kieSession.halt();
+ }
+ else {
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ }
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.policyName);
@@ -324,6 +372,18 @@ public class VCPEControlLoopTest implements TopicListener {
kieSession.insert(event);
}
+ protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vnfId) {
+ VirtualControlLoopEvent event = new VirtualControlLoopEvent();
+ event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
+ event.requestID = requestID;
+ event.target = "generic-vnf.vnf-id";
+ event.closedLoopAlarmStart = Instant.now();
+ event.AAI = new HashMap<>();
+ event.AAI.put("generic-vnf.vnf-id", vnfId);
+ event.closedLoopEventStatus = status;
+ kieSession.insert(event);
+ }
+
/**
* This method will dump all the facts in the working memory.
*
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
index c64764baf..9b9c2fe7c 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
@@ -62,8 +62,8 @@ public class VDNSControlLoopTest implements TopicListener {
private static List<? extends TopicSink> noopTopics;
- private KieSession kieSession;
- private Util.Pair<ControlLoopPolicy, String> pair;
+ private static KieSession kieSession;
+ private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestID;
static {
@@ -93,17 +93,7 @@ public class VDNSControlLoopTest implements TopicListener {
} catch (Exception e) {
fail(e.getMessage());
}
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- PolicyEngine.manager.shutdown();
- }
-
- @Test
- public void successTest() {
-
+
/*
* Start the kie session
*/
@@ -118,6 +108,24 @@ public class VDNSControlLoopTest implements TopicListener {
logger.debug("Could not create kieSession");
fail("Could not create kieSession");
}
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+
+ /*
+ * Gracefully shut down the kie session
+ */
+ kieSession.dispose();
+
+ HttpServletServer.factory.destroy();
+ PolicyEngine.manager.shutdown();
+ TopicEndpoint.manager.shutdown();
+ PolicyEngine.manager.stop();
+ }
+
+ @Test
+ public void successTest() {
/*
* Allows the PolicyEngine to callback to this object to
@@ -152,11 +160,90 @@ public class VDNSControlLoopTest implements TopicListener {
* Print what's left in memory
*/
dumpFacts(kieSession);
+ }
+
+ @Test
+ public void namedQueryFailTest() {
/*
- * Gracefully shut down the kie session
+ * Allows the PolicyEngine to callback to this object to
+ * notify that there is an event ready to be pulled
+ * from the queue
*/
- kieSession.dispose();
+ for (TopicSink sink : noopTopics) {
+ assertTrue(sink.start());
+ sink.register(this);
+ }
+
+ /*
+ * Create a unique requestId
+ */
+ requestID = UUID.randomUUID();
+
+ /*
+ * Simulate an onset event the policy engine will
+ * receive from DCAE to kick off processing through
+ * the rules
+ */
+ sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "error");
+
+ kieSession.fireUntilHalt();
+
+ /*
+ * The only fact in memory should be Params
+ */
+ assertEquals(1, kieSession.getFactCount());
+
+ /*
+ * Print what's left in memory
+ */
+ dumpFacts(kieSession);
+ }
+
+ @Test
+ public void aaiGetFailTest() {
+
+ /*
+ * Allows the PolicyEngine to callback to this object to
+ * notify that there is an event ready to be pulled
+ * from the queue
+ */
+ for (TopicSink sink : noopTopics) {
+ assertTrue(sink.start());
+ sink.register(this);
+ }
+
+ /*
+ * Create a unique requestId
+ */
+ requestID = UUID.randomUUID();
+
+ /*
+ * Simulate an onset event the policy engine will
+ * receive from DCAE to kick off processing through
+ * the rules
+ */
+ sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "getFail");
+
+ try {
+ kieSession.fireUntilHalt();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ logger.warn(e.toString());
+ fail(e.getMessage());
+ }
+
+
+ /*
+ * The only fact in memory should be Params
+ */
+ assertEquals(1, kieSession.getFactCount());
+
+ /*
+ * Print what's left in memory
+ */
+ dumpFacts(kieSession);
}
/**
@@ -176,7 +263,7 @@ public class VDNSControlLoopTest implements TopicListener {
* @return the kieSession to be used to insert facts
* @throws IOException
*/
- private KieSession startSession(String droolsTemplate,
+ private static KieSession startSession(String droolsTemplate,
String yamlFile,
String policyScope,
String policyName,
@@ -232,7 +319,13 @@ public class VDNSControlLoopTest implements TopicListener {
String policyName = notification.policyName;
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-id"))) {
+ assertEquals(ControlLoopNotificationType.REJECTED, notification.notification);
+ kieSession.halt();
+ }
+ else {
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ }
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.policyName);
@@ -266,7 +359,12 @@ public class VDNSControlLoopTest implements TopicListener {
}
else if (policyName.endsWith("EVENT.MANAGER")) {
logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
+ if ("error".equals(notification.AAI.get("vserver.vserver-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ }
+ else {
+ assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
+ }
kieSession.halt();
}
else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
@@ -303,6 +401,18 @@ public class VDNSControlLoopTest implements TopicListener {
kieSession.insert(event);
}
+ protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vserverName) {
+ VirtualControlLoopEvent event = new VirtualControlLoopEvent();
+ event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
+ event.requestID = requestID;
+ event.target = "vserver.vserver-name";
+ event.closedLoopAlarmStart = Instant.now();
+ event.AAI = new HashMap<>();
+ event.AAI.put("vserver.vserver-name", vserverName);
+ event.closedLoopEventStatus = status;
+ kieSession.insert(event);
+ }
+
/**
* This method will dump all the facts in the working memory.
*
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
index c139ab339..4a2b81399 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
@@ -64,8 +64,8 @@ public class VFCControlLoopTest implements TopicListener {
private static List<? extends TopicSink> noopTopics;
- private KieSession kieSession;
- private Util.Pair<ControlLoopPolicy, String> pair;
+ private static KieSession kieSession;
+ private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestID;
static {
@@ -95,18 +95,8 @@ public class VFCControlLoopTest implements TopicListener {
} catch (Exception e) {
fail(e.getMessage());
}
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- PolicyEngine.manager.shutdown();
- }
-
- @Test
- public void successTest() throws IOException {
-
/*
+ *
* Start the kie session
*/
try {
@@ -120,6 +110,24 @@ public class VFCControlLoopTest implements TopicListener {
logger.debug("Could not create kieSession");
fail("Could not create kieSession");
}
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+
+ /*
+ * Gracefully shut down the kie session
+ */
+ kieSession.dispose();
+
+ HttpServletServer.factory.destroy();
+ PolicyEngine.manager.shutdown();
+ TopicEndpoint.manager.shutdown();
+ PolicyEngine.manager.stop();
+ }
+
+ @Test
+ public void successTest() throws IOException {
/*
* Allows the PolicyEngine to callback to this object to
@@ -154,11 +162,6 @@ public class VFCControlLoopTest implements TopicListener {
* Print what's left in memory
*/
dumpFacts(kieSession);
-
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
}
/**
@@ -178,7 +181,7 @@ public class VFCControlLoopTest implements TopicListener {
* @return the kieSession to be used to insert facts
* @throws IOException
*/
- private KieSession startSession(String droolsTemplate,
+ private static KieSession startSession(String droolsTemplate,
String yamlFile,
String policyScope,
String policyName,
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
index 6424d02b6..54591cad0 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
@@ -35,7 +35,6 @@ import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
@@ -65,8 +64,8 @@ public class VFWControlLoopTest implements TopicListener {
private static List<? extends TopicSink> noopTopics;
- private KieSession kieSession;
- private Util.Pair<ControlLoopPolicy, String> pair;
+ private static KieSession kieSession;
+ private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestID;
static {
@@ -97,16 +96,6 @@ public class VFWControlLoopTest implements TopicListener {
} catch (Exception e) {
fail(e.getMessage());
}
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- PolicyEngine.manager.shutdown();
- }
-
- @Test
- public void successTest() {
/*
* Start the kie session
@@ -122,8 +111,25 @@ public class VFWControlLoopTest implements TopicListener {
logger.debug("Could not create kieSession");
fail("Could not create kieSession");
}
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ /*
+ * Gracefully shut down the kie session
+ */
+ kieSession.dispose();
- /*
+ HttpServletServer.factory.destroy();
+ PolicyEngine.manager.shutdown();
+ TopicEndpoint.manager.shutdown();
+ PolicyEngine.manager.stop();
+ }
+
+ @Test
+ public void successTest() {
+
+ /*
* Allows the PolicyEngine to callback to this object to
* notify that there is an event ready to be pulled
* from the queue
@@ -132,7 +138,7 @@ public class VFWControlLoopTest implements TopicListener {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
@@ -164,30 +170,10 @@ public class VFWControlLoopTest implements TopicListener {
* Print what's left in memory
*/
dumpFacts(kieSession);
-
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
}
@Test
- public void namedQueryFailTest() {
-
- /*
- * Start the kie session
- */
- try {
- kieSession = startSession("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vFW.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational",
- "CL_vFW",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
+ public void aaiFailTests() {
/*
* Allows the PolicyEngine to callback to this object to
@@ -210,7 +196,6 @@ public class VFWControlLoopTest implements TopicListener {
* the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "error");
-
try {
kieSession.fireUntilHalt();
}
@@ -220,7 +205,6 @@ public class VFWControlLoopTest implements TopicListener {
fail(e.getMessage());
}
-
/*
* The only fact in memory should be Params
*/
@@ -232,9 +216,36 @@ public class VFWControlLoopTest implements TopicListener {
dumpFacts(kieSession);
/*
- * Gracefully shut down the kie session
+ * Create a unique requestId
*/
- kieSession.dispose();
+ requestID = UUID.randomUUID();
+
+ /*
+ * Simulate an onset event the policy engine will
+ * receive from DCAE to kick off processing through
+ * the rules
+ */
+
+ sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "getFail");
+
+ try {
+ kieSession.fireUntilHalt();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ logger.warn(e.toString());
+ fail(e.getMessage());
+ }
+
+ /*
+ * The only fact in memory should be Params
+ */
+ assertEquals(1, kieSession.getFactCount());
+
+ /*
+ * Print what's left in memory
+ */
+ dumpFacts(kieSession);
}
/**
@@ -254,7 +265,7 @@ public class VFWControlLoopTest implements TopicListener {
* @return the kieSession to be used to insert facts
* @throws IOException
*/
- private KieSession startSession(String droolsTemplate,
+ private static KieSession startSession(String droolsTemplate,
String yamlFile,
String policyScope,
String policyName,
@@ -311,7 +322,13 @@ public class VFWControlLoopTest implements TopicListener {
String policyName = notification.policyName;
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-id"))) {
+ assertEquals(ControlLoopNotificationType.REJECTED, notification.notification);
+ kieSession.halt();
+ }
+ else {
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ }
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.policyName);