summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/test/java
diff options
context:
space:
mode:
authorRashmi Pujar <rashmi.pujar@bell.ca>2019-10-29 16:17:37 -0400
committerRashmi Pujar <rashmi.pujar@bell.ca>2019-11-04 14:25:47 -0500
commit3819d5070b2a1d4599f8f3547331869d664c2bd5 (patch)
treec9abb19a17a89ee972af37bf024b96efc3ddd894 /controlloop/common/eventmanager/src/test/java
parent114380115eabbc093102511667bf5ee9341d8fc7 (diff)
PNF support changes for drools-application
Conditional checks for enrichment and validation by target-types PNF specific AAI enrichment Fixed Unit Tests Issue-ID: POLICY-1187 Signed-off-by: Rashmi Pujar <rashmi.pujar@bell.ca> Change-Id: I78bf73e454828253ca69695f9196047449b4d9d6
Diffstat (limited to 'controlloop/common/eventmanager/src/test/java')
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java27
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java24
2 files changed, 45 insertions, 6 deletions
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
index 8efdb1fcb..c9202904c 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
@@ -66,6 +66,7 @@ import org.onap.policy.common.utils.io.Serializer;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.ControlLoopNotificationType;
+import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.SupportUtil;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
@@ -126,6 +127,7 @@ public class ControlLoopEventManagerTest {
PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_USERNAME, "AAI");
PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_PASS, "AAI");
PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_URL, "http://localhost:6666");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.customQuery", "false");
}
@AfterClass
@@ -145,11 +147,12 @@ public class ControlLoopEventManagerTest {
onset.setRequestId(UUID.randomUUID());
onset.setTarget("VM_NAME");
onset.setClosedLoopAlarmStart(Instant.now());
- onset.setAai(new HashMap<String, String>());
+ onset.setAai(new HashMap<>());
onset.getAai().put("cloud-region.identity-url", "foo");
onset.getAai().put("vserver.selflink", "bar");
onset.getAai().put(VNF_ID, VNF_UUID);
onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
+ onset.setTargetType(ControlLoopTargetType.VNF);
PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_URL, "http://localhost:6666");
}
@@ -212,6 +215,7 @@ public class ControlLoopEventManagerTest {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event.setAai(new HashMap<>());
event.getAai().put(VNF_NAME, ONSET_ONE);
+ event.setTargetType(ControlLoopTargetType.VNF);
ControlLoopEventManager manager = makeManager(event);
VirtualControlLoopNotification notification = manager.activate(event);
@@ -236,6 +240,7 @@ public class ControlLoopEventManagerTest {
event2.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event2.setAai(new HashMap<>());
event2.getAai().put(VNF_NAME, "onsetTwo");
+ event2.setTargetType(ControlLoopTargetType.VNF);
status = manager.onNewEvent(event2);
@@ -440,6 +445,7 @@ public class ControlLoopEventManagerTest {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event.setAai(new HashMap<>());
event.getAai().put(VNF_NAME, ONSET_ONE);
+ event.setTargetType(ControlLoopTargetType.VNF);
ControlLoopEventManager manager = makeManager(event);
manager.setActivated(true);
@@ -459,6 +465,7 @@ public class ControlLoopEventManagerTest {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event.setAai(new HashMap<>());
event.getAai().put(VNF_NAME, ONSET_ONE);
+ event.setTargetType(ControlLoopTargetType.VNF);
ControlLoopEventManager manager = makeManager(event);
@@ -505,6 +512,7 @@ public class ControlLoopEventManagerTest {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event.setAai(new HashMap<>());
event.getAai().put(VNF_NAME, ONSET_ONE);
+ event.setTargetType(ControlLoopTargetType.VNF);
ControlLoopEventManager manager = makeManager(event);
ControlLoopEventManager manager2 = manager;
@@ -572,6 +580,8 @@ public class ControlLoopEventManagerTest {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event.setAai(new HashMap<>());
event.getAai().put(VNF_NAME, ONSET_ONE);
+ event.getAai().put(VSERVER_NAME, "test-vserver");
+ event.setTargetType(ControlLoopTargetType.VNF);
ControlLoopEventManager manager = makeManager(event);
ControlLoopEventManager manager2 = manager;
@@ -781,6 +791,7 @@ public class ControlLoopEventManagerTest {
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
VirtualControlLoopEvent abatedEvent = new VirtualControlLoopEvent();
abatedEvent.setClosedLoopControlName(TWO_ONSET_TEST);
@@ -846,6 +857,9 @@ public class ControlLoopEventManagerTest {
checkSyntaxEvent.setAai(new HashMap<>());
assertEquals(NewEventStatus.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
+ checkSyntaxEvent.setTargetType("");
+ assertEquals(NewEventStatus.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
+
checkSyntaxEvent.setTarget("");
assertEquals(NewEventStatus.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
@@ -900,6 +914,7 @@ public class ControlLoopEventManagerTest {
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
ControlLoopEventManager manager = makeManager(onsetEvent);
assertTrue(0 == manager.getControlLoopTimeout(null));
@@ -926,6 +941,7 @@ public class ControlLoopEventManagerTest {
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
ControlLoopEventManager manager = makeManager(onsetEvent);
@@ -951,6 +967,7 @@ public class ControlLoopEventManagerTest {
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
ControlLoopEventManager manager = makeManager(onsetEvent);
@@ -972,8 +989,8 @@ public class ControlLoopEventManagerTest {
ControlLoopEventManager mgr = makeManager(onset);
- assertThatThrownBy(() -> mgr.queryAai(onset)).isInstanceOf(AaiException.class)
- .hasMessage("is-closed-loop-disabled is set to true on VServer or VNF");
+ assertThatThrownBy(() -> mgr.queryAai(onset)).isInstanceOf(AaiException.class).hasMessage(
+ "is-closed-loop-disabled is set to true on VServer or VNF or in-maint is set to true for PNF");
assertNull(mgr.getVnfResponse());
assertNull(mgr.getVserverResponse());
}
@@ -986,7 +1003,7 @@ public class ControlLoopEventManagerTest {
ControlLoopEventManager mgr = makeManager(onset);
assertThatThrownBy(() -> mgr.queryAai(onset)).isInstanceOf(AaiException.class)
- .hasMessage("prov-status is not ACTIVE on VServer or VNF");
+ .hasMessage("prov-status is not ACTIVE on VServer or VNF or PNF");
assertNull(mgr.getVnfResponse());
assertNull(mgr.getVserverResponse());
}
@@ -1343,6 +1360,8 @@ public class ControlLoopEventManagerTest {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event.setAai(new HashMap<>());
event.getAai().put(VNF_ID, ONSET_ONE);
+ event.getAai().put(VSERVER_NAME, "test-vserver");
+ event.setTargetType(ControlLoopTargetType.VNF);
return event;
}
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
index 480bc290e..b3e2e2181 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
@@ -64,6 +64,7 @@ import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.SupportUtil;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
+import org.onap.policy.controlloop.policy.ControlLoop;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
@@ -108,12 +109,15 @@ public class ControlLoopOperationManagerTest {
onset.setClosedLoopAlarmStart(Instant.now());
onset.setAai(new HashMap<>());
onset.getAai().put(VNF_NAME, "testTriggerSource");
+ onset.getAai().put(VSERVER_NAME, "testVserverName");
onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
+ onset.setTargetType(ControlLoopTargetType.VNF);
/* Set environment properties */
PolicyEngineConstants.getManager().setEnvironmentProperty("aai.url", "http://localhost:6666");
PolicyEngineConstants.getManager().setEnvironmentProperty("aai.username", "AAI");
PolicyEngineConstants.getManager().setEnvironmentProperty("aai.password", "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.customQuery", "false");
}
private static EntityManagerFactory emf;
@@ -390,10 +394,12 @@ public class ControlLoopOperationManagerTest {
onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST);
onsetEvent.setRequestId(requestId);
onsetEvent.setTarget(VNF_ID);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.getAai().put(VSERVER_NAME, "testVserverName");
ControlLoopEventManager manager =
new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
@@ -428,7 +434,8 @@ public class ControlLoopOperationManagerTest {
policy.setTarget(savedTarget);
policy.getTarget().setType(TargetType.PNF);
- assertThatThrownBy(() -> clom.getTarget(policy)).hasMessage("PNF target is not supported");
+ assertThatThrownBy(() -> clom.getTarget(policy)).hasMessage(
+ "Target in the onset event is either null or does not match target key expected in AAI section.");
onsetEvent.setTarget("Oz");
onsetEvent.getAai().remove(VNF_NAME);
@@ -495,10 +502,12 @@ public class ControlLoopOperationManagerTest {
onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST);
onsetEvent.setRequestId(requestId);
onsetEvent.setTarget(VNF_ID);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.getAai().put(VSERVER_NAME, "testVserverName");
ControlLoopEventManager manager =
new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
@@ -543,10 +552,12 @@ public class ControlLoopOperationManagerTest {
onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST);
onsetEvent.setRequestId(requestId);
onsetEvent.setTarget(VNF_ID);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.getAai().put(VSERVER_NAME, "testVserverName");
ControlLoopEventManager manager =
new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
@@ -631,10 +642,12 @@ public class ControlLoopOperationManagerTest {
onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST);
onsetEvent.setRequestId(requestId);
onsetEvent.setTarget(VNF_ID);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.getAai().put(VSERVER_NAME, "testVserverName");
ControlLoopEventManager manager =
new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
@@ -726,10 +739,12 @@ public class ControlLoopOperationManagerTest {
onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST);
onsetEvent.setRequestId(requestId);
onsetEvent.setTarget(VNF_ID);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.getAai().put(VSERVER_NAME, "testVserverName");
ControlLoopEventManager manager =
new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
@@ -772,6 +787,7 @@ public class ControlLoopOperationManagerTest {
event.setClosedLoopControlName(TWO_ONSET_TEST);
event.setRequestId(requestId);
event.setTarget(VNF_ID);
+ event.setTargetType(ControlLoopTargetType.VNF);
event.setClosedLoopAlarmStart(Instant.now());
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
event.setAai(new HashMap<>());
@@ -801,7 +817,7 @@ public class ControlLoopOperationManagerTest {
@Test
public void testCommitAbatement() throws Exception {
- String yamlString = null;
+ String yamlString;
try (InputStream is = new FileInputStream(new File(TEST_YAML))) {
yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
}
@@ -811,10 +827,12 @@ public class ControlLoopOperationManagerTest {
onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST);
onsetEvent.setRequestId(requestId);
onsetEvent.setTarget(VNF_ID);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.getAai().put(VSERVER_NAME, "testVserverName");
ControlLoopEventManager manager =
new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
@@ -850,10 +868,12 @@ public class ControlLoopOperationManagerTest {
onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST);
onsetEvent.setRequestId(requestId);
onsetEvent.setTarget(VNF_ID);
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
onsetEvent.setAai(new HashMap<>());
onsetEvent.getAai().put(VNF_NAME, ONSET_ONE);
+ onsetEvent.getAai().put(VSERVER_NAME, "testVserverName");
ControlLoopEventManager manager =
new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());