summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-11-20 15:47:59 -0500
committerJim Hahn <jrh3@att.com>2020-11-20 15:48:44 -0500
commit2883cbc1e3a2754c40cf5683ce98f9a18f5aee0b (patch)
tree03c0cdd7d5b35d042642c986e04ce93b41915946
parent022405974f42fc183d8de46a603a1049dfb2ee15 (diff)
Remove legacy simulators
Drools-apps now uses simulators from policy/models. Deleted the legacy simulators. Issue-ID: POLICY-2804 Change-Id: Ie118237a52a4272d2f86fbb15b320ea2175ac7f4 Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--controlloop/common/simulators/pom.xml73
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java294
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java53
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java78
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java69
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java138
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java85
-rw-r--r--controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json15
-rw-r--r--controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json77
-rw-r--r--controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json267
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java140
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java79
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java149
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java79
14 files changed, 0 insertions, 1596 deletions
diff --git a/controlloop/common/simulators/pom.xml b/controlloop/common/simulators/pom.xml
deleted file mode 100644
index 924de88be..000000000
--- a/controlloop/common/simulators/pom.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- simulators
- ================================================================================
- Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
- Modifications Copyright (C) 2020 Bell Canada.
- ================================================================================
- 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.controlloop.common</groupId>
- <artifactId>drools-applications-common</artifactId>
- <version>1.4.2-SNAPSHOT</version>
- </parent>
-
- <artifactId>simulators</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${version.policy.common}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>aai</artifactId>
- <version>${policy.models.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>so</artifactId>
- <version>${policy.models.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>vfc</artifactId>
- <version>${policy.models.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-management</artifactId>
- <version>${version.policy.drools-pdp}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>sdnc</artifactId>
- <version>${policy.models.version}</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
deleted file mode 100644
index 8fa4892fb..000000000
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2018 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 java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-import java.util.UUID;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import org.apache.commons.io.IOUtils;
-import org.onap.policy.aai.AaiNqRequest;
-import org.onap.policy.aai.util.Serialization;
-
-@Path("/aai")
-public class AaiSimulatorJaxRs {
-
- private static final String VSERVER = "vserver";
- private static final String DISABLE_CLOSEDLOOP = "disableClosedLoop";
- private static final String ERROR = "error";
- private static final String GETFAIL = "getFail";
-
- /**
- * A&AI get query.
- *
- * @param vnfId the VNF Id
- * @return the result
- */
- @GET
- @Path("/v8/network/generic-vnfs/generic-vnf/{vnfId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String aaiGetQuery(@PathParam("vnfID") final String vnfId) {
- return "{\"relationship-list\": {\"relationship\":[{\"related-to-property\": [{\"property-key\": "
- + "\"service-instance.service-instance-name\"}]},{\"related-to-property\": [ {\"property-key\": "
- + "\"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
- }
-
- /**
- * A&AI post query.
- *
- * @param req the request
- * @return the response
- * @throws IOException if a response file cannot be read
- */
- @POST
- @Path("/search/named-query")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String aaiPostQuery(final String req) throws IOException {
- final AaiNqRequest request = Serialization.gsonPretty.fromJson(req, AaiNqRequest.class);
-
- if (request.getInstanceFilters().getInstanceFilter().get(0).containsKey(VSERVER)) {
- final String vserverName =
- request.getInstanceFilters().getInstanceFilter().get(0).get(VSERVER).get("vserver-name");
- if (ERROR.equals(vserverName)) {
- Map<String,String> params = new TreeMap<>();
- params.put("type", VSERVER);
- return load("aai/AaiNqResponse-Error.json", params);
- } else {
- // vll format - new
- // new aai response from Brian 11/13/2017
- return load("aai/AaiNqResponse-Vserver.json", new TreeMap<>());
- }
- } else {
- final String vnfId =
- request.getInstanceFilters().getInstanceFilter().get(0).get("generic-vnf").get("vnf-id");
- if (ERROR.equals(vnfId)) {
- Map<String,String> params = new TreeMap<>();
- params.put("type", "generic-vnf");
- return load("aai/AaiNqResponse-Error.json", params);
- } else {
- Map<String, String> params = new TreeMap<>();
- params.put("vnfId", "" + vnfId);
- params.put("vnfName", getUuidValue(vnfId, "ZRDM2MMEX39"));
- params.put("pnfVndName", "pnf-test-" + vnfId);
- params.put("pnfVnfId", getUuidValue(params.get("pnfVndName"), "jimmy-test"));
-
- params.put("serviceInstanceVnfName", "service-instance-test-" + vnfId);
- params.put("serviceInstanceVnfId",
- getUuidValue(params.get("serviceInstanceVnfName"), "jimmy-test-vnf2"));
-
- return load("aai/AaiNqResponse-GenericVnf.json", params);
- }
- }
- }
-
- /**
- * Get by VNF name.
- *
- * @param vnfName the VNF name
- * @return the response
- */
- @GET
- @Path("/v11/network/generic-vnfs/generic-vnf")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String getByVnfName(@QueryParam("vnf-name") final String vnfName) {
- if (GETFAIL.equals(vnfName)) {
- return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
- + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
- + "generic-vnf\",\"Node Not Found:No Node of type generic-vnf found at network/generic-vnfs"
- + "/generic-vnf\",\"ERR.5.4.6114\"]}}}";
- }
- final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfName);
- if (ERROR.equals(vnfName)) {
- return "{ \"vnf-id\": \"error\", \"vnf-name\": \"" + vnfName
- + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \""
- + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \""
- + "ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
- + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
- + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", "
- + "\"is-closed-loop-disabled\": " + isDisabled
- + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
- + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/"
- + "1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
- + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \""
- + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \""
- + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type"
- + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \""
- + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01"
- + "\"} ], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name"
- + "\"}]},{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/"
- + "cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/"
- + "USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45"
- + "\", \"relationship-data\":[{ \"relationship-key\": \"cloud-region.cloud-owner\", \""
- + "relationship-value\": \"att-aic\"},{ \"relationship-key\": \"cloud-region.cloud-region-id"
- + "\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"tenant.tenant-id"
- + "\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"relationship-key\": \""
- + "vserver.vserver-id\", \"relationship-value\": \"3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \""
- + "related-to-property\": [ {\"property-key\": \"vserver.vserver-name\",\"property-value\": \""
- + "USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
-
- }
- final String vnfId = getUuidValue(vnfName, "5e49ca06-2972-4532-9ed4-6d071588d792");
- return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName
- + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \""
- + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT"
- + "\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
- + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
- + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", "
- + "\"is-closed-loop-disabled\": " + isDisabled
- + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
- + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer"
- + "/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
- + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \""
- + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \""
- + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type"
- + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \""
- + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} ], \""
- + "related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},{ \""
- + "related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/"
- + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
- + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \""
- + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \""
- + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \""
- + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \""
- + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \""
- + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \""
- + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
- }
-
- /**
- * Get by VNF Id.
- *
- * @param vnfId the VNF Id
- * @return the response
- */
- @GET
- @Path("/v11/network/generic-vnfs/generic-vnf/{vnfId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String getByVnfId(@PathParam("vnfId") final String vnfId) {
- if (GETFAIL.equals(vnfId)) {
- return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
- + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
- + "generic-vnf/getFail\",\"Node Not Found:No Node of type generic-vnf found at network/"
- + "generic-vnfs/generic-vnf/getFail\",\"ERR.5.4.6114\"]}}}";
- }
- final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfId);
- final String vnfName = getUuidValue(vnfId, "USUCP0PCOIL0110UJRT01");
- return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName
- + "\", \"vnf-type\": \"RT\", \"service-id\": \""
- + "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status"
- + "\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \""
- + "ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345"
- + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, "
- + "\"prov-status\":\"ACTIVE\", \"" + ""
- + "is-closed-loop-disabled\": " + isDisabled + ", \"resource-version\": \"1493389458092\", \""
- + "relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link"
- + "\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions"
- + "/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \""
- + "relationship-data\":[{ \"relationship-key\": \"customer.global-customer-id\", \""
- + "relationship-value\": \"1610_Func_Global_20160817084727\"},{ \"relationship-key\": \""
- + "service-subscription.service-type\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key"
- + "\": \"service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} "
- + "], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},"
- + "{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/"
- + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
- + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \""
- + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \""
- + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \""
- + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \""
- + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \""
- + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \""
- + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
- }
-
- /**
- * Get by VServer name.
- *
- * @param vserverName the VServer name
- * @return the response
- */
- @GET
- @Path("/v11/nodes/vservers")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String getByVserverName(@QueryParam("vserver-name") final String vserverName) {
- if (GETFAIL.equals(vserverName)) {
- return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
- + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"nodes/vservers\",\"Node Not"
- + " Found:No Node of type generic-vnf found at nodes/vservers\",\"ERR.5.4.6114\"]}}}";
- }
- final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vserverName);
- final String vserverId = getUuidValue(vserverName, "d0668d4f-c25e-4a1b-87c4-83845c01efd8");
- return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \"" + vserverName
- + "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"in-maint\": false, \"is-closed-loop-disabled\": "
- + isDisabled
- + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", "
- + "\"relationship-list\": {\"relationship\":[{ \"related-to"
- + "\": \"generic-vnf\", \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/"
- + "e1a41e99-4ede-409a-8f9d-b5e12984203a\", \"relationship-data\": [ {\"relationship-key\": \""
- + "generic-vnf.vnf-id\",\"relationship-value\": \"e1a41e99-4ede-409a-8f9d-b5e12984203a\" }], \""
- + "related-to-property\": [ {\"property-key\": \"generic-vnf.vnf-name\",\"property-value\": \""
- + "USMSO1SX7NJ0103UJSW01\" }]},{ \"related-to\": \"pserver\", \"related-link\": \"/aai/v11/"
- + "cloud-infrastructure/pservers/pserver/USMSO1SX7NJ0103UJZZ01\", \"relationship-data\": [ {\""
- + "relationship-key\": \"pserver.hostname\",\"relationship-value\": \"USMSO1SX7NJ0103UJZZ01\" }], \""
- + "related-to-property\": [{\"property-key\": \"pserver.pserver-name2\"}]} ]}}]}";
- }
-
- private String getUuidValue(final String value, final String defaultValue) {
- return value != null ? UUID.nameUUIDFromBytes(value.getBytes()).toString() : defaultValue;
- }
-
- /**
- * Loads a JSON response from a file and then replaces parameters of the form, ${xxx},
- * with values.
- *
- * @param fileName name of the file containing the JSON
- * @param params parameters to be substituted
- * @return the JSON response, after parameter substitution
- * @throws IOException if the file cannot be read
- */
- private String load(String fileName, Map<String, String> params) throws IOException {
- String json = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
-
- // perform parameter substitution
- for (Entry<String, String> ent : params.entrySet()) {
- String name = "${" + ent.getKey() + "}";
- String value = ent.getValue();
- json = json.replace(name, value);
- }
-
- return json;
- }
-}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java
deleted file mode 100644
index 90bec372b..000000000
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/GuardSimulatorJaxRs.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2018 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 javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.json.JSONObject;
-
-@Path("/pdp/api")
-public class GuardSimulatorJaxRs {
- public static final String DENY_CLNAME = "denyGuard";
-
- /**
- * Get a guard decision.
- *
- * @param req the request
- * @return the response
- */
- @POST
- @Path("/getDecision")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String getGuardDecision(String req) {
- String clName = new JSONObject(req).getJSONObject("decisionAttributes").getString("clname");
- if (DENY_CLNAME.equals(clName)) {
- return "{\"decision\": \"DENY\", \"details\": \"Decision Deny. You asked for it\"}";
- } else {
- return "{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}";
- }
- }
-}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java
deleted file mode 100644
index bf1ec0b1a..000000000
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2018-2019 Huawei Technologies Co., Ltd. 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 java.util.UUID;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-
-import org.onap.policy.sdnc.SdncResponse;
-import org.onap.policy.sdnc.SdncResponseOutput;
-import org.onap.policy.sdnc.util.Serialization;
-
-
-@Path("/restconf/operations/")
-public class SdncSimulatorJaxRs {
-
- /**
- * SDNC post query.
- *
- * @return the response
- */
- @POST
- @Path("/GENERIC-RESOURCE-API:network-topology-operation")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String sdncPostQuery() {
- final SdncResponse response = new SdncResponse();
- response.setRequestId(UUID.randomUUID().toString());
- SdncResponseOutput responseOutput = new SdncResponseOutput();
- responseOutput.setResponseCode("200");
- responseOutput.setAckFinalIndicator("Y");
- responseOutput.setSvcRequestId(UUID.randomUUID().toString());
- response.setResponseOutput(responseOutput);
- return Serialization.gsonPretty.toJson(response);
- }
-
- /**
- * SDNC vf module topology operation.
- *
- * @return the response
- */
- @POST
- @Path("/GENERIC-RESOURCE-API:vf-module-topology-operation")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String sdncVnfTopologyOperation() {
- final SdncResponse response = new SdncResponse();
- response.setRequestId(UUID.randomUUID().toString());
- SdncResponseOutput responseOutput = new SdncResponseOutput();
- responseOutput.setResponseCode("200");
- responseOutput.setAckFinalIndicator("Y");
- responseOutput.setSvcRequestId(UUID.randomUUID().toString());
- response.setResponseOutput(responseOutput);
- return Serialization.gsonPretty.toJson(response);
- }
-}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
deleted file mode 100644
index d7d93957f..000000000
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2019 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 com.att.aft.dme2.internal.gson.Gson;
-import java.util.UUID;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import org.onap.policy.so.SoRequest;
-import org.onap.policy.so.SoRequestReferences;
-import org.onap.policy.so.SoRequestStatus;
-import org.onap.policy.so.SoResponse;
-
-@Path("/serviceInstantiation")
-public class SoSimulatorJaxRs {
-
- /**
- * SO post query.
- *
- * @param serviceInstanceId the service instance Id
- * @param vnfInstanceId the VNF Id
- * @return the response
- */
- @POST
- @Path("/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId,
- @PathParam("vnfInstanceId") final String vnfInstanceId) {
- final SoRequest request = new SoRequest();
- final SoRequestStatus requestStatus = new SoRequestStatus();
- requestStatus.setRequestState("COMPLETE");
- request.setRequestStatus(requestStatus);
- request.setRequestId(UUID.randomUUID());
-
- final SoResponse response = new SoResponse();
-
- final SoRequestReferences requestReferences = new SoRequestReferences();
- final String requestId = UUID.randomUUID().toString();
- requestReferences.setRequestId(requestId);
- response.setRequestReferences(requestReferences);
-
- response.setRequest(request);
-
- return new Gson().toJson(response);
- }
-}
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
deleted file mode 100644
index 1de77638b..000000000
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/Util.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2018 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 java.io.IOException;
-
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.utils.network.NetworkUtil;
-
-public class Util {
- public static final String AAISIM_SERVER_NAME = "aaiSim";
- public static final String SOSIM_SERVER_NAME = "soSim";
- public static final String VFCSIM_SERVER_NAME = "vfcSim";
- public static final String GUARDSIM_SERVER_NAME = "guardSim";
- public static final String SDNCSIM_SERVER_NAME = "sdncSim";
-
- public static final int AAISIM_SERVER_PORT = 6666;
- public static final int SOSIM_SERVER_PORT = 6667;
- public static final int VFCSIM_SERVER_PORT = 6668;
- public static final int GUARDSIM_SERVER_PORT = 6669;
- public static final int SDNCSIM_SERVER_PORT = 6670;
-
- private static final String CANNOT_CONNECT = "cannot connect to port ";
- private static final String LOCALHOST = "localhost";
-
- private Util() {
- // Prevent instantiation of thic class
- }
-
- /**
- * Build an A&AI simulator.
- *
- * @return the simulator
- * @throws InterruptedException if a thread is interrupted
- * @throws IOException if an IO errror occurs
- */
- public static HttpServletServer buildAaiSim() throws InterruptedException, IOException {
- final HttpServletServer testServer =
- HttpServletServer.factory.build(AAISIM_SERVER_NAME, LOCALHOST, AAISIM_SERVER_PORT, "/", false, true);
- testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
- }
- return testServer;
- }
-
- /**
- * Build an SDNC simulator.
- *
- * @return the simulator
- * @throws InterruptedException if a thread is interrupted
- * @throws IOException if an IO errror occurs
- */
- public static HttpServletServer buildSdncSim() throws InterruptedException, IOException {
- final HttpServletServer testServer =
- HttpServletServer.factory.build(SDNCSIM_SERVER_NAME, LOCALHOST, SDNCSIM_SERVER_PORT, "/", false, true);
- testServer.addServletClass("/*", SdncSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
- }
- return testServer;
- }
-
-
- /**
- * Build an SO simulator.
- *
- * @return the simulator
- * @throws InterruptedException if a thread is interrupted
- * @throws IOException if an IO errror occurs
- */
- public static HttpServletServer buildSoSim() throws InterruptedException, IOException {
- final HttpServletServer testServer =
- HttpServletServer.factory.build(SOSIM_SERVER_NAME, LOCALHOST, SOSIM_SERVER_PORT, "/", false, true);
- testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
- }
- return testServer;
- }
-
- /**
- * Build a VFC simulator.
- *
- * @return the simulator
- * @throws InterruptedException if a thread is interrupted
- * @throws IOException if an IO errror occurs
- */
- public static HttpServletServer buildVfcSim() throws InterruptedException, IOException {
- final HttpServletServer testServer =
- HttpServletServer.factory.build(VFCSIM_SERVER_NAME,LOCALHOST, VFCSIM_SERVER_PORT, "/", false, true);
- testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
- }
- return testServer;
- }
-
- /**
- * Build a guard simulator.
- *
- * @return the simulator
- * @throws InterruptedException if a thread is interrupted
- * @throws IOException if an IO errror occurs
- */
- public static HttpServletServer buildGuardSim() throws InterruptedException, IOException {
- HttpServletServer testServer = HttpServletServer.factory.build(GUARDSIM_SERVER_NAME, LOCALHOST,
- GUARDSIM_SERVER_PORT, "/", false, true);
- testServer.addServletClass("/*", GuardSimulatorJaxRs.class.getName());
- testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
- }
- return testServer;
- }
-}
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
deleted file mode 100644
index 101184d69..000000000
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2018 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 javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Path("/api/nslcm/v1")
-public class VfcSimulatorJaxRs {
-
- /**
- * VFC post query.
- *
- * @param nsInstanceId the NS instance
- * @param response the response
- * @return the response
- */
- @POST
- @Path("/ns/{nsInstanceId}/heal")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId,
- @Context final HttpServletResponse response) {
- response.setStatus(HttpServletResponse.SC_ACCEPTED);
- try {
- response.flushBuffer();
- } catch (Exception e) {
- final Logger logger = LoggerFactory.getLogger(VfcSimulatorJaxRs.class);
- logger.error("flushBuffer threw: ", e);
- return "";
- }
-
- return "{\"jobId\":\"1\"}";
- }
-
- /**
- * VFC get query.
- *
- * @param jobId tthe job id
- * @return the response
- */
- @GET
- @Path("/jobs/{jobId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String vfcGetQuery(@PathParam("jobId") String jobId) {
- return "{\"jobId\" : " + jobId
- + ",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription"
- + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\""
- + "responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription"
- + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\""
- + "progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are "
- + "decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";
- }
-
-}
-
diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json
deleted file mode 100644
index 77b30bdb1..000000000
--- a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "inventory-response-item": [],
- "requestError": {
- "serviceException": {
- "messageId": "SVC3001",
- "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
- "variables": [
- "POST Search",
- "getNamedQueryResponse",
- "Node Not Found:No Node of type ${type} found for properties",
- "ERR.5.4.6114"
- ]
- }
- }
-}
diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json
deleted file mode 100644
index 906e4afbb..000000000
--- a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json
+++ /dev/null
@@ -1,77 +0,0 @@
-{
- "inventory-response-item": [
- {
- "model-name": "service-instance",
- "generic-vnf": {
- "vnf-id": "${vnfId}",
- "vnf-name": "${vnfName}",
- "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
- "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
- "prov-status": "ACTIVE",
- "in-maint": false,
- "is-closed-loop-disabled": false,
- "resource-version": "1503082370097",
- "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4",
- "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9"
- },
- "extra-properties": {
- "extra-property": []
- },
- "inventory-response-items": {
- "inventory-response-item": [
- {
- "model-name": "service-instance",
- "service-instance": {
- "service-instance-id": "37b8cdb7-94eb-468f-a0c2-4e3c3546578e",
- "service-instance-name": "Changed Service Instance NAME",
- "resource-version": "1503082993532",
- "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4",
- "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9"
- },
- "extra-properties": {
- "extra-property": []
- },
- "inventory-response-items": {
- "inventory-response-item": [
- {
- "model-name": "pnf",
- "generic-vnf": {
- "vnf-id": "${pnfVnfId}",
- "vnf-name": "${pnfVndName}",
- "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
- "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
- "in-maint": false,
- "is-closed-loop-disabled": false,
- "resource-version": "1504013830207",
- "model-invariant-id": "862b25a1-262a-4961-bdaa-cdc55d69785a",
- "model-version-id": "e9f1fa7d-c839-418a-9601-03dc0d2ad687"
- },
- "extra-properties": {
- "extra-property": []
- }
- },
- {
- "model-name": "service-instance",
- "generic-vnf": {
- "vnf-id": "${serviceInstanceVnfId}",
- "vnf-name": "${serviceInstanceVnfName}",
- "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
- "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
- "in-maint": false,
- "is-closed-loop-disabled": false,
- "resource-version": "1504014833841",
- "model-invariant-id": "Eace933104d443b496b8.nodes.heat.vpg",
- "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9"
- },
- "extra-properties": {
- "extra-property": []
- }
- }
- ]
- }
- }
- ]
- }
- }
- ]
-}
diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json
deleted file mode 100644
index af40be948..000000000
--- a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json
+++ /dev/null
@@ -1,267 +0,0 @@
-{
- "inventory-response-item": [
- {
- "vserver": {
- "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
- "vserver-name": "zdfw1lb01lb02",
- "vserver-name2": "zdfw1lb01lb02",
- "prov-status": "ACTIVE",
- "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
- "in-maint": false,
- "is-closed-loop-disabled": false,
- "resource-version": "1510606403522"
- },
- "extra-properties": {
- "extra-property": []
- },
- "inventory-response-items": {
- "inventory-response-item": [
- {
- "model-name": "vLoadBalancer",
- "generic-vnf": {
- "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144",
- "vnf-name": "Vfmodule_vLB1113",
- "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0",
- "service-id": "66f157fc-4148-4880-95f5-e120677e98d1",
- "prov-status": "PREPROV",
- "in-maint": false,
- "is-closed-loop-disabled": false,
- "resource-version": "1510604011851",
- "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc",
- "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
- },
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model-ver.model-version-id",
- "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
- },
- {
- "property-name": "model-ver.model-name",
- "property-value": "vLoadBalancer"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-invariant-id",
- "property-value": "cee050ed-92a5-494f-ab04-234307a846dc"
- },
- {
- "property-name": "model-ver.model-version",
- "property-value": "1.0"
- }
- ]
- },
- "inventory-response-items": {
- "inventory-response-item": [
- {
- "model-name": "vLoadBalancer-1106",
- "service-instance": {
- "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941",
- "service-instance-name": "vLoadBalancer-1113",
- "resource-version": "1510603936425",
- "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a",
- "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50"
- },
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model-ver.model-version-id",
- "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50"
- },
- {
- "property-name": "model-ver.model-name",
- "property-value": "vLoadBalancer-1106"
- },
- {
- "property-name": "model.model-type",
- "property-value": "service"
- },
- {
- "property-name": "model.model-invariant-id",
- "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a"
- },
- {
- "property-name": "model-ver.model-version",
- "property-value": "1.0"
- }
- ]
- }
- },
- {
- "model-name": "Vloadbalancer..base_vlb..module-0",
- "vf-module": {
- "vf-module-id": "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12",
- "vf-module-name": "Vfmodule_vLB1113-1",
- "heat-stack-id": "Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db",
- "orchestration-status": "active",
- "is-base-vf-module": true,
- "resource-version": "1510604612557",
- "model-invariant-id": "6d760188-9a24-451a-b05b-e08b86cb94f2",
- "model-version-id": "93facad9-55f2-4fe0-9574-814c2bc2d071"
- },
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model-ver.model-version-id",
- "property-value": "93facad9-55f2-4fe0-9574-814c2bc2d071"
- },
- {
- "property-name": "model-ver.model-name",
- "property-value": "Vloadbalancer..base_vlb..module-0"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-invariant-id",
- "property-value": "6d760188-9a24-451a-b05b-e08b86cb94f2"
- },
- {
- "property-name": "model-ver.model-version",
- "property-value": "1"
- }
- ]
- }
- },
- {
- "model-name": "Vloadbalancer..dnsscaling..module-1",
- "vf-module": {
- "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
- "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
- "is-base-vf-module": false,
- "resource-version": "1510610079687",
- "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
- "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
- },
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model-ver.model-version-id",
- "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
- },
- {
- "property-name": "model-ver.model-name",
- "property-value": "Vloadbalancer..dnsscaling..module-1"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-invariant-id",
- "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
- },
- {
- "property-name": "model-ver.model-version",
- "property-value": "1"
- }
- ]
- }
- },
- {
- "model-name": "Vloadbalancer..dnsscaling..module-1",
- "vf-module": {
- "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
- "vf-module-name": "my_module_1",
- "is-base-vf-module": false,
- "resource-version": "1510610079687",
- "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
- "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
- },
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model-ver.model-version-id",
- "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
- },
- {
- "property-name": "model-ver.model-name",
- "property-value": "Vloadbalancer..dnsscaling..module-1"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-invariant-id",
- "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
- },
- {
- "property-name": "model-ver.model-version",
- "property-value": "1"
- }
- ]
- }
- },
- {
- "model-name": "Vloadbalancer..dnsscaling..module-1",
- "vf-module": {
- "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
- "vf-module-name": "my_module_2",
- "is-base-vf-module": false,
- "resource-version": "1510610079687",
- "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
- "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
- },
- "extra-properties": {
- "extra-property": [
- {
- "property-name": "model-ver.model-version-id",
- "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
- },
- {
- "property-name": "model-ver.model-name",
- "property-value": "Vloadbalancer..dnsscaling..module-1"
- },
- {
- "property-name": "model.model-type",
- "property-value": "resource"
- },
- {
- "property-name": "model.model-invariant-id",
- "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
- },
- {
- "property-name": "model-ver.model-version",
- "property-value": "1"
- }
- ]
- }
- }
- ]
- }
- },
- {
- "tenant": {
- "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd",
- "tenant-name": "Integration-SB-00",
- "resource-version": "1509587770200"
- },
- "extra-properties": {
- "extra-property": []
- },
- "inventory-response-items": {
- "inventory-response-item": [
- {
- "cloud-region": {
- "cloud-owner": "CloudOwner",
- "cloud-region-id": "RegionOne",
- "cloud-region-version": "v1",
- "resource-version": "1509587770092"
- },
- "extra-properties": {
- "extra-property": []
- }
- }
- ]
- }
- }
- ]
- }
- }
- ]
-}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
deleted file mode 100644
index b18e3da9d..000000000
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2019 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 static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-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.AaiManager;
-import org.onap.policy.aai.AaiNqInstanceFilters;
-import org.onap.policy.aai.AaiNqNamedQuery;
-import org.onap.policy.aai.AaiNqQueryParameters;
-import org.onap.policy.aai.AaiNqRequest;
-import org.onap.policy.aai.AaiNqResponse;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
-import org.onap.policy.rest.RestManager;
-
-public class AaiSimulatorTest {
-
- /**
- * Set up test class.
- */
- @BeforeClass
- public static void setUpSimulator() {
- LoggerUtil.setLevel("ROOT", "INFO");
- LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
- try {
- Util.buildAaiSim();
- } catch (final Exception e) {
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
- @Test
- public void testGet() {
- final AaiGetVnfResponse response = new AaiManager(new RestManager()).getQueryByVnfId(
- "http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass",
- UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
- assertNotNull(response);
- assertNotNull(response.getRelationshipList());
- }
-
- @Test
- public void testPost() {
- // check vserver named query
- final AaiNqRequest request = new AaiNqRequest();
- final AaiNqQueryParameters tempQueryParameters = new AaiNqQueryParameters();
- final AaiNqNamedQuery tempNamedQuery = new AaiNqNamedQuery();
- tempNamedQuery.setNamedQueryUuid(UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469"));
- tempQueryParameters.setNamedQuery(tempNamedQuery);
- request.setQueryParameters(tempQueryParameters);
- Map<String, String> tempInnerMap = new HashMap<>();
- tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- Map<String, Map<String, String>> tempOuterMap = new HashMap<>();
- tempOuterMap.put("vserver", tempInnerMap);
- List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>();
- tempInstanceFilter.add(tempOuterMap);
- AaiNqInstanceFilters tempInstanceFilters = new AaiNqInstanceFilters();
- tempInstanceFilters.setInstanceFilter(tempInstanceFilter);
- request.setInstanceFilters(tempInstanceFilters);
-
- AaiNqResponse response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser",
- "testPass", request, UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.getInventoryResponseItems());
-
- // check error response for vserver query
- tempInnerMap.put("vserver-name", "error");
-
- response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
- UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.getRequestError());
- assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("vserver"));
-
- // check generic-vnf named query
- tempNamedQuery.setNamedQueryUuid(UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"));
- tempQueryParameters.setNamedQuery(tempNamedQuery);
- request.setQueryParameters(tempQueryParameters);
- tempInnerMap = new HashMap<>();
- tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb");
- tempOuterMap = new HashMap<>();
- tempOuterMap.put("generic-vnf", tempInnerMap);
- tempInstanceFilter = new LinkedList<>();
- tempInstanceFilter.add(tempOuterMap);
- tempInstanceFilters = new AaiNqInstanceFilters();
- tempInstanceFilters.setInstanceFilter(tempInstanceFilter);
- request.setInstanceFilters(tempInstanceFilters);
-
- response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
- UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.getInventoryResponseItems());
- assertNull(response.getRequestError());
-
- // check error response for generic-vnf query
- tempInnerMap.put("vnf-id", "error");
-
- response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
- UUID.randomUUID());
- assertNotNull(response);
- assertNotNull(response.getRequestError());
- assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("generic-vnf"));
- }
-}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java
deleted file mode 100644
index c02f14334..000000000
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2019 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 static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
-import org.onap.policy.rest.RestManager;
-import org.onap.policy.rest.RestManager.Pair;
-
-public class GuardSimulatorTest {
-
- /**
- * Set up test class.
- */
- @BeforeClass
- public static void setupSimulator() {
- LoggerUtil.setLevel("ROOT", "INFO");
- LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
- try {
- org.onap.policy.simulators.Util.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
- @Test
- public void testGuard() {
- String request = makeRequest("test_actor_id", "test_op_id", "test_target", "test_clName");
- String url = "http://localhost:" + Util.GUARDSIM_SERVER_PORT + "/pdp/api/getDecision";
- Pair<Integer, String> response =
- new RestManager().post(url, "testUname", "testPass", null, "application/json", request);
- assertNotNull(response);
- assertNotNull(response.first);
- assertNotNull(response.second);
- assertEquals("{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}", response.second);
-
- request = makeRequest("test_actor_id", "test_op_id", "test_target", "denyGuard");
- response = new RestManager().post(url, "testUname", "testPass", null, "application/json", request);
- assertNotNull(response);
- assertNotNull(response.first);
- assertNotNull(response.second);
- assertEquals("{\"decision\": \"DENY\", \"details\": \"Decision Deny. You asked for it\"}", response.second);
- }
-
- private static String makeRequest(String actor, String recipe, String target, String clName) {
- return "{\"decisionAttributes\": {\"actor\": \"" + actor + "\", \"recipe\": \"" + recipe + "\""
- + ", \"target\": \"" + target + "\", \"clname\": \"" + clName + "\"}, \"onapName\": \"PDPD\"}";
- }
-}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
deleted file mode 100644
index c7545b005..000000000
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2019 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 static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.HashMap;
-import java.util.UUID;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
-import org.onap.policy.rest.RestManager;
-import org.onap.policy.rest.RestManager.Pair;
-import org.onap.policy.so.SoCloudConfiguration;
-import org.onap.policy.so.SoModelInfo;
-import org.onap.policy.so.SoRelatedInstance;
-import org.onap.policy.so.SoRelatedInstanceListElement;
-import org.onap.policy.so.SoRequest;
-import org.onap.policy.so.SoRequestDetails;
-import org.onap.policy.so.SoRequestInfo;
-import org.onap.policy.so.SoRequestParameters;
-import org.onap.policy.so.SoResponse;
-import org.onap.policy.so.util.Serialization;
-
-public class SoSimulatorTest {
-
- /**
- * Set up test class.
- */
- @BeforeClass
- public static void setUpSimulator() {
- LoggerUtil.setLevel("ROOT", "INFO");
- LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
- try {
- Util.buildSoSim();
- } catch (final Exception e) {
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
- /**
- * Create dummy SO request for TestResponse() junit.
- */
- private SoRequest createTestRequest() {
-
- // Construct SO Request
- final SoRequest request = new SoRequest();
- request.setRequestId(UUID.randomUUID());
- request.setRequestDetails(new SoRequestDetails());
- request.getRequestDetails().setModelInfo(new SoModelInfo());
- request.getRequestDetails().setCloudConfiguration(new SoCloudConfiguration());
- request.getRequestDetails().setRequestInfo(new SoRequestInfo());
- request.getRequestDetails().setRequestParameters(new SoRequestParameters());
- request.getRequestDetails().getRequestParameters().setUserParams(null);
- //
- // cloudConfiguration
- //
- request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW");
- request.getRequestDetails().getCloudConfiguration().setTenantId("1015548");
- //
- // modelInfo
- //
- request.getRequestDetails().getModelInfo().setModelType("vfModule");
- request.getRequestDetails().getModelInfo().setModelInvariantId("f32568ec-2f1c-458a-864b-0593d53d141a");
- request.getRequestDetails().getModelInfo().setModelVersionId("69615025-879d-4f0d-afe3-b7d1a7eeed1f");
- request.getRequestDetails().getModelInfo().setModelName("C15ce9e1E9144c8fB8bb..dnsscaling..module-1");
- request.getRequestDetails().getModelInfo().setModelVersion("1.0");
- //
- // requestInfo
- //
- request.getRequestDetails().getRequestInfo()
- .setInstanceName("vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8");
- request.getRequestDetails().getRequestInfo().setSource("POLICY");
- request.getRequestDetails().getRequestInfo().setSuppressRollback(false);
- request.getRequestDetails().getRequestInfo().setRequestorId("policy");
- //
- // relatedInstanceList
- //
- final SoRelatedInstanceListElement relatedInstanceListElement1 = new SoRelatedInstanceListElement();
- final SoRelatedInstanceListElement relatedInstanceListElement2 = new SoRelatedInstanceListElement();
- relatedInstanceListElement1.setRelatedInstance(new SoRelatedInstance());
- relatedInstanceListElement2.setRelatedInstance(new SoRelatedInstance());
- //
- relatedInstanceListElement1.getRelatedInstance().setInstanceId("cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5");
- relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SoModelInfo());
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service");
- relatedInstanceListElement1.getRelatedInstance().getModelInfo()
- .setModelInvariantId("4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b");
- relatedInstanceListElement1.getRelatedInstance().getModelInfo()
- .setModelVersionId("5c996219-b2e2-4c76-9b43-7e8672a33c1d");
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("8330e932-2a23-4943-8606");
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("1.0");
- //
- relatedInstanceListElement2.getRelatedInstance().setInstanceId("594e2fe0-48b8-41ff-82e2-3d4bab69b192");
- relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SoModelInfo());
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf");
- relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelInvariantId("033a32ed-aa65-4764-a736-36f2942f1aa0");
- relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelVersionId("d4d072dc-4e21-4a03-9524-628985819a8e");
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("c15ce9e1-e914-4c8f-b8bb");
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1");
- relatedInstanceListElement2.getRelatedInstance().getModelInfo()
- .setModelCustomizationName("c15ce9e1-e914-4c8f-b8bb 1");
- //
- request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1);
- request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2);
-
- return request;
- }
-
- @Test
- public void testResponse() {
- final String request = Serialization.gsonPretty.toJson(this.createTestRequest());
- final Pair<Integer, String> httpDetails = new RestManager().post(
- "http://localhost:6667/serviceInstantiation/v7/serviceInstances/12345/vnfs/12345/vfModules/scaleOut",
- "username",
- "password", new HashMap<>(), "application/json", request);
- assertNotNull(httpDetails);
- final SoResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, SoResponse.class);
- assertNotNull(response);
- }
-}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
deleted file mode 100644
index cb161d59f..000000000
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * simulators
- * ================================================================================
- * Copyright (C) 2017-2019 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 static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.HashMap;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
-import org.onap.policy.rest.RestManager;
-import org.onap.policy.rest.RestManager.Pair;
-import org.onap.policy.vfc.VfcResponse;
-import org.onap.policy.vfc.util.Serialization;
-
-public class VfcSimulatorTest {
-
- /**
- * Set up test class.
- */
- @BeforeClass
- public static void setUpSimulator() {
- LoggerUtil.setLevel("ROOT", "INFO");
- LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
- try {
- Util.buildVfcSim();
- } catch (final Exception e) {
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
- @Test
- public void testPost() {
- final Pair<Integer, String> httpDetails =
- new RestManager().post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password",
- new HashMap<String, String>(), "application/json", "Some Request Here");
- assertNotNull(httpDetails);
- assertTrue(httpDetails.first == 202);
- final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class);
- assertNotNull(response);
- }
-
- @Test
- public void testGet() {
- final Pair<Integer, String> httpDetails = new RestManager().get("http://localhost:6668/api/nslcm/v1/jobs/1234",
- "username", "password", new HashMap<String, String>());
- assertNotNull(httpDetails);
- final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class);
- assertNotNull(response);
- }
-}
null;
}
- @Override
+ @Override
public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
return new JsonPrimitive(datetime.format(format));
}
}
-
- public static class gsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ public static class GSONInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
@Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
return Instant.ofEpochMilli(json.getAsLong());
}
@@ -109,30 +102,30 @@ public final class Serialization {
public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.toEpochMilli());
}
-
+
}
-
- final static public Gson gson = new GsonBuilder().disableHtmlEscaping()
- .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
- .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+
+ public static final Gson gson = new GsonBuilder().disableHtmlEscaping()
+ .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
.create();
-
- final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
.setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
- .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
.create();
-
- final static public Gson gsonJunit = new GsonBuilder().disableHtmlEscaping()
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping()
.setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
.create();
}
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 6d7ecdb89..c09e64abe 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -147,7 +147,7 @@ rule "${policyName}.EVENT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- not ( ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID ) )
+ not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -160,14 +160,14 @@ rule "${policyName}.EVENT"
// we create the ControlLoopEventManager. The ControlLoopEventManager
// will do extra syntax checking as well check if the closed loop is disabled.
//
- if ($event.requestID == null) {
+ if ($event.getRequestID() == null) {
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.notification = ControlLoopNotificationType.REJECTED;
- notification.from = "policy";
- notification.message = "Missing requestID";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setNotification(ControlLoopNotificationType.REJECTED);
+ notification.setFrom("policy");
+ notification.setMessage("Missing requestID");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
//
// Let interested parties know
@@ -178,25 +178,25 @@ rule "${policyName}.EVENT"
// Retract it from memory
//
retract($event);
- } else if ($event.closedLoopEventStatus != ControlLoopEventStatus.ONSET) {
- throw new ControlLoopException($event.closedLoopEventStatus + " received with no prior onset");
+ } else if ($event.getClosedLoopEventStatus() != ControlLoopEventStatus.ONSET) {
+ throw new ControlLoopException($event.getClosedLoopEventStatus() + " received with no prior onset");
} else {
//
// Create an EventManager
//
- ControlLoopEventManager manager = new ControlLoopEventManager($params.getClosedLoopControlName(), $event.requestID);
+ ControlLoopEventManager manager = new ControlLoopEventManager($params.getClosedLoopControlName(), $event.getRequestID());
//
// Determine if EventManager can actively process the event (i.e. syntax, is_closed_loop_disabled checks etc.)
//
VirtualControlLoopNotification notification = manager.activate($params.getControlLoopYaml(), $event);
- notification.from = "pdp-0001-controller=controlloop"; // Engine.getInstanceName()
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setFrom("pdp-0001-controller=controlloop"); // Engine.getInstanceName()
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
//
// Are we actively pursuing this event?
//
- if (notification.notification == ControlLoopNotificationType.ACTIVE) {
+ if (notification.getNotification() == ControlLoopNotificationType.ACTIVE) {
//
// Insert Event Manager into memory, this will now kick off processing.
//
@@ -209,8 +209,8 @@ rule "${policyName}.EVENT"
// Setup the Overall Control Loop timer
//
ControlLoopTimer clTimer = new ControlLoopTimer();
- clTimer.setClosedLoopControlName($event.closedLoopControlName);
- clTimer.setRequestID($event.requestID.toString());
+ clTimer.setClosedLoopControlName($event.getClosedLoopControlName());
+ clTimer.setRequestID($event.getRequestID().toString());
clTimer.setDelay(manager.getControlLoopTimeout(1500) + "s");
//
// Insert it
@@ -237,11 +237,11 @@ rule "${policyName}.EVENT"
logger.warn("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName(), e);
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.notification = ControlLoopNotificationType.REJECTED;
- notification.message = "Exception occurred: " + e.getMessage();
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setNotification(ControlLoopNotificationType.REJECTED);
+ notification.setMessage("Exception occurred: " + e.getMessage());
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
//
//
//
@@ -263,8 +263,8 @@ rule "${policyName}.EVENT.MANAGER"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $clTimer : ControlLoopTimer ( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
+ $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -310,7 +310,7 @@ rule "${policyName}.EVENT.MANAGER"
}
logger.debug("{}: {}: target={}", $params.getClosedLoopControlName(),
- drools.getRule().getName(), $event.target);
+ drools.getRule().getName(), $event.getTarget());
//
// Now start seeing if we need to process this event
//
@@ -328,11 +328,11 @@ rule "${policyName}.EVENT.MANAGER"
if ($manager.getNumAbatements() > 0) {
logger.info("{}: {}: abatement received for {}. Closing the control loop",
$params.getClosedLoopControlName(), drools.getRule().getName(),
- $event.requestID);
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ $event.getRequestID());
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
//
// In this case, we are done
//
@@ -364,18 +364,18 @@ rule "${policyName}.EVENT.MANAGER"
//
// Check whether we need to wait for abatement
//
- if ($manager.getProcessor().getControlLoop().getAbatement() == true && notification.notification == ControlLoopNotificationType.FINAL_SUCCESS) {
+ if ($manager.getProcessor().getControlLoop().getAbatement() == true && notification.getNotification() == ControlLoopNotificationType.FINAL_SUCCESS) {
logger.info("{}: {}: waiting for abatement ..",
$params.getClosedLoopControlName(), drools.getRule().getName());
} else {
logger.info("{}: {}: no abatement expect for {}. Closing the control loop",
$params.getClosedLoopControlName(), drools.getRule().getName(),
- $event.requestID);
+ $event.getRequestID());
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
//
// In this case, we are done
@@ -424,8 +424,8 @@ rule "${policyName}.EVENT.MANAGER"
// insert operation timeout object
//
OperationTimer opTimer = new OperationTimer();
- opTimer.setClosedLoopControlName($event.closedLoopControlName);
- opTimer.setRequestID($event.requestID.toString());
+ opTimer.setClosedLoopControlName($event.getClosedLoopControlName());
+ opTimer.setRequestID($event.getRequestID().toString());
opTimer.setDelay(operation.getOperationTimeout().toString() + "s");
insert(opTimer);
@@ -436,14 +436,14 @@ rule "${policyName}.EVENT.MANAGER"
}
else {
logger.debug("The target resource {} is already processing",
- $event.AAI.get($event.target));
+ $event.getAAI().get($event.getTarget()));
notification = new VirtualControlLoopNotification($event);
- notification.notification = ControlLoopNotificationType.REJECTED;
- notification.message = "The target " + $event.AAI.get($event.target) + " is already locked";
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setNotification(ControlLoopNotificationType.REJECTED);
+ notification.setMessage("The target " + $event.getAAI().get($event.getTarget()) + " is already locked");
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
@@ -468,12 +468,12 @@ rule "${policyName}.EVENT.MANAGER"
drools.getRule().getName(), e);
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
- notification.message = e.getMessage();
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
+ notification.setMessage(e.getMessage());
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
@@ -493,10 +493,10 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
- $lock : TargetLock (requestID == $event.requestID)
- $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
+ $lock : TargetLock (requestID == $event.getRequestID())
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -531,13 +531,13 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
// Tell interested parties we are performing this Operation
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.notification = ControlLoopNotificationType.OPERATION;
- notification.message = $operation.getOperationMessage();
- notification.history = $operation.getHistory();
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setNotification(ControlLoopNotificationType.OPERATION);
+ notification.setMessage($operation.getOperationMessage());
+ notification.setHistory($operation.getHistory());
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
@@ -558,7 +558,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
if(request instanceof SORequest) {
// Call SO. The response will be inserted into memory once it's received
- SOActorServiceProvider.sendRequest($event.requestID.toString(), drools.getWorkingMemory(), request);
+ SOActorServiceProvider.sendRequest($event.getRequestID().toString(), drools.getWorkingMemory(), request);
}
break;
case "VFC":
@@ -601,9 +601,9 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, getGuardApprovalStatus() == "NONE" )
- $lock : TargetLock (requestID == $event.requestID)
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID(), getGuardApprovalStatus() == "NONE" )
+ $lock : TargetLock (requestID == $event.getRequestID())
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -615,13 +615,13 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
// Sending notification that we are about to query Guard ("DB write - start operation")
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.notification = ControlLoopNotificationType.OPERATION;
- notification.message = "Sending guard query for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe();
- notification.history = $operation.getHistory();
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setNotification(ControlLoopNotificationType.OPERATION);
+ notification.setMessage("Sending guard query for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe());
+ notification.setHistory($operation.getHistory());
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
@@ -641,16 +641,16 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
Thread t = new Thread(new org.onap.policy.guard.CallGuardTask(
drools.getWorkingMemory(),
- $event.closedLoopControlName,
+ $event.getClosedLoopControlName(),
$operation.policy.getActor().toString(),
$operation.policy.getRecipe(),
$operation.getTargetEntity(),
- $event.requestID.toString()
+ $event.getRequestID().toString()
));
t.start();
}
else{
- insert(new PolicyGuardResponse("Permit", $event.requestID, $operation.policy.getRecipe()));
+ insert(new PolicyGuardResponse("Permit", $event.getRequestID(), $operation.policy.getRecipe()));
}
end
@@ -663,11 +663,11 @@ rule "${policyName}.GUARD.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID )
- $lock : TargetLock (requestID == $event.requestID)
- $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
- $guardResponse : PolicyGuardResponse(requestID == $event.requestID, $operation.policy.recipe == operation)
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
+ $lock : TargetLock (requestID == $event.getRequestID())
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $guardResponse : PolicyGuardResponse(requestID == $event.getRequestID(), $operation.policy.recipe == operation)
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -685,13 +685,13 @@ rule "${policyName}.GUARD.RESPONSE"
// This notification has Guard result in "message". ("DB write - end operation in case of Guard Deny")
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.notification = ControlLoopNotificationType.OPERATION;
- notification.message = "Guard result for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe() + " is " + $guardResponse.result;
- notification.history = $operation.getHistory();
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setNotification(ControlLoopNotificationType.OPERATION);
+ notification.setMessage("Guard result for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe() + " is " + $guardResponse.result);
+ notification.setHistory($operation.getHistory());
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
@@ -717,7 +717,7 @@ end
* This rule responds to APPC Response Events
*
* I would have like to be consistent and write the Response like this:
-* $response : Response( CommonHeader.RequestID == $onset.requestID )
+* $response : Response( CommonHeader.RequestID == $onset.getRequestID() )
*
* However, no compile error was given. But a runtime error was given. I think
* because drools is confused between the classname CommonHeader vs the property CommonHeader.
@@ -727,11 +727,11 @@ rule "${policyName}.APPC.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID )
- $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
- $lock : TargetLock (requestID == $event.requestID)
- $response : Response( getCommonHeader().RequestID == $event.requestID )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $lock : TargetLock (requestID == $event.getRequestID())
+ $response : Response( getCommonHeader().RequestID == $event.getRequestID() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -751,20 +751,20 @@ rule "${policyName}.APPC.RESPONSE"
// This Operation has completed, construct a notification showing our results. (DB write - end operation)
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
- notification.message = $operation.getOperationHistory();
- notification.history = $operation.getHistory();
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
+ notification.setMessage($operation.getOperationHistory());
+ notification.setHistory($operation.getHistory());
if (policyResult.equals(PolicyResult.SUCCESS)) {
- notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS);
//
// Let interested parties know
//
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
} else {
- notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
//
// Let interested parties know
//
@@ -841,11 +841,11 @@ rule "${policyName}.APPC.LCM.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID )
- $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
- $lock : TargetLock (requestID == $event.requestID)
- $response : LCMResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.requestID )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $lock : TargetLock (requestID == $event.getRequestID())
+ $response : LCMResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestID() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -867,16 +867,16 @@ rule "${policyName}.APPC.LCM.RESPONSE"
// This Operation has completed, construct a notification showing our results. (DB write - end operation)
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
- notification.message = $operation.getOperationHistory();
- notification.history = $operation.getHistory();
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
+ notification.setMessage($operation.getOperationHistory());
+ notification.setHistory($operation.getHistory());
if (policyResult.equals(PolicyResult.SUCCESS)) {
- notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS);
} else {
- notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
}
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
//
@@ -946,11 +946,11 @@ rule "${policyName}.SO.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID )
- $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
- $lock : TargetLock (requestID == $event.requestID)
- $response : SOResponseWrapper(requestID.toString() == $event.requestID.toString() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $lock : TargetLock (requestID == $event.getRequestID())
+ $response : SOResponseWrapper(requestID.toString() == $event.getRequestID().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -971,16 +971,16 @@ rule "${policyName}.SO.RESPONSE"
// This Operation has completed, construct a notification showing our results
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
- notification.message = $operation.getOperationHistory();
- notification.history = $operation.getHistory();
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
+ notification.setMessage($operation.getOperationHistory());
+ notification.setHistory($operation.getHistory());
if (policyResult.equals(PolicyResult.SUCCESS)) {
- notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS);
} else {
- notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
}
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
@@ -1030,11 +1030,11 @@ rule "${policyName}.VFC.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID )
- $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
- $lock : TargetLock (requestID == $event.requestID)
- $response : VFCResponse( requestId.toString() == $event.requestID.toString() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $lock : TargetLock (requestID == $event.getRequestID())
+ $response : VFCResponse( requestId.toString() == $event.getRequestID().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName());
@@ -1050,12 +1050,12 @@ rule "${policyName}.VFC.RESPONSE"
// This Operation has completed, construct a notification showing our results
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
- notification.message = $operation.getOperationHistory();
- notification.history = $operation.getHistory();
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
+ notification.setMessage($operation.getOperationHistory());
+ notification.setHistory($operation.getHistory());
//
// Ensure the operation is complete
//
@@ -1103,10 +1103,10 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.TIMEOUT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID )
- $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString(), $to : getDelay() )
- $lock : TargetLock (requestID == $event.requestID)
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString(), $to : getDelay() )
+ $lock : TargetLock (requestID == $event.getRequestID())
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1123,13 +1123,13 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.TIMEOUT"
// Create a notification for it ("DB Write - end operation")
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
- notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
- notification.message = $operation.getOperationHistory();
- notification.history = $operation.getHistory();
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
+ notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
+ notification.setMessage($operation.getOperationHistory());
+ notification.setHistory($operation.getHistory());
//
// Let interested parties know
//
@@ -1168,14 +1168,14 @@ rule "${policyName}.EVENT.MANAGER.TIMEOUT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $clTimer : ControlLoopTimer ( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString(), $to : getDelay() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
+ $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString(), $to : getDelay() )
$operations : LinkedList()
- from collect( ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID ) )
+ from collect( ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() ) )
$opTimers : LinkedList()
- from collect( OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() ) )
+ from collect( OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() ) )
$locks : LinkedList()
- from collect( TargetLock (requestID == $event.requestID) )
+ from collect( TargetLock (requestID == $event.getRequestID()) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1195,10 +1195,10 @@ rule "${policyName}.EVENT.MANAGER.TIMEOUT"
//
VirtualControlLoopNotification notification = $manager.setControlLoopTimedOut();
if (notification != null) {
- notification.from = "policy";
- notification.policyName = drools.getRule().getName();
- notification.policyScope = "${policyScope}";
- notification.policyVersion = "${policyVersion}";
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
//
// Let interested parties know
//
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
index 869a1a6ff..826488691 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
@@ -270,64 +270,64 @@ public class ControlLoopFailureTest implements TopicListener {
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
- String policyName = notification.policyName;
+ String policyName = notification.getPolicyName();
if (policyName.endsWith("EVENT")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("Sending guard query"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("Sending guard query"));
}
else if (policyName.endsWith("GUARD.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.toLowerCase().endsWith("permit"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
}
else if (policyName.endsWith("GUARD_PERMITTED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=APPC"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=APPC"));
}
else if (policyName.endsWith("OPERATION.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
}
else if (policyName.endsWith("APPC.LCM.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=APPC"));
- if (requestId.equals(notification.requestID)) {
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=APPC"));
+ if (requestId.equals(notification.getRequestID())) {
sendEvent(pair.a, requestId, ControlLoopEventStatus.ABATED, "vnf01");
}
- else if (requestId2.equals(notification.requestID)) {
+ else if (requestId2.equals(notification.getRequestID())) {
sendEvent(pair.a, requestId2, ControlLoopEventStatus.ABATED, "vnf02");
}
}
else if (policyName.endsWith("EVENT.MANAGER")) {
- logger.debug("Rule Fired: " + notification.policyName);
- if (requestId3.equals(notification.requestID)) {
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ if (requestId3.equals(notification.getRequestID())) {
/*
* The event with the duplicate target should be rejected
*/
- assertTrue(ControlLoopNotificationType.REJECTED.equals(notification.notification));
+ assertTrue(ControlLoopNotificationType.REJECTED.equals(notification.getNotification()));
}
else {
- assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
+ assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification()));
}
if (++eventCount == 3) {
kieSession.halt();
}
}
else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
@@ -378,13 +378,13 @@ public class ControlLoopFailureTest implements TopicListener {
protected void sendEvent(ControlLoopPolicy policy, UUID requestID,
ControlLoopEventStatus status, String target) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
- event.requestID = requestID;
- event.target = "generic-vnf.vnf-id";
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<>();
- event.AAI.put("generic-vnf.vnf-id", target);
- event.closedLoopEventStatus = status;
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestID(requestID);
+ event.setTarget("generic-vnf.vnf-id");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("generic-vnf.vnf-id", target);
+ event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
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 c95d558a5..661d8c187 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
@@ -276,55 +276,55 @@ public class VCPEControlLoopTest implements TopicListener {
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
- String policyName = notification.policyName;
+ String policyName = notification.getPolicyName();
if (policyName.endsWith("EVENT")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("Sending guard query"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("Sending guard query"));
}
else if (policyName.endsWith("GUARD.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.toLowerCase().endsWith("permit"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
}
else if (policyName.endsWith("GUARD_PERMITTED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=APPC"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=APPC"));
}
else if (policyName.endsWith("OPERATION.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
}
else if (policyName.endsWith("APPC.LCM.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=APPC"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=APPC"));
sendEvent(pair.a, requestID, ControlLoopEventStatus.ABATED);
}
else if (policyName.endsWith("EVENT.MANAGER")) {
- logger.debug("Rule Fired: " + notification.policyName);
- if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-name"))) {
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ if ("getFail".equals(notification.getAAI().get("generic-vnf.vnf-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
kieSession.halt();
}
else {
- assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.notification);
+ assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification());
kieSession.halt();
}
}
else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
@@ -366,37 +366,37 @@ public class VCPEControlLoopTest implements TopicListener {
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
- event.requestID = requestID;
- event.target = "generic-vnf.vnf-name";
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<>();
- event.AAI.put("generic-vnf.vnf-name", "testGenericVnfName");
- event.closedLoopEventStatus = status;
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestID(requestID);
+ event.setTarget("generic-vnf.vnf-name");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("generic-vnf.vnf-name", "testGenericVnfName");
+ event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
protected void sendEvent(ControlLoopPolicy policy, UUID requestID,
ControlLoopEventStatus status, String vnfName, boolean isEnriched) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
- event.requestID = requestID;
- event.target = "generic-vnf.vnf-name";
- event.target_type = ControlLoopTargetType.VNF;
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<>();
- event.AAI.put("generic-vnf.vnf-name", vnfName);
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestID(requestID);
+ event.setTarget("generic-vnf.vnf-name");
+ event.setTargetType(ControlLoopTargetType.VNF);
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("generic-vnf.vnf-name", vnfName);
if (isEnriched) {
- event.AAI.put("generic-vnf.in-maint", "false");
- event.AAI.put("generic-vnf.is-closed-loop-disabled", "false");
- event.AAI.put("generic-vnf.orchestration-status", "Created");
- event.AAI.put("generic-vnf.prov-status", "PREPROV");
- event.AAI.put("generic-vnf.resource-version", "1");
- event.AAI.put("generic-vnf.service-id", "e8cb8968-5411-478b-906a-f28747de72cd");
- event.AAI.put("generic-vnf.vnf-id", "63b31229-9a3a-444f-9159-04ce2dca3be9");
- event.AAI.put("generic-vnf.vnf-type", "vCPEInfraService10/vCPEInfraService10 0");
+ event.getAAI().put("generic-vnf.in-maint", "false");
+ event.getAAI().put("generic-vnf.is-closed-loop-disabled", "false");
+ event.getAAI().put("generic-vnf.orchestration-status", "Created");
+ event.getAAI().put("generic-vnf.prov-status", "PREPROV");
+ event.getAAI().put("generic-vnf.resource-version", "1");
+ event.getAAI().put("generic-vnf.service-id", "e8cb8968-5411-478b-906a-f28747de72cd");
+ event.getAAI().put("generic-vnf.vnf-id", "63b31229-9a3a-444f-9159-04ce2dca3be9");
+ event.getAAI().put("generic-vnf.vnf-type", "vCPEInfraService10/vCPEInfraService10 0");
}
- event.closedLoopEventStatus = status;
+ event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
index f7e2c3049..25a69b14e 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
@@ -319,56 +319,56 @@ public class VDNSControlLoopTest implements TopicListener {
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
- String policyName = notification.policyName;
+ String policyName = notification.getPolicyName();
if (policyName.endsWith("EVENT")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("Sending guard query"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("Sending guard query"));
}
else if (policyName.endsWith("GUARD.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.toLowerCase().endsWith("permit"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
}
else if (policyName.endsWith("GUARD_PERMITTED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=SO"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=SO"));
}
else if (policyName.endsWith("OPERATION.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
}
else if (policyName.endsWith("SO.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=SO"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=SO"));
}
else if (policyName.endsWith("EVENT.MANAGER")) {
- logger.debug("Rule Fired: " + notification.policyName);
- if ("error".equals(notification.AAI.get("vserver.vserver-name"))) {
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ if ("error".equals(notification.getAAI().get("vserver.vserver-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
}
- else if ("getFail".equals(notification.AAI.get("vserver.vserver-name"))) {
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ else if ("getFail".equals(notification.getAAI().get("vserver.vserver-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
}
else {
- assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
+ assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification()));
}
kieSession.halt();
}
else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
@@ -390,26 +390,26 @@ public class VDNSControlLoopTest implements TopicListener {
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
- event.requestID = requestID;
- event.target = "vserver.vserver-name";
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<>();
- event.AAI.put("vserver.vserver-name", "dfw1lb01lb01");
- event.AAI.put("vserver.is-closed-loop-disabled", "false");
- event.closedLoopEventStatus = status;
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestID(requestID);
+ event.setTarget("vserver.vserver-name");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("vserver.vserver-name", "dfw1lb01lb01");
+ event.getAAI().put("vserver.is-closed-loop-disabled", "false");
+ event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vserverName) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
- event.requestID = requestID;
- event.target = "vserver.vserver-name";
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<>();
- event.AAI.put("vserver.vserver-name", vserverName);
- event.closedLoopEventStatus = status;
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestID(requestID);
+ event.setTarget("vserver.vserver-name");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("vserver.vserver-name", vserverName);
+ event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
index 39dac8131..178b5b29d 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
@@ -192,16 +192,16 @@ public class VFCControlLoopTest implements TopicListener {
*/
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
- event.requestID = UUID.randomUUID();
- event.closedLoopEventClient = "tca.instance00009";
- event.target_type = ControlLoopTargetType.VM;
- event.target = "vserver.vserver-name";
- event.from = "DCAE";
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<String, String>();
- event.AAI.put("vserver.vserver-name", "nullRequest");
- event.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+ event.setClosedLoopControlName(pair.a.getControlLoop().getControlLoopName());
+ event.setRequestID(UUID.randomUUID());
+ event.setClosedLoopEventClient("tca.instance00009");
+ event.setTargetType(ControlLoopTargetType.VM);
+ event.setTarget("vserver.vserver-name");
+ event.setFrom("DCAE");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<String, String>());
+ event.getAAI().put("vserver.vserver-name", "nullRequest");
+ event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
kieSession.insert(event);
kieSession.fireUntilHalt();
@@ -287,53 +287,53 @@ public class VFCControlLoopTest implements TopicListener {
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
- String policyName = notification.policyName;
+ String policyName = notification.getPolicyName();
if (policyName.endsWith("EVENT")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("Sending guard query"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("Sending guard query"));
}
else if (policyName.endsWith("GUARD.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.toLowerCase().endsWith("permit"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
}
else if (policyName.endsWith("GUARD_PERMITTED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=VFC"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=VFC"));
}
else if (policyName.endsWith("OPERATION.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
}
else if (policyName.endsWith("VFC.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=VFC"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=VFC"));
}
else if (policyName.endsWith("EVENT.MANAGER")) {
- logger.debug("Rule Fired: " + notification.policyName);
- if ("nullRequest".equals(notification.AAI.get("vserver.vserver-name"))){
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ if ("nullRequest".equals(notification.getAAI().get("vserver.vserver-name"))){
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
}
else {
- assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.notification);
+ assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification());
}
kieSession.halt();
}
else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
@@ -355,20 +355,20 @@ public class VFCControlLoopTest implements TopicListener {
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
- event.requestID = UUID.randomUUID();
- event.closedLoopEventClient = "tca.instance00009";
- event.target_type = ControlLoopTargetType.VM;
- event.target = "vserver.vserver-name";
- event.from = "DCAE";
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<String, String>();
- event.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- event.AAI.put("vserver.vserver-id", "vserver-id-16102016-aai3255-data-11-1");
- event.AAI.put("generic-vnf.vnf-id", "vnf-id-16102016-aai3255-data-11-1");
- event.AAI.put("service-instance.service-instance-id", "service-instance-id-16102016-aai3255-data-11-1");
- event.AAI.put("vserver.is-closed-loop-disabled", "false");
- event.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestID(UUID.randomUUID());
+ event.setClosedLoopEventClient("tca.instance00009");
+ event.setTargetType(ControlLoopTargetType.VM);
+ event.setTarget("vserver.vserver-name");
+ event.setFrom("DCAE");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<String, String>());
+ event.getAAI().put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ event.getAAI().put("vserver.vserver-id", "vserver-id-16102016-aai3255-data-11-1");
+ event.getAAI().put("generic-vnf.vnf-id", "vnf-id-16102016-aai3255-data-11-1");
+ event.getAAI().put("service-instance.service-instance-id", "service-instance-id-16102016-aai3255-data-11-1");
+ event.getAAI().put("vserver.is-closed-loop-disabled", "false");
+ event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
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 95737b9c8..156fbbaa8 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
@@ -322,58 +322,58 @@ public class VFWControlLoopTest implements TopicListener {
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
- String policyName = notification.policyName;
+ String policyName = notification.getPolicyName();
if (policyName.endsWith("EVENT")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.notification));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
}
else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("Sending guard query"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("Sending guard query"));
}
else if (policyName.endsWith("GUARD.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.toLowerCase().endsWith("permit"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
}
else if (policyName.endsWith("GUARD_PERMITTED")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=APPC"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=APPC"));
}
else if (policyName.endsWith("OPERATION.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
}
else if (policyName.endsWith("APPC.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.policyName);
- assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.notification));
- assertNotNull(notification.message);
- assertTrue(notification.message.startsWith("actor=APPC"));
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
+ assertNotNull(notification.getMessage());
+ assertTrue(notification.getMessage().startsWith("actor=APPC"));
sendEvent(pair.a, requestID, ControlLoopEventStatus.ABATED);
}
else if (policyName.endsWith("EVENT.MANAGER")) {
- logger.debug("Rule Fired: " + notification.policyName);
- if ("error".equals(notification.AAI.get("generic-vnf.vnf-name"))) {
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
- assertEquals("Target vnf-id could not be found", notification.message);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
+ if ("error".equals(notification.getAAI().get("generic-vnf.vnf-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
+ assertEquals("Target vnf-id could not be found", notification.getMessage());
}
- else if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-name"))) {
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification);
+ else if ("getFail".equals(notification.getAAI().get("generic-vnf.vnf-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
}
else {
- assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
+ assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification()));
}
kieSession.halt();
}
else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.policyName);
+ logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
@@ -407,13 +407,13 @@ public class VFWControlLoopTest implements TopicListener {
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
- event.requestID = requestID;
- event.target = "generic-vnf.vnf-name";
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<>();
- event.AAI.put("generic-vnf.vnf-name", "testGenericVnfID");
- event.closedLoopEventStatus = status;
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestID(requestID);
+ event.setTarget("generic-vnf.vnf-name");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("generic-vnf.vnf-name", "testGenericVnfID");
+ event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
@@ -428,13 +428,13 @@ public class VFWControlLoopTest implements TopicListener {
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vnfId) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
- event.requestID = requestID;
- event.target = "generic-vnf.vnf-name";
- event.closedLoopAlarmStart = Instant.now();
- event.AAI = new HashMap<>();
- event.AAI.put("generic-vnf.vnf-name", vnfId);
- event.closedLoopEventStatus = status;
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestID(requestID);
+ event.setTarget("generic-vnf.vnf-name");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("generic-vnf.vnf-name", vnfId);
+ event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}