summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/test
diff options
context:
space:
mode:
authorJoseph Chou <jc2555@att.com>2017-09-19 16:39:56 -0400
committerJoseph Chou <jc2555@att.com>2017-09-21 15:13:18 -0400
commitac8208cc9ce66062fe4edf54f19ad933f9b0ab99 (patch)
tree400c59fa1004e1610ce3a2e19eccd55e4e1e6307 /controlloop/common/eventmanager/src/test
parent2313dd4767975e7d814e52613afab8054b84208c (diff)
ONAP AAI GET QUERY code to support ONAP project
check in code to use simulator url Issue-ID: POLICY-103 Change-Id: I352140dd3cb3159fc2c5738bf02dbb6272de48bc Signed-off-by: Joseph Chou <jc2555@att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/test')
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java113
1 files changed, 84 insertions, 29 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 2e208748f..745841049 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
@@ -27,6 +27,8 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.UUID;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.aai.AAIGETVnfResponse;
import org.onap.policy.aai.AAIGETVserverResponse;
@@ -40,6 +42,8 @@ import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.Util;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,27 +64,79 @@ public class ControlLoopEventManagerTest {
onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
}
+ @BeforeClass
+ public static void setUpSimulator() {
+ try {
+ org.onap.policy.simulators.Util.buildAaiSim();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
+ @Test
+ public void testAAIVnfInfo() {
+ final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
+ onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ try {
+ setAAIProperties();
+ AAIGETVnfResponse response = getQueryByVnfID2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/network/generic-vnfs/generic-vnf/",
+ PolicyEngine.manager.getEnvironmentProperty("aai.user"),
+ PolicyEngine.manager.getEnvironmentProperty("aai.password"),
+ UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
+ assertNotNull(response);
+ logger.info("testAAIVnfInfo test result is " + (response == null ? "null" : "not null"));
+ } catch (Exception e) {
+ logger.error("testAAIVnfInfo Exception: ", e);
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testAAIVnfInfo2() {
+ final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
+ onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ try {
+ setAAIProperties();
+ AAIGETVnfResponse response = getQueryByVnfName2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=",
+ PolicyEngine.manager.getEnvironmentProperty("aai.user"),
+ PolicyEngine.manager.getEnvironmentProperty("aai.password"),
+ UUID.randomUUID(), "lll_vnf_010317");
+ assertNotNull(response);
+ logger.info("testAAIVnfInfo2 test result is " + (response == null ? "null" : "not null"));
+ } catch (Exception e) {
+ logger.error("testAAIVnfInfo2 Exception: ", e);
+ fail(e.getMessage());
+ }
+ }
+
@Test
- public void testGetAAIInfo() {
+ public void testAAIVserver() {
final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
try {
- @SuppressWarnings("unused")
- ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID);
- onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
-
- String user = "POLICY";
- String password = "POLICY";
- String vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491";
- String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf/";
- AAIGETVnfResponse response = getQueryByVnfID2(url, user, password, onset.requestID, vnfID);
+ setAAIProperties();
+ AAIGETVserverResponse response = getQueryByVserverName2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/nodes/vservers?vserver-name=",
+ PolicyEngine.manager.getEnvironmentProperty("aai.user"),
+ PolicyEngine.manager.getEnvironmentProperty("aai.password"),
+ UUID.randomUUID(), "USMSO1SX7NJ0103UJZZ01-vjunos0");
assertNotNull(response);
- logger.info("testGetAAIInfo test result is " + (response == null ? "null" : "not null"));
+ logger.info("testAAIVserver test result is " + (response == null ? "null" : "not null"));
} catch (Exception e) {
+ logger.error("testAAIVserver Exception: ", e);
fail(e.getMessage());
- logger.error("testGetAAIInfo Exception: ", e);
}
}
+
+ private void setAAIProperties() {
+ PolicyEngine.manager.setEnvironmentProperty("aai.user", "AAI");
+ PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
+ PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
+ }
@Test
public void testIsClosedLoopDisabled() {
@@ -91,31 +147,30 @@ public class ControlLoopEventManagerTest {
onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
try {
- onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
-
logger.info("testIsClosedLoopDisabled --");
- String user = "POLICY";
- String password = "POLICY";
- String vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491";
- String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf/";
- AAIGETVnfResponse response = getQueryByVnfID2(url, user, password, onset.requestID, vnfID);
+ setAAIProperties();
+ AAIGETVnfResponse response = getQueryByVnfID2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/network/generic-vnfs/generic-vnf/",
+ PolicyEngine.manager.getEnvironmentProperty("aai.user"),
+ PolicyEngine.manager.getEnvironmentProperty("aai.password"),
+ UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
assertNotNull(response);
boolean disabled = ControlLoopEventManager.isClosedLoopDisabled(response);
logger.info("QueryByVnfID - isClosedLoopDisabled: " + disabled);
- String vnfName = "lll_vnf_010317";
- url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
- response = getQueryByVnfName2(url, user, password, onset.requestID, vnfName);
+ response = getQueryByVnfName2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=",
+ PolicyEngine.manager.getEnvironmentProperty("aai.user"),
+ PolicyEngine.manager.getEnvironmentProperty("aai.password"),
+ UUID.randomUUID(), "lll_vnf_010317");
assertNotNull(response);
disabled = ControlLoopEventManager.isClosedLoopDisabled(response);
- logger.info("QueryByVnfName2 - isClosedLoopDisabled: " + disabled);
+ logger.info("QueryByVnfName - isClosedLoopDisabled: " + disabled);
- String vserverName = "USMSO1SX7NJ0103UJZZ01-vjunos0";
- url = "https://aai-ext1.test.att.com:8443//aai/v11/nodes/vservers?vserver-name=";
- @SuppressWarnings("unused")
- AAIGETVserverResponse response2 = getQueryByVserverName2(url, user, password, onset.requestID, vserverName);
- assertNotNull(response);
- disabled = ControlLoopEventManager.isClosedLoopDisabled(response);
+ AAIGETVserverResponse response2 = getQueryByVserverName2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/nodes/vservers?vserver-name=",
+ PolicyEngine.manager.getEnvironmentProperty("aai.user"),
+ PolicyEngine.manager.getEnvironmentProperty("aai.password"),
+ UUID.randomUUID(), "USMSO1SX7NJ0103UJZZ01-vjunos0");
+ assertNotNull(response2);
+ disabled = ControlLoopEventManager.isClosedLoopDisabled(response2);
logger.info("QueryByVserverName - isClosedLoopDisabled: " + disabled);
} catch (Exception e) {
fail(e.getMessage());