summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java14
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java8
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java38
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java14
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java8
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java4
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseHistoryList.java36
-rw-r--r--controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java11
-rw-r--r--controlloop/common/pom.xml1
-rw-r--r--controlloop/common/simulators/pom.xml67
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java)6
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorJaxRs.java)4
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java49
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorJaxRs.java)4
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulatorTest.java)4
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java)4
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorTest.java)6
-rw-r--r--controlloop/templates/template.demo/pom.xml20
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java26
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java19
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java9
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java10
-rw-r--r--controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml2
-rw-r--r--pom.xml2
24 files changed, 227 insertions, 139 deletions
diff --git a/controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java b/controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java
index f3c563f2a..64e0c616b 100644
--- a/controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java
+++ b/controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java
@@ -157,8 +157,8 @@ public class MSOActorServiceProvider implements Actor {
//
// instanceFilters
//
- Map aainqf199instancefiltermap = new HashMap();
- Map aainqf199instancefiltermapitem = new HashMap();
+ Map<String, Map<String, String>> aainqf199instancefiltermap = new HashMap<>();
+ Map<String, String> aainqf199instancefiltermapitem = new HashMap<>();
aainqf199instancefiltermapitem.put("vserver-name", onset.AAI.get("vserver.vserver-name")); // TO DO: get vserver.vname from dcae onset.AAI.get("vserver.vserver-name")
aainqf199instancefiltermap.put("vserver", aainqf199instancefiltermapitem);
aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);
@@ -269,7 +269,7 @@ public class MSOActorServiceProvider implements Actor {
setCloudRegionItemCloudRegionId(namedQueryResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId);
} catch (Exception e) {
- logger.error(e.getMessage());
+ logger.error(e.getMessage(), e);
VirtualControlLoopNotification notification = new VirtualControlLoopNotification(onset);
notification.notification = ControlLoopNotificationType.REJECTED;
notification.message = "Exception occurred " + e.getMessage();
@@ -281,7 +281,7 @@ public class MSOActorServiceProvider implements Actor {
logger.debug(Serialization.gsonPretty.toJson(notification));
} catch (Exception e1) {
logger.error("Can't deliver notification: " + notification);
- logger.error(e1.getMessage());
+ logger.error(e1.getMessage(), e1);
}
//
notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
@@ -291,7 +291,7 @@ public class MSOActorServiceProvider implements Actor {
logger.debug(Serialization.gsonPretty.toJson(notification));
} catch (Exception e1) {
logger.error("Can't deliver notification: " + notification);
- logger.error(e1.getMessage());
+ logger.error(e1.getMessage(), e1);
}
// Retract everything
return;
@@ -438,7 +438,7 @@ public class MSOActorServiceProvider implements Actor {
* @param vnfItemVnfId the vnfItemVnfId to set
*/
private void setVnfItemVnfId(String vnfItemVnfId) {
- this.vnfItemVnfId = vnfItemVnfId;
+ MSOActorServiceProvider.vnfItemVnfId = vnfItemVnfId;
}
/**
@@ -537,7 +537,7 @@ public class MSOActorServiceProvider implements Actor {
*/
private void setServiceItemServiceInstanceId(
String serviceItemServiceInstanceId) {
- this.serviceItemServiceInstanceId = serviceItemServiceInstanceId;
+ MSOActorServiceProvider.serviceItemServiceInstanceId = serviceItemServiceInstanceId;
}
/**
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index bc7f3c32d..2248fcd48 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -572,6 +572,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
if (! event.target.equalsIgnoreCase("VM_NAME") &&
! event.target.equalsIgnoreCase("VNF_NAME") &&
! event.target.equalsIgnoreCase("vserver.vserver-name") &&
+ ! event.target.equalsIgnoreCase("generic-vnf.vnf-id") &&
! event.target.equalsIgnoreCase("generic-vnf.vnf-name") ) {
throw new ControlLoopException("target field invalid - expecting VM_NAME or VNF_NAME");
}
@@ -680,9 +681,16 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
case PNF:
break;
case VM:
+ case VNF:
if (this.onset.target.equalsIgnoreCase("vserver.vserver-name")) {
return this.onset.AAI.get("vserver.vserver-name");
}
+ else if (this.onset.target.equalsIgnoreCase("generic-vnf.vnf-id")) {
+ return this.onset.AAI.get("generic-vnf.vnf-id");
+ }
+ else if (this.onset.target.equalsIgnoreCase("generic-vnf.vnf-name")) {
+ return this.onset.AAI.get("generic-vnf.vnf-name");
+ }
break;
default:
break;
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
index d35726a64..3e93bd761 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
@@ -23,6 +23,7 @@ package org.onap.policy.guard;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
@@ -112,13 +113,13 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
@Override
public Collection<PIPRequest> attributesRequired() {
// TODO Auto-generated method stub
- return null;
+ return Collections.emptySet();
}
@Override
public Collection<PIPRequest> attributesProvided() {
// TODO Auto-generated method stub
- return null;
+ return Collections.emptySet();
}
@Override
@@ -190,23 +191,25 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
try {
pipResponse = pipFinder.getMatchingAttributes(pipRequest, this);
- if (pipResponse != null) {
- if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
- logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
- pipResponse = null;
- }
- if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
- logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
- logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
- pipResponse = null;
- }
- if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
- logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
- pipResponse = null;
- }
- }
} catch (PIPException ex) {
logger.error("getAttribute threw:", ex);
+ return null;
+ }
+ if (pipResponse == null) {
+ return null;
+ }
+ if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+ return null;
+ }
+ if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
+ return null;
+ }
+ if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
+ return null;
}
return pipResponse;
}
@@ -312,6 +315,7 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
}catch(Exception ex){
logger.error("PIP thread got Exception. Can't connect to Operations History DB -- {}", OpsHistPU);
logger.error("getCountFromDB threw: ", ex);
+ return 0;
}
DateUtil dateUtil = new DateUtil(){
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
index 6018c2cab..b594aff0a 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
@@ -24,19 +24,17 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
public final class Util {
@@ -60,14 +58,11 @@ public final class Util {
Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class));
Object obj = yaml.load(contents);
- //String ttt = ((ControlLoopPolicy)obj).policies.getFirst().payload.get("asdas");
logger.debug(contents);
- //for(Policy policy : ((ControlLoopPolicy)obj).policies){
return new Pair<ControlLoopPolicy, String>((ControlLoopPolicy) obj, contents);
- } catch (FileNotFoundException e) {
- fail(e.getLocalizedMessage());
} catch (IOException e) {
+ logger.error(e.getLocalizedMessage(), e);
fail(e.getLocalizedMessage());
}
return null;
@@ -82,9 +77,8 @@ public final class Util {
Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class));
Object obj = yaml.load(contents);
return (ControlLoopGuard) obj;
- } catch (FileNotFoundException e) {
- fail(e.getLocalizedMessage());
} catch (IOException e) {
+ logger.error(e.getLocalizedMessage(), e);
fail(e.getLocalizedMessage());
}
return null;
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java
index 0cfc82ec9..8451998eb 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java
@@ -21,11 +21,17 @@
package org.onap.policy.aai;
import java.util.List;
+import java.io.Serializable;
import java.util.LinkedList;
import com.google.gson.annotations.SerializedName;
-public class RelationshipItem {
+public class RelationshipItem implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1543404460741069628L;
@SerializedName("related-to-property")
public List<RelatedToPropertyItem> relatedToProperty = new LinkedList<RelatedToPropertyItem>();
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
index f156fa0d0..9bf77c57c 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
@@ -19,7 +19,7 @@
package org.onap.policy.vfc;
import java.io.Serializable;
-
+import java.util.List;
import com.google.gson.annotations.SerializedName;
public class VFCResponseDescriptor implements Serializable {
@@ -42,7 +42,7 @@ public class VFCResponseDescriptor implements Serializable {
String responseId;
@SerializedName("responseHistoryList")
- VFCResponseHistoryList responseHistoryList;
+ public List<VFCResponseDescriptor> responseHistoryList;
public VFCResponseDescriptor() {
}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseHistoryList.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseHistoryList.java
deleted file mode 100644
index 3fe62ea25..000000000
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseHistoryList.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2017 Intel Corp. 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.vfc;
-
-import java.io.Serializable;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.google.gson.annotations.SerializedName;
-
-public class VFCResponseHistoryList implements Serializable {
-
- private static final long serialVersionUID = 3340914325806649762L;
-
- public List<VFCResponseDescriptor> responseDescriptorList= new LinkedList<>();
-
- public VFCResponseHistoryList() {
- }
-
-}
diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java
index 7e8c212e1..2bdb650ba 100644
--- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java
+++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java
@@ -27,9 +27,10 @@ import org.onap.policy.vfc.VFCHealAdditionalParams;
import org.onap.policy.vfc.VFCHealActionVmInfo;
import org.onap.policy.vfc.VFCResponse;
import org.onap.policy.vfc.VFCResponseDescriptor;
-import org.onap.policy.vfc.VFCResponseHistoryList;
import org.junit.Test;
import org.onap.policy.vfc.util.Serialization;
+import java.util.LinkedList;
+import java.util.List;
public class TestDemo {
@@ -74,11 +75,15 @@ public class TestDemo {
responseDescriptor.errorCode = null;
responseDescriptor.responseId = "11";
- response.responseDescriptor.responseHistoryList = new VFCResponseHistoryList();
- response.responseDescriptor.responseHistoryList.responseDescriptorList.add(responseDescriptor);
+ response.responseDescriptor.responseHistoryList = new LinkedList();
+ response.responseDescriptor.responseHistoryList.add(responseDescriptor);
body = Serialization.gsonPretty.toJson(response);
System.out.println(body);
+ response = Serialization.gsonPretty.fromJson(body, VFCResponse.class);
+ body = Serialization.gsonPretty.toJson(response);
+ System.out.println(body);
+
}
}
diff --git a/controlloop/common/pom.xml b/controlloop/common/pom.xml
index b6db66660..083a19f0b 100644
--- a/controlloop/common/pom.xml
+++ b/controlloop/common/pom.xml
@@ -38,6 +38,7 @@
<module>eventmanager</module>
<module>model-impl</module>
<module>policy-yaml</module>
+ <module>simulators</module>
</modules>
diff --git a/controlloop/common/simulators/pom.xml b/controlloop/common/simulators/pom.xml
new file mode 100644
index 000000000..9d3b71c0d
--- /dev/null
+++ b/controlloop/common/simulators/pom.xml
@@ -0,0 +1,67 @@
+<!--
+ ============LICENSE_START=======================================================
+ simulators
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>common</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>simulators</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>aai</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>mso</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>vfc</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
index 74b8bde0e..e1668ef4f 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
@@ -26,7 +26,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@Path("/aai")
-public class AaiSimulator {
+public class AaiSimulatorJaxRs {
@GET
@Path("/v8/network/generic-vnfs/generic-vnf/{vnfId}")
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java
index 14e12da7f..824c547ce 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/MsoSimulatorJaxRs.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
new file mode 100644
index 000000000..27cc6e0fa
--- /dev/null
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * simulators
+ * ================================================================================
+ * 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.simulators;
+
+import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.simulators.AaiSimulatorJaxRs;
+import org.onap.policy.simulators.MsoSimulatorJaxRs;
+import org.onap.policy.simulators.VfcSimulatorJaxRs;
+
+public class Util {
+ public static HttpServletServer buildAaiSim() throws InterruptedException {
+ HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6666, "/", false, true);
+ testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ return testServer;
+ }
+
+ public static HttpServletServer buildMsoSim() throws InterruptedException {
+ HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6667, "/", false, true);
+ testServer.addServletClass("/*", MsoSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ return testServer;
+ }
+
+ public static HttpServletServer buildVfcSim() throws InterruptedException {
+ HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6668, "/", false, true);
+ testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
+ testServer.waitedStart(5000);
+ return testServer;
+ }
+}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
index d85a9fb8a..51a85ce60 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
index 3bddbc50d..1b12b2527 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java
index 7696cbe73..917288ed5 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/MsoSimulatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import static org.junit.Assert.*;
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
index 340404136..db110383c 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * demo
+ * simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.template.demo;
+package org.onap.policy.simulators;
import static org.junit.Assert.*;
@@ -58,8 +58,6 @@ public class VfcSimulatorTest {
assertNotNull(response);
}
- //This test case fails because the model code does not match the response I was given, I do not know which is wrong
- @Ignore
@Test
public void testGet(){
Pair<Integer, String> httpDetails = RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234&responseId=5678", "username", "password", new HashMap<String, String>());
diff --git a/controlloop/templates/template.demo/pom.xml b/controlloop/templates/template.demo/pom.xml
index 0bceea848..e08174004 100644
--- a/controlloop/templates/template.demo/pom.xml
+++ b/controlloop/templates/template.demo/pom.xml
@@ -192,28 +192,16 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.drools-applications</groupId>
- <artifactId>aai</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${project.version}</version>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>[1.4.186,)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onap.policy.drools-applications</groupId>
- <artifactId>mso</artifactId>
+ <artifactId>simulators</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>[1.4.186,)</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
index 0738aadcf..b277b669e 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
@@ -23,6 +23,7 @@ package org.onap.policy.template.demo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.URLEncoder;
@@ -35,6 +36,8 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.kie.api.KieServices;
@@ -53,6 +56,7 @@ import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.impl.ControlLoopLoggerStdOutImpl;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
import org.onap.policy.mso.util.Serialization;
import org.slf4j.Logger;
@@ -63,6 +67,20 @@ public class TestSO {
private static final Logger log = LoggerFactory.getLogger(TestSO.class);
+ @BeforeClass
+ public static void setUpSimulator() {
+ try {
+ Util.buildAaiSim();
+ } catch (InterruptedException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
@Ignore
@Test
public void testvDNS() throws IOException {
@@ -117,10 +135,6 @@ public class TestSO {
@Override
public void run() {
-
- log.debug("\n***** Starting AAI Simulator ***** ");
- AaiSimulatorTest.setUpSimulator();
- log.debug("\n***** AAI Simulator started ***** ");
log.debug("\n************ Starting vDNS Test *************\n");
@@ -197,10 +211,6 @@ public class TestSO {
//
dumpFacts(kieSession);
- log.debug("\n***** Stopping AAI Simulator ***** ");
- AaiSimulatorTest.tearDownSimulator();
- log.debug("\n***** AAI Simulator stopped ***** ");
-
//
// See if there is anything left in memory, there SHOULD only be
// a params fact.
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
index 502ef7c1d..fb9f88f16 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
@@ -53,11 +53,15 @@ import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
import org.onap.policy.guard.PolicyGuardYamlToXacml;
+import org.onap.policy.simulators.AaiSimulatorJaxRs;
+import org.onap.policy.simulators.MsoSimulatorJaxRs;
+import org.onap.policy.simulators.VfcSimulatorJaxRs;
import com.att.research.xacml.api.pdp.PDPEngine;
import com.att.research.xacml.api.pdp.PDPEngineFactory;
import com.att.research.xacml.util.FactoryException;
import com.att.research.xacml.util.XACMLProperties;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -114,24 +118,15 @@ public final class Util {
}
public static HttpServletServer buildAaiSim() throws InterruptedException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6666, "/", false, true);
- testServer.addServletClass("/*", AaiSimulator.class.getName());
- testServer.waitedStart(5000);
- return testServer;
+ return org.onap.policy.simulators.Util.buildAaiSim();
}
public static HttpServletServer buildMsoSim() throws InterruptedException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6667, "/", false, true);
- testServer.addServletClass("/*", MsoSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- return testServer;
+ return org.onap.policy.simulators.Util.buildMsoSim();
}
public static HttpServletServer buildVfcSim() throws InterruptedException {
- HttpServletServer testServer = HttpServletServer.factory.build("testServer", "localhost", 6668, "/", false, true);
- testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- return testServer;
+ return org.onap.policy.simulators.Util.buildVfcSim();
}
private static String generatePolicy(String ruleContents,
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 a34ee6cd1..182e39828 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
@@ -294,7 +294,7 @@ public class VCPEControlLoopTest {
/*
* One final check to make sure the lock is released
*/
- assertFalse(PolicyGuard.isLocked(TargetType.VM, triggerSourceName, requestID));
+ assertFalse(PolicyGuard.isLocked(TargetType.VNF, triggerSourceName, requestID));
}
else {
fail("Operation Denied by Guard");
@@ -389,13 +389,12 @@ public class VCPEControlLoopTest {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
event.requestID = requestID;
- event.target = "vserver.vserver-name";
+ event.target = "generic-vnf.vnf-id";
event.closedLoopAlarmStart = Instant.now();
event.AAI = new HashMap<>();
event.AAI.put("cloud-region.identity-url", "foo");
event.AAI.put("vserver.selflink", "bar");
event.AAI.put("vserver.is-closed-loop-disabled", "false");
- event.AAI.put("vserver.vserver-name", "testGenericVnfName");
event.AAI.put("generic-vnf.vnf-id", "testGenericVnfId");
event.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
kieSession.insert(event);
@@ -415,14 +414,14 @@ public class VCPEControlLoopTest {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
event.requestID = requestID;
- event.target = "vserver.vserver-name";
+ event.target = "generic-vnf.vnf-id";
event.closedLoopAlarmStart = Instant.now().minusSeconds(5);
event.closedLoopAlarmEnd = Instant.now();
event.AAI = new HashMap<>();
event.AAI.put("cloud-region.identity-url", "foo");
event.AAI.put("vserver.selflink", "bar");
event.AAI.put("vserver.is-closed-loop-disabled", "false");
- event.AAI.put("generic-vnf.vnf-name", "testGenericVnfName");
+ event.AAI.put("generic-vnf.vnf-id", "testGenericVnfId");
event.closedLoopEventStatus = ControlLoopEventStatus.ABATED;
kieSession.insert(event);
}
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 25920e8b5..e2b688d5d 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
@@ -289,7 +289,7 @@ public class VFWControlLoopTest {
/*
* One final check to make sure the lock is released
*/
- assertFalse(PolicyGuard.isLocked(TargetType.VM, triggerSourceName, requestID));
+ assertFalse(PolicyGuard.isLocked(TargetType.VNF, triggerSourceName, requestID));
}
else {
fail("Operation Denied by Guard");
@@ -384,13 +384,13 @@ public class VFWControlLoopTest {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
event.requestID = requestID;
- event.target = "vserver.vserver-name";
+ event.target = "generic-vnf.vnf-id";
event.closedLoopAlarmStart = Instant.now();
event.AAI = new HashMap<>();
event.AAI.put("cloud-region.identity-url", "foo");
event.AAI.put("vserver.selflink", "bar");
event.AAI.put("vserver.is-closed-loop-disabled", "false");
- event.AAI.put("vserver.vserver-name", "testGenericVnfName");
+ event.AAI.put("generic-vnf.vnf-id", "testGenericVnfID");
event.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
kieSession.insert(event);
Thread.sleep(2000);
@@ -409,14 +409,14 @@ public class VFWControlLoopTest {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
event.requestID = requestID;
- event.target = "vserver.vserver-name";
+ event.target = "generic-vnf.vnf-id";
event.closedLoopAlarmStart = Instant.now().minusSeconds(5);
event.closedLoopAlarmEnd = Instant.now();
event.AAI = new HashMap<>();
event.AAI.put("cloud-region.identity-url", "foo");
event.AAI.put("vserver.selflink", "bar");
event.AAI.put("vserver.is-closed-loop-disabled", "false");
- event.AAI.put("generic-vnf.vnf-name", "testGenericVnfName");
+ event.AAI.put("generic-vnf.vnf-id", "testGenericVnfID");
event.closedLoopEventStatus = ControlLoopEventStatus.ABATED;
kieSession.insert(event);
}
diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml
index e78b1ca33..d15c46126 100644
--- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml
+++ b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml
@@ -17,7 +17,7 @@ policies:
recipe: ModifyConfig
target:
resourceID: Eace933104d443b496b8.nodes.heat.vpg
- type: VM
+ type: VNF
retry: 0
timeout: 300
success: final_success
diff --git a/pom.xml b/pom.xml
index bdfb0351e..73769ad61 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@
<artifactId>drools-pdp-apps</artifactId>
<version>1.1.0-SNAPSHOT</version>
- <name>Policy Engine - Drools PDP Application Models</name>
+ <name>policy-drools-applications</name>
<packaging>pom</packaging>
<properties>