summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/test/java
diff options
context:
space:
mode:
authorpramod.jamkhedkar <pramod@research.att.com>2019-04-10 21:22:01 -0400
committerpramod.jamkhedkar <pramod@research.att.com>2019-04-11 10:10:05 -0400
commit080dd34e7f506027c2dc1a87ddc4c9aa347a9c59 (patch)
tree7353b069f01f85fee1d176adee40012022372b0e /controlloop/common/eventmanager/src/test/java
parent92fc7744a4df901d1688b9fa8da899372ea76fd8 (diff)
Drools-App changes to support CQ
Changes in event manager to support Aai custom query Issue-ID: POLICY-1278 Change-Id: I693dd6b94f1fa6f24b08a389db099914636cf2ba Signed-off-by: pramod.jamkhedkar <pramod@research.att.com>
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.java44
2 files changed, 47 insertions, 24 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 7c3a38b38..bce96b2f0 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
@@ -43,6 +43,7 @@ import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.aai.AaiGetVnfResponse;
import org.onap.policy.aai.AaiGetVserverResponse;
import org.onap.policy.aai.AaiNqRequestError;
@@ -80,6 +81,7 @@ public class ControlLoopEventManagerTest {
private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManagerTest.class);
+
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -558,7 +560,7 @@ public class ControlLoopEventManagerTest {
VirtualControlLoopNotification clfNotification = manager.isControlLoopFinal();
assertNull(clfNotification);
-
+
// serialize and de-serialize manager
manager = Serializer.roundTrip(manager);
@@ -632,7 +634,7 @@ public class ControlLoopEventManagerTest {
ControlLoopOperationManager clom = manager.processControlLoop();
assertNotNull(clom);
assertNull(clom.getOperationResult());
-
+
// serialize and de-serialize manager
manager = Serializer.roundTrip(manager);
@@ -724,7 +726,7 @@ public class ControlLoopEventManagerTest {
}
assertNull(manager.unlockCurrentOperation());
-
+
// serialize and de-serialize manager
manager = Serializer.roundTrip(manager);
@@ -917,7 +919,7 @@ public class ControlLoopEventManagerTest {
try {
onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, Boolean.TRUE.toString());
onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS,
- ControlLoopEventManager.PROV_STATUS_ACTIVE);
+ ControlLoopEventManager.PROV_STATUS_ACTIVE);
mgr = makeManager(onset);
mgr.queryAai(onset);
@@ -1290,6 +1292,23 @@ public class ControlLoopEventManagerTest {
assertNull(manager.getNqVserverFromAai());
}
+ @Test
+ public void testGetCqResponse() {
+ try {
+ ControlLoopEventManager mgr = null;
+ mgr = makeManager(onset);
+ mgr.queryAai(onset);
+ AaiCqResponse aaiCqResponse = mgr.getCqResponse(onset);
+ assertNotNull(aaiCqResponse);
+
+
+ } catch (Exception e) {
+ logger.error("testGetCqResponse Exception: ", e);
+ fail(e.getMessage());
+ }
+ }
+
+
private ControlLoopEventManager makeManager(VirtualControlLoopEvent event) {
return new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
}
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 82da603ff..d722cc220 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -119,7 +119,7 @@ public class ControlLoopOperationManagerTest {
return numEvents;
}
-
+
/**
* Set up test class.
*/
@@ -131,7 +131,7 @@ public class ControlLoopOperationManagerTest {
} catch (Exception e) {
fail(e.getMessage());
}
-
+
// Set PU
System.setProperty("OperationsHistoryPU", "TestOperationsHistoryPU");
@@ -155,7 +155,7 @@ public class ControlLoopOperationManagerTest {
emf.close();
HttpServletServer.factory.destroy();
}
-
+
@Test
public void testRetriesFail() {
//
@@ -479,8 +479,11 @@ public class ControlLoopOperationManagerTest {
onsetEvent.getAai().remove("generic-vnf.vnf-id");
manager.getVnfResponse();
- clom.getEventManager().getVnfResponse().setVnfId("generic-vnf.vnf-id");
- assertEquals("generic-vnf.vnf-id", clom.getTarget(policy));
+ if (!Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty("aai.customQuery"))) {
+ clom.getEventManager().getVnfResponse().setVnfId("generic-vnf.vnf-id");
+ assertEquals("generic-vnf.vnf-id", clom.getTarget(policy));
+ }
+
policy.getTarget().setType(TargetType.VFC);
try {
@@ -550,6 +553,7 @@ public class ControlLoopOperationManagerTest {
clom = new ControlLoopOperationManager(onsetEvent, policy, manager);
assertNotNull(clom);
+
policy.setActor("SO");
clom = new ControlLoopOperationManager(onsetEvent, policy, manager);
assertNotNull(clom);
@@ -804,13 +808,13 @@ public class ControlLoopOperationManagerTest {
System.setProperty("OperationsHistoryPU", "TestOperationsHistoryPU");
assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw));
- }
+ }
@Test
public void testCommitAbatement() throws ControlLoopException, AaiException, IOException {
String yamlString = null;
- try ( InputStream is = new FileInputStream(new File("src/test/resources/test.yaml")) ) {
+ try (InputStream is = new FileInputStream(new File("src/test/resources/test.yaml"))) {
yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
} catch (Exception e) {
fail(e.getMessage());
@@ -835,19 +839,19 @@ public class ControlLoopOperationManagerTest {
Policy policy = manager.getProcessor().getCurrentPolicy();
ControlLoopOperationManager clom = new ControlLoopOperationManager(onsetEvent, policy, manager);
assertNotNull(clom);
-
+
clom.startOperation(onsetEvent);
int numEventsBefore = getCount();
- logger.info("numEventsBefore={}", numEventsBefore);
-
- clom.commitAbatement("Test message","TEST_RESULT");
+ logger.info("numEventsBefore={}", numEventsBefore);
+
+ clom.commitAbatement("Test message", "TEST_RESULT");
int numEventsAfter = getCount();
- logger.info("numEventsAfter={}", numEventsAfter);
-
- assertEquals(1, numEventsAfter - numEventsBefore);
- }
+ logger.info("numEventsAfter={}", numEventsAfter);
+
+ assertEquals(1, numEventsAfter - numEventsBefore);
+ }
@Test
public void testSerialization() throws Exception {
@@ -876,7 +880,7 @@ public class ControlLoopOperationManagerTest {
clom.startOperation(onsetEvent);
assertTrue(clom.isOperationRunning());
-
+
clom = Serializer.roundTrip(clom);
assertNotNull(clom);
assertTrue(clom.isOperationRunning());
@@ -893,7 +897,7 @@ public class ControlLoopOperationManagerTest {
assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw));
assertFalse(clom.isOperationRunning());
assertEquals(1, clom.getHistory().size());
-
+
clom = Serializer.roundTrip(clom);
assertNotNull(clom);
assertFalse(clom.isOperationRunning());
@@ -901,7 +905,7 @@ public class ControlLoopOperationManagerTest {
System.setProperty("OperationsHistoryPU", "TestOperationsHistoryPU");
assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw));
-
+
clom = Serializer.roundTrip(clom);
assertNotNull(clom);
assertFalse(clom.isOperationRunning());