summaryrefslogtreecommitdiffstats
path: root/controlloop/templates
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/templates')
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl83
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java18
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java11
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java11
4 files changed, 59 insertions, 64 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 2f8d86127..725e01e22 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
@@ -294,49 +294,50 @@ rule "${policyName}.EVENT.MANAGER"
logger.info("{}: {}: event={} manager={} clTimer={}",
$params.getClosedLoopControlName(), drools.getRule().getName(),
$event, $manager, $clTimer);
- //
- // Check which event this is.
- //
- ControlLoopEventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
-
- //
- // Check what kind of event this is
- //
- if (eventStatus == NEW_EVENT_STATUS.SUBSEQUENT_ONSET) {
- //
- // We don't care about subsequent onsets
- //
- logger.info("{}: {}: subsequent onset",
- $params.getClosedLoopControlName(), drools.getRule().getName());
- retract($event);
- return;
- }
- if (eventStatus == NEW_EVENT_STATUS.SYNTAX_ERROR) {
- //
- // Ignore any bad syntax events
- //
- logger.warn("{}: {}: syntax error",
- $params.getClosedLoopControlName(), drools.getRule().getName());
- retract($event);
- return;
- }
- //
- // We only want the initial ONSET event in memory,
- // all the other events need to be retracted to support
- // cleanup and avoid the other rules being fired for this event.
- //
- if (eventStatus != NEW_EVENT_STATUS.FIRST_ONSET) {
- logger.warn("{}: {}: no first onset",
- $params.getClosedLoopControlName(), drools.getRule().getName());
- retract($event);
- }
- logger.debug("{}: {}: target={}", $params.getClosedLoopControlName(),
- drools.getRule().getName(), $event.target);
- //
- // Now start seeing if we need to process this event
- //
try {
+ //
+ // Check which event this is.
+ //
+ ControlLoopEventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
+ //
+ // Check what kind of event this is
+ //
+ if (eventStatus == NEW_EVENT_STATUS.SUBSEQUENT_ONSET) {
+ //
+ // We don't care about subsequent onsets
+ //
+ logger.info("{}: {}: subsequent onset",
+ $params.getClosedLoopControlName(), drools.getRule().getName());
+ retract($event);
+ return;
+ }
+ if (eventStatus == NEW_EVENT_STATUS.SYNTAX_ERROR) {
+ //
+ // Ignore any bad syntax events
+ //
+ logger.warn("{}: {}: syntax error",
+ $params.getClosedLoopControlName(), drools.getRule().getName());
+ retract($event);
+ return;
+ }
+ //
+ // We only want the initial ONSET event in memory,
+ // all the other events need to be retracted to support
+ // cleanup and avoid the other rules being fired for this event.
+ //
+ if (eventStatus != NEW_EVENT_STATUS.FIRST_ONSET) {
+ logger.warn("{}: {}: no first onset",
+ $params.getClosedLoopControlName(), drools.getRule().getName());
+ retract($event);
+ }
+
+ logger.debug("{}: {}: target={}", $params.getClosedLoopControlName(),
+ drools.getRule().getName(), $event.target);
+ //
+ // Now start seeing if we need to process this event
+ //
+
//
// Check if this is a Final Event
//
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 aaa40d1ad..55812f154 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
@@ -279,13 +279,7 @@ public class VCPEControlLoopTest implements TopicListener {
String policyName = notification.policyName;
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.policyName);
- if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-name"))) {
- assertEquals(ControlLoopNotificationType.REJECTED, notification.notification);
- kieSession.halt();
- }
- else {
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
- }
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.policyName);
@@ -320,8 +314,14 @@ public class VCPEControlLoopTest implements TopicListener {
}
else if (policyName.endsWith("EVENT.MANAGER")) {
logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
- kieSession.halt();
+ if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ kieSession.halt();
+ }
+ else {
+ assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
+ kieSession.halt();
+ }
}
else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.policyName);
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 3e1785d18..f7e2c3049 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
@@ -322,13 +322,7 @@ public class VDNSControlLoopTest implements TopicListener {
String policyName = notification.policyName;
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.policyName);
- if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-id"))) {
- assertEquals(ControlLoopNotificationType.REJECTED, notification.notification);
- kieSession.halt();
- }
- else {
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
- }
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.policyName);
@@ -365,6 +359,9 @@ public class VDNSControlLoopTest implements TopicListener {
if ("error".equals(notification.AAI.get("vserver.vserver-name"))) {
assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
}
+ else if ("getFail".equals(notification.AAI.get("vserver.vserver-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ }
else {
assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
}
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 601eef0eb..5ef20b544 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
@@ -325,13 +325,7 @@ public class VFWControlLoopTest implements TopicListener {
String policyName = notification.policyName;
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.policyName);
- if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-name"))) {
- assertEquals(ControlLoopNotificationType.REJECTED, notification.notification);
- kieSession.halt();
- }
- else {
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
- }
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.policyName);
@@ -370,6 +364,9 @@ public class VFWControlLoopTest implements TopicListener {
assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
assertEquals("Target vnf-id could not be found", notification.message);
}
+ else if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ }
else {
assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
}