summaryrefslogtreecommitdiffstats
path: root/controlloop/templates/template.demo.v1.0.0/template.demo/src/test
diff options
context:
space:
mode:
authordaniel <dc443y@att.com>2017-10-06 10:08:21 -0500
committerdaniel <dc443y@att.com>2017-10-06 10:08:35 -0500
commitff94dea51430832d739c0e932b3df13dd1d7ccfc (patch)
tree8894e0db8acfe6246289b951ca138bb36aecdcfc /controlloop/templates/template.demo.v1.0.0/template.demo/src/test
parentdb6d2468fc672a23ed152b8624b34de01ff13233 (diff)
Fix Build Errors
Removing the legacy "demo" project as this uses obsolete code. The operation and control loop timeouts were increased to allow more time for the simulators to respond. Issue-Id: POLICY-291 Change-Id: I1143352cefaf9749ca0eca55927960535b2599b8 Signed-off-by: Daniel Cruz <dc443y@att.com>
Diffstat (limited to 'controlloop/templates/template.demo.v1.0.0/template.demo/src/test')
-rw-r--r--controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java61
-rw-r--r--controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java594
-rw-r--r--controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java163
-rw-r--r--controlloop/templates/template.demo.v1.0.0/template.demo/src/test/resources/aairesponse.json227
4 files changed, 0 insertions, 1045 deletions
diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java
deleted file mode 100644
index 42b28d2f4..000000000
--- a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestAPPCPayload.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * demo
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.template.demo;
-
-import java.util.HashMap;
-import java.util.UUID;
-
-import org.junit.Test;
-import org.onap.policy.appc.CommonHeader;
-import org.onap.policy.appc.Request;
-import org.onap.policy.appc.util.Serialization;
-import org.onap.policy.vnf.trafficgenerator.PGRequest;
-import org.onap.policy.vnf.trafficgenerator.PGStream;
-import org.onap.policy.vnf.trafficgenerator.PGStreams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TestAPPCPayload {
-
- private static final Logger logger = LoggerFactory.getLogger(TestAPPCPayload.class);
- @Test
- public void test() {
- PGRequest request = new PGRequest();
- request.pgStreams = new PGStreams();
-
- PGStream pgStream;
- for(int i = 0; i < 5; i++){
- pgStream = new PGStream();
- pgStream.streamId = "fw_udp"+(i+1);
- pgStream.isEnabled = "true";
- request.pgStreams.pgStream.add(pgStream);
- }
-
- Request appc = new Request();
- appc.CommonHeader = new CommonHeader();
- appc.CommonHeader.RequestID = UUID.randomUUID();
- appc.Action = "ModifyConfig";
- appc.Payload = new HashMap<String, Object>();
- appc.Payload.put("pg-streams", request);
- logger.debug(Serialization.gsonPretty.toJson(appc));
- }
-
-}
diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java
deleted file mode 100644
index 5675b6bdf..000000000
--- a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestFirewallDemo.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * demo
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.template.demo;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.time.Instant;
-import java.util.HashMap;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.junit.Test;
-import org.kie.api.KieServices;
-import org.kie.api.builder.KieBuilder;
-import org.kie.api.builder.KieFileSystem;
-import org.kie.api.builder.Message;
-import org.kie.api.builder.ReleaseId;
-import org.kie.api.builder.Results;
-import org.kie.api.builder.model.KieModuleModel;
-import org.kie.api.runtime.KieContainer;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
-import org.onap.policy.appc.CommonHeader;
-import org.onap.policy.appc.Response;
-import org.onap.policy.appc.ResponseStatus;
-import org.onap.policy.controlloop.ControlLoopEventStatus;
-import org.onap.policy.controlloop.ControlLoopTargetType;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.appc.util.Serialization;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class TestFirewallDemo {
-
- private static final Logger logger = LoggerFactory.getLogger(TestFirewallDemo.class);
- @Test
- public void testvDNS() throws IOException {
- //
- // Build a container
- //
- final String closedLoopControlName = "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8";
- final KieSession kieSession = buildContainer("src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl",
- closedLoopControlName,
- "type=operational",
- "myFirewallDemoPolicy",
- "v1.0",
- "SO",
- "http://localhost:8080/TestREST/Test",
- "POLICY",
- "POLICY",
- "http://localhost:8080/TestREST/Test",
- "POLICY",
- "POLICY",
- "4ff56a54-9e3f-46b7-a337-07a1d3c6b469",
- 0,
- "POLICY-CL-MGT",
- "APPC-CL"
- );
- //
- // Initial fire of rules
- //
- kieSession.fireAllRules();
- //
- // Kick a thread that starts testing
- //
- new Thread(new Runnable() {
-
- @Override
- public void run() {
- //
- // Generate an invalid DCAE Event with requestID=null
- //
- VirtualControlLoopEvent invalidEvent = new VirtualControlLoopEvent();
- invalidEvent.closedLoopControlName = closedLoopControlName;
- invalidEvent.requestID = null;
- invalidEvent.closedLoopEventClient = "tca.instance00001";
- invalidEvent.target_type = ControlLoopTargetType.VF;
- invalidEvent.target = "generic-vnf.vnf-id";
- invalidEvent.from = "DCAE";
- invalidEvent.closedLoopAlarmStart = Instant.now();
- invalidEvent.AAI = new HashMap<String, String>();
- invalidEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
-
- logger.debug("----- Invalid ONSET -----");
- logger.debug(Serialization.gsonPretty.toJson(invalidEvent));
-
- //
- // Insert invalid DCAE Event into memory
- //
- kieSession.insert(invalidEvent);
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- }
- //
- // Generate first DCAE ONSET Event
- //
- VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
- onsetEvent.closedLoopControlName = closedLoopControlName;
- onsetEvent.requestID = UUID.randomUUID();
- onsetEvent.closedLoopEventClient = "tca.instance00001";
- onsetEvent.target_type = ControlLoopTargetType.VF;
- onsetEvent.target = "generic-vnf.vnf-id";
- onsetEvent.from = "DCAE";
- onsetEvent.closedLoopAlarmStart = Instant.now();
- onsetEvent.AAI = new HashMap<String, String>();
- onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
-
- logger.debug("----- ONSET -----");
- logger.debug(Serialization.gsonPretty.toJson(onsetEvent));
-
- //
- // Insert first DCAE ONSET Event into memory
- //
- kieSession.insert(onsetEvent);
- //
- // We have test for subsequent ONSET Events in testvFirewall()
- // So no need to test it again here
- //
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- }
- //
- // Test is finished, so stop the kieSession
- //
- kieSession.halt();
- }
- //
- }).start();
- //
- // Start firing rules
- //
- kieSession.fireUntilHalt();
- //
- // Dump working memory
- //
- dumpFacts(kieSession);
- //
- // See if there is anything left in memory, there SHOULD only be
- // a params fact.
- //
- assertEquals("There should only be 1 Fact left in memory.", 1, kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- Object fact = kieSession.getObject(handle);
- assertEquals("Non-Param Fact left in working memory", "org.onap.policy.controlloop.Params", fact.getClass().getName());
- }
- }
-
- @Test
- public void testvFirewall() throws IOException {
- //
- // Build a container
- //
- final String closedLoopControlName = "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8";
- final KieSession kieSession = buildContainer("src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl",
- closedLoopControlName,
- "type=operational",
- "myFirewallDemoPolicy",
- "v1.0",
- "APPC",
- "http://localhost:8080/TestREST/Test",
- "POLICY",
- "POLICY",
- null,
- null,
- null,
- null,
- 1,
- "POLICY-CL-MGT",
- "APPC-CL"
- );
- //
- // Initial fire of rules
- //
- kieSession.fireAllRules();
- //
- // Kick a thread that starts testing
- //
- new Thread(new Runnable() {
-
- @Override
- public void run() {
- //
- // Generate an invalid DCAE Event with requestID=null
- //
- VirtualControlLoopEvent invalidEvent = new VirtualControlLoopEvent();
- invalidEvent.closedLoopControlName = closedLoopControlName;
- invalidEvent.requestID = null;
- invalidEvent.closedLoopEventClient = "tca.instance00001";
- invalidEvent.target_type = ControlLoopTargetType.VF;
- invalidEvent.target = "generic-vnf.vnf-id";
- invalidEvent.from = "DCAE";
- invalidEvent.closedLoopAlarmStart = Instant.now();
- invalidEvent.AAI = new HashMap<String, String>();
- invalidEvent.AAI.put("generic-vnf.vnf-id", "foo");
- invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
-
- logger.debug("----- Invalid ONSET -----");
- logger.debug(Serialization.gsonPretty.toJson(invalidEvent));
-
- //
- // Insert invalid DCAE Event into memory
- //
- kieSession.insert(invalidEvent);
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- }
- //
- // Generate first DCAE ONSET Event
- //
- VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
- onsetEvent.closedLoopControlName = closedLoopControlName;
- onsetEvent.requestID = UUID.randomUUID();
- onsetEvent.closedLoopEventClient = "tca.instance00001";
- onsetEvent.target_type = ControlLoopTargetType.VF;
- onsetEvent.target = "generic-vnf.vnf-id";
- onsetEvent.from = "DCAE";
- onsetEvent.closedLoopAlarmStart = Instant.now();
- onsetEvent.AAI = new HashMap<String, String>();
- onsetEvent.AAI.put("generic-vnf.vnf-id", "fw0001vm001fw001");
- //onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
-
- logger.debug("----- ONSET -----");
- logger.debug(Serialization.gsonPretty.toJson(onsetEvent));
-
- //
- // Insert first DCAE ONSET Event into memory
- //
- kieSession.insert(onsetEvent);
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- }
-
-
- Thread thread = new Thread(new Runnable() {
-
- @Override
- public void run() {
- while (true) {
- //
- // Generate subsequent DCAE ONSET Event
- //
- VirtualControlLoopEvent subOnsetEvent = new VirtualControlLoopEvent();
- subOnsetEvent.closedLoopControlName = closedLoopControlName;
- subOnsetEvent.requestID = UUID.randomUUID();
- subOnsetEvent.closedLoopEventClient = "tca.instance00001";
- subOnsetEvent.target_type = ControlLoopTargetType.VF;
- subOnsetEvent.target = "generic-vnf.vnf-id";
- subOnsetEvent.from = "DCAE";
- subOnsetEvent.closedLoopAlarmStart = Instant.now();
- subOnsetEvent.AAI = new HashMap<String, String>();
- subOnsetEvent.AAI.put("generic-vnf.vnf-id", "fw0001vm001fw001");
- //subOnsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- subOnsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
-
- logger.debug("----- Subsequent ONSET -----");
- logger.debug(Serialization.gsonPretty.toJson(subOnsetEvent));
-
- //
- // Insert subsequent DCAE ONSET Event into memory
- //
- kieSession.insert(subOnsetEvent);
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- break;
- }
- }
- }
-
- });
- thread.start();
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- }
- //
- // Stop the thread
- //
- thread.interrupt();
- //
- // Generate APPC ACCEPT Response
- //
- Response response1 = new Response();
- // CommonHeader
- CommonHeader commonHeader1 = new CommonHeader();
- commonHeader1.RequestID = onsetEvent.requestID;
- response1.CommonHeader = commonHeader1;
- // ResponseStatus
- ResponseStatus responseStatus1 = new ResponseStatus();
- responseStatus1.Code = 100;
- response1.Status = responseStatus1;
- //
- logger.debug("----- APP-C RESPONSE 100 -----");
- logger.debug(Serialization.gsonPretty.toJson(response1));
- //
- // Insert APPC Response into memory
- //
- kieSession.insert(response1);
- //
- // Simulating APPC takes some time for processing the recipe
- // and then gives response
- //
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- //
- // Generate APPC SUCCESS Response
- //
- Response response2 = new Response();
- // CommonHeader
- CommonHeader commonHeader2 = new CommonHeader();
- commonHeader2.RequestID = onsetEvent.requestID;
- response2.CommonHeader = commonHeader2;
- // ResponseStatus
- ResponseStatus responseStatus2 = new ResponseStatus();
- responseStatus2.Code = 400;
- response2.Status = responseStatus2;
- //
- logger.debug("----- APP-C RESPONSE 400 -----");
- logger.debug(Serialization.gsonPretty.toJson(response2));
- //
- // Insert APPC Response into memory
- //
- kieSession.insert(response2);
- //
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- }
- //
- // Test is finished, so stop the kieSession
- //
- kieSession.halt();
- }
- //
- }).start();
- //
- // Start firing rules
- //
- kieSession.fireUntilHalt();
- //
- // Dump working memory
- //
- dumpFacts(kieSession);
- //
- // See if there is anything left in memory, there SHOULD only be
- // a params fact.
- //
- assertEquals("There should only be 1 Fact left in memory.", 1, kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- Object fact = kieSession.getObject(handle);
- assertEquals("Non-Param Fact left in working memory", "org.onap.policy.controlloop.Params", fact.getClass().getName());
- }
- }
-
- public static void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: {}", kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: {}", handle);
- }
- }
-
- public static KieSession buildContainer(String droolsTemplate,
- String closedLoopControlName,
- String policyScope,
- String policyName,
- String policyVersion,
- String actor,
- String aaiURL,
- String aaiUsername,
- String aaiPassword,
- String msoURL,
- String msoUsername,
- String msoPassword,
- String aaiNamedQuery,
- int aaiPatternMatch,
- String notificationTopic,
- String appcTopic ) throws IOException {
- //
- // Get our Drools Kie factory
- //
- KieServices ks = KieServices.Factory.get();
-
- KieModuleModel kModule = ks.newKieModuleModel();
-
- logger.debug("KMODULE: {} {}", System.lineSeparator(), kModule.toXML());
-
- //
- // Generate our drools rule from our template
- //
- KieFileSystem kfs = ks.newKieFileSystem();
-
- kfs.writeKModuleXML(kModule.toXML());
- {
- Path rule = Paths.get(droolsTemplate);
- String ruleTemplate = new String(Files.readAllBytes(rule));
- String drlContents = generatePolicy(ruleTemplate,
- closedLoopControlName,
- policyScope,
- policyName,
- policyVersion,
- actor,
- aaiURL,
- aaiUsername,
- aaiPassword,
- msoURL,
- msoUsername,
- msoPassword,
- aaiNamedQuery,
- aaiPatternMatch,
- notificationTopic,
- appcTopic
- );
-
- kfs.write("src/main/resources/" + policyName + ".drl", ks.getResources().newByteArrayResource(drlContents.getBytes()));
- }
- //
- // Compile the rule
- //
- KieBuilder builder = ks.newKieBuilder(kfs).buildAll();
- Results results = builder.getResults();
- if (results.hasMessages(Message.Level.ERROR)) {
- for (Message msg : results.getMessages()) {
- logger.error("{}", msg);
- }
- throw new RuntimeException("Drools Rule has Errors");
- }
- for (Message msg : results.getMessages()) {
- logger.debug("{}", msg);
- }
- //
- // Create our kie Session and container
- //
- ReleaseId releaseId = ks.getRepository().getDefaultReleaseId();
- logger.debug("{}", releaseId);
- KieContainer kContainer = ks.newKieContainer(releaseId);
-
- return kContainer.newKieSession();
- }
- public static String generatePolicy(String ruleContents,
- String closedLoopControlName,
- String policyScope,
- String policyName,
- String policyVersion,
- String actor,
- String aaiURL,
- String aaiUsername,
- String aaiPassword,
- String msoURL,
- String msoUsername,
- String msoPassword,
- String aaiNamedQueryUUID,
- int aaiPatternMatch,
- String notificationTopic,
- String appcTopic) {
-
- Pattern p = Pattern.compile("\\$\\{closedLoopControlName\\}");
- Matcher m = p.matcher(ruleContents);
- ruleContents = m.replaceAll(closedLoopControlName);
-
- p = Pattern.compile("\\$\\{policyScope\\}");
- m = p.matcher(ruleContents);
- ruleContents = m.replaceAll(policyScope);
-
- p = Pattern.compile("\\$\\{policyName\\}");
- m = p.matcher(ruleContents);
- ruleContents = m.replaceAll(policyName);
-
- p = Pattern.compile("\\$\\{policyVersion\\}");
- m = p.matcher(ruleContents);
- ruleContents = m.replaceAll(policyVersion);
-
- p = Pattern.compile("\\$\\{actor\\}");
- m = p.matcher(ruleContents);
- ruleContents = m.replaceAll(actor);
-
- p = Pattern.compile("\\$\\{aaiURL\\}");
- m = p.matcher(ruleContents);
- if (aaiURL == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(aaiURL);
- }
-
- p = Pattern.compile("\\$\\{aaiUsername\\}");
- m = p.matcher(ruleContents);
- if (aaiUsername == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(aaiUsername);
- }
-
- p = Pattern.compile("\\$\\{aaiPassword\\}");
- m = p.matcher(ruleContents);
- if (aaiPassword == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(aaiPassword);
- }
-
- p = Pattern.compile("\\$\\{msoURL\\}");
- m = p.matcher(ruleContents);
- if (msoURL == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(msoURL);
- }
-
- p = Pattern.compile("\\$\\{msoUsername\\}");
- m = p.matcher(ruleContents);
- if (msoUsername == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(msoUsername);
- }
-
- p = Pattern.compile("\\$\\{msoPassword\\}");
- m = p.matcher(ruleContents);
- if (msoPassword == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(msoPassword);
- }
-
- p = Pattern.compile("\\$\\{aaiNamedQueryUUID\\}");
- m = p.matcher(ruleContents);
- if (aaiNamedQueryUUID == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(aaiNamedQueryUUID);
- }
-
- p = Pattern.compile("\\$\\{aaiPatternMatch\\}");
- m = p.matcher(ruleContents);
- if (aaiPatternMatch == 1) {
- ruleContents = m.replaceAll("1");
- } else {
- ruleContents = m.replaceAll("0");
- }
-
- p = Pattern.compile("\\$\\{notificationTopic\\}");
- m = p.matcher(ruleContents);
- if (notificationTopic == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(notificationTopic);
- }
-
- p = Pattern.compile("\\$\\{appcTopic\\}");
- m = p.matcher(ruleContents);
- if (appcTopic == null) {
- ruleContents = m.replaceAll("null");
- } else {
- ruleContents = m.replaceAll(appcTopic);
- }
-
- logger.debug(ruleContents);
-
- return ruleContents;
- }
-
-}
diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
deleted file mode 100644
index 333fde6b2..000000000
--- a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * demo
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.template.demo;
-
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.util.UUID;
-
-import org.junit.Test;
-import org.onap.policy.mso.SOCloudConfiguration;
-import org.onap.policy.mso.SOModelInfo;
-import org.onap.policy.mso.SORelatedInstance;
-import org.onap.policy.mso.SORelatedInstanceListElement;
-import org.onap.policy.mso.SORequest;
-import org.onap.policy.mso.SORequestDetails;
-import org.onap.policy.mso.SORequestInfo;
-import org.onap.policy.mso.SORequestParameters;
-import org.onap.policy.aai.AAINQResponse;
-import org.onap.policy.aai.AAINQResponseWrapper;
-import org.onap.policy.mso.util.Serialization;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.gson.Gson;
-import com.google.gson.stream.JsonReader;
-
-public class TestSO {
-
- private static final Logger logger = LoggerFactory.getLogger(TestSO.class);
-
- @Test
- public void test() throws FileNotFoundException {
- Gson gson = new Gson();
- JsonReader reader = new JsonReader(new FileReader("src/test/resources/aairesponse.json"));
- AAINQF199Response response = gson.fromJson(reader, AAINQF199Response.class);
-
- logger.debug(Serialization.gsonPretty.toJson(response));
-
- AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper(UUID.randomUUID(), response);
-
- //
- //
- // vnfItem
- //
- String vnfItemVnfId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;
- String vnfItemVnfType = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;
- vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf("/")+1);
- String vnfItemPersonaModelId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;
- String vnfItemPersonaModelVersion = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;
- String vnfItemModelName = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
- String vnfItemModelNameVersionId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
- //
- // serviceItem
- //
- String serviceItemServiceInstanceId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;
- String serviceItemPersonaModelId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;
- String serviceItemModelName = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
- String serviceItemModelVersion = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;
- String serviceItemModelNameVersionId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
- //
- // This comes from the base module
- //
- String vfModuleItemVfModuleName = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName;
- vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS");
- //
- // vfModuleItem - NOT the base module
- //
- String vfModuleItemPersonaModelId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId;
- String vfModuleItemPersonaModelVersion = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion;
- String vfModuleItemModelName = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue;
- String vfModuleItemModelNameVersionId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue;
-
- //
- // tenantItem
- //
- String tenantItemTenantId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;
- //
- // cloudRegionItem
- //
- String cloudRegionItemCloudRegionId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;
-
- //
- // Construct an SO request
- //
- SORequest request = new SORequest();
- request.requestDetails = new SORequestDetails();
- request.requestDetails.modelInfo = new SOModelInfo();
- request.requestDetails.cloudConfiguration = new SOCloudConfiguration();
- request.requestDetails.requestInfo = new SORequestInfo();
- request.requestDetails.requestParameters = new SORequestParameters();
- request.requestDetails.requestParameters.userParams = null;
- //
- // cloudConfiguration
- //
- request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;
- request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;
- //
- // modelInfo
- //
- request.requestDetails.modelInfo.modelType = "vfModule";
- request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;
- request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;
- request.requestDetails.modelInfo.modelName = vfModuleItemModelName;
- request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;
- //
- // requestInfo
- //
- request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;
- request.requestDetails.requestInfo.source = "POLICY";
- request.requestDetails.requestInfo.suppressRollback = false;
- //
- // relatedInstanceList
- //
- SORelatedInstanceListElement relatedInstanceListElement1 = new SORelatedInstanceListElement();
- SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement();
- relatedInstanceListElement1.relatedInstance = new SORelatedInstance();
- relatedInstanceListElement2.relatedInstance = new SORelatedInstance();
- //
- relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;
- relatedInstanceListElement1.relatedInstance.modelInfo = new SOModelInfo();
- relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
- relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;
- relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;
- relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;
- relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;
- //
- relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;
- relatedInstanceListElement2.relatedInstance.modelInfo = new SOModelInfo();
- relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
- relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;
- relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;
- relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;
- relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemPersonaModelVersion;
- relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;
- //
- request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
- request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
- //
- // print SO request for debug
- //
- logger.debug("SO request sent:");
- logger.debug(Serialization.gsonPretty.toJson(request));
- }
-
-}
diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/resources/aairesponse.json b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/resources/aairesponse.json
deleted file mode 100644
index 66da8e715..000000000
--- a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/resources/aairesponse.json
+++ /dev/null
@@ -1,227 +0,0 @@
-{
- "inventory-response-item": [
- {
- "extra-properties": {},
- "inventory-response-items": {
- "inventory-response-item": [
- {
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model.model-name",
- "property-value": "c15ce9e1-e914-4c8f-b8bb"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-version",
- "property-value": "1"
- },
- {
- "property-name": "model.model-id",
- "property-value": "033a32ed-aa65-4764-a736-36f2942f1aa0"
- },
- {
- "property-name": "model.model-name-version-id",
- "property-value": "d4d072dc-4e21-4a03-9524-628985819a8e"
- }
- ]
- },
- "generic-vnf": {
- "in-maint": false,
- "is-closed-loop-disabled": false,
- "orchestration-status": "Created",
- "persona-model-id": "033a32ed-aa65-4764-a736-36f2942f1aa0",
- "persona-model-version": "1.0",
- "resource-version": "1485542422",
- "service-id": "b3f70641-bdb9-4030-825e-6abb73a1f929",
- "vnf-id": "594e2fe0-48b8-41ff-82e2-3d4bab69b192",
- "vnf-name": "Vnf_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8",
- "vnf-type": "8330e932-2a23-4943-8606/c15ce9e1-e914-4c8f-b8bb 1"
- },
- "inventory-response-items": {
- "inventory-response-item": [
- {
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model.model-name",
- "property-value": "8330e932-2a23-4943-8606"
- },
- {
- "property-name": "model.model-type",
- "property-value": "service"
- },
- {
- "property-name": "model.model-version",
- "property-value": "1"
- },
- {
- "property-name": "model.model-id",
- "property-value": "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b"
- },
- {
- "property-name": "model.model-name-version-id",
- "property-value": "5c996219-b2e2-4c76-9b43-7e8672a33c1d"
- }
- ]
- },
- "service-instance": {
- "persona-model-id": "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b",
- "persona-model-version": "1.0",
- "resource-version": "1485542400",
- "service-instance-id": "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5",
- "service-instance-name": "Service_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"
- }
- },
- {
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model.model-name",
- "property-value": "C15ce9e1E9144c8fB8bb..base_vlb..module-0"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-version",
- "property-value": "1"
- },
- {
- "property-name": "model.model-id",
- "property-value": "79ee24cd-fc9a-4f14-afae-5e1dd2ab2941"
- },
- {
- "property-name": "model.model-name-version-id",
- "property-value": "5484cabb-1a0d-4f29-a616-094a3f643d73"
- }
- ]
- },
- "model-name": "C15ce9e1E9144c8fB8bb..base_vlb..module-0",
- "vf-module": {
- "heat-stack-id": "Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/5845f37b-6cda-4e91-8ca3-f5572d226488",
- "is-base-vf-module": true,
- "orchestration-status": "active",
- "persona-model-id": "79ee24cd-fc9a-4f14-afae-5e1dd2ab2941",
- "persona-model-version": "1",
- "resource-version": "1485542667",
- "vf-module-id": "b0eff878-e2e1-4947-9597-39afdd0f51dd",
- "vf-module-name": "Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"
- }
- },
- {
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model.model-name",
- "property-value": "C15ce9e1E9144c8fB8bb..dnsscaling..module-1"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-version",
- "property-value": "1"
- },
- {
- "property-name": "model.model-id",
- "property-value": "f32568ec-2f1c-458a-864b-0593d53d141a"
- },
- {
- "property-name": "model.model-name-version-id",
- "property-value": "69615025-879d-4f0d-afe3-b7d1a7eeed1f"
- }
- ]
- },
- "vf-module": {
- "is-base-vf-module": false,
- "persona-model-id": "f32568ec-2f1c-458a-864b-0593d53d141a",
- "persona-model-version": "1.0",
- "resource-version": "1485561752",
- "vf-module-id": "dummy",
- "vf-module-name": "dummy"
- }
- },
- {
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model.model-name",
- "property-value": "C15ce9e1E9144c8fB8bb..dnsscaling..module-1"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-version",
- "property-value": "1"
- },
- {
- "property-name": "model.model-id",
- "property-value": "f32568ec-2f1c-458a-864b-0593d53d141a"
- },
- {
- "property-name": "model.model-name-version-id",
- "property-value": "69615025-879d-4f0d-afe3-b7d1a7eeed1f"
- }
- ]
- },
- "vf-module": {
- "heat-stack-id": "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/f447ce51-14dd-4dcd-9957-68a047c79673",
- "is-base-vf-module": false,
- "orchestration-status": "active",
- "persona-model-id": "f32568ec-2f1c-458a-864b-0593d53d141a",
- "persona-model-version": "1.0",
- "resource-version": "1485562712",
- "vf-module-id": "8cd79e44-1fae-48c1-a160-609f90b46749",
- "vf-module-name": "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"
- }
- }
- ]
- }
- },
- {
- "extra-properties": {},
- "inventory-response-items": {
- "inventory-response-item": [
- {
- "cloud-region": {
- "cloud-owner": "Rackspace",
- "cloud-region-id": "DFW",
- "cloud-region-version": "v1",
- "cloud-type": "SharedNode",
- "cloud-zone": "CloudZone",
- "owner-defined-type": "OwnerType",
- "resource-version": "1485465545"
- },
- "extra-properties": {}
- }
- ]
- },
- "tenant": {
- "resource-version": "1485465545",
- "tenant-id": "1015548",
- "tenant-name": "1015548"
- }
- }
- ]
- },
- "vserver": {
- "in-maint": false,
- "is-closed-loop-disabled": false,
- "prov-status": "ACTIVE",
- "resource-version": "1485546436",
- "vserver-id": "70f081eb-2a87-4c81-9296-4b93d7d145c6",
- "vserver-name": "vlb-lb-32c8",
- "vserver-name2": "vlb-lb-32c8",
- "vserver-selflink": "https://dfw.servers.api.rackspacecloud.com/v2/1015548/servers/70f081eb-2a87-4c81-9296-4b93d7d145c6"
- }
- }
- ]
-}