summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/clamp/clds/config/LegacyOperationalPolicyController.java48
-rw-r--r--src/main/java/org/onap/clamp/policy/Policy.java2
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java5
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java252
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java104
-rw-r--r--src/main/resources/application-noaaf.properties2
-rw-r--r--src/main/resources/application.properties2
-rw-r--r--src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java11
-rw-r--r--src/test/java/org/onap/clamp/loop/PolicyComponentTest.java6
-rw-r--r--src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java61
-rw-r--r--src/test/resources/tosca/operational-policy-payload-legacy.yaml90
-rw-r--r--src/test/resources/tosca/operational-policy-payload.json4
-rw-r--r--src/test/resources/tosca/operational-policy-payload.yaml100
13 files changed, 19 insertions, 668 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/LegacyOperationalPolicyController.java b/src/main/java/org/onap/clamp/clds/config/LegacyOperationalPolicyController.java
deleted file mode 100644
index 69e94a35a..000000000
--- a/src/main/java/org/onap/clamp/clds/config/LegacyOperationalPolicyController.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2020 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.clamp.clds.config;
-
-import javax.annotation.PostConstruct;
-import org.onap.clamp.loop.template.PolicyModel;
-import org.onap.clamp.loop.template.PolicyModelsService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-
-@Configuration
-@Profile("legacy-operational-policy")
-public class LegacyOperationalPolicyController {
-
- @Autowired
- PolicyModelsService policyModelService;
-
- public static final String OPERATIONAL_POLICY_LEGACY = "onap.policies.controlloop.Operational";
-
- @PostConstruct
- public void init() {
- policyModelService.saveOrUpdatePolicyModel(new PolicyModel(OPERATIONAL_POLICY_LEGACY, "", "1.0.0",
- "OperationalPolicyLegacy"));
- }
-}
-
diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java
index 65e88d182..d84f2c8a0 100644
--- a/src/main/java/org/onap/clamp/policy/Policy.java
+++ b/src/main/java/org/onap/clamp/policy/Policy.java
@@ -284,6 +284,4 @@ public abstract class Policy extends AuditEntity {
.append(blueprintFilename.replaceAll(".yaml", ""));
return buffer.toString().replace('.', '_').replaceAll(" ", "");
}
-
- public abstract Boolean isLegacy();
}
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
index 127f495cc..77627a31a 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
@@ -157,11 +157,6 @@ public class MicroServicePolicy extends Policy implements Serializable {
this.getPolicyModel().getPolicyModelType(), serviceModel));
}
- @Override
- public Boolean isLegacy() {
- return false;
- }
-
public Boolean getShared() {
return shared;
}
diff --git a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java
deleted file mode 100644
index a7a344df2..000000000
--- a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
- * reserved.
- * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
- * ================================================================================
- * 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.clamp.policy.operational;
-
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-import org.apache.commons.lang3.math.NumberUtils;
-import org.onap.clamp.loop.Loop;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * This class contains the code required to support the sending of Legacy
- * operational payload to policy engine. This will probably disappear in El
- * Alto.
- */
-public class LegacyOperationalPolicy {
-
- private static final String ACTOR = "actor";
- private static final String RECIPE = "recipe";
- private static final String POLICIES = "policies";
- private static final String PAYLOAD = "payload";
-
- private LegacyOperationalPolicy() {
-
- }
-
- private static void translateStringValues(String jsonKey, String stringValue, JsonElement parentJsonElement) {
- if (stringValue.equalsIgnoreCase("true") || stringValue.equalsIgnoreCase("false")) {
- parentJsonElement.getAsJsonObject().addProperty(jsonKey, Boolean.valueOf(stringValue));
-
- } else if (NumberUtils.isParsable(stringValue)) {
- parentJsonElement.getAsJsonObject().addProperty(jsonKey, Long.parseLong(stringValue));
- }
- }
-
- private static JsonElement removeAllQuotes(JsonElement jsonElement) {
- if (jsonElement.isJsonArray()) {
- for (JsonElement element : jsonElement.getAsJsonArray()) {
- removeAllQuotes(element);
- }
- } else if (jsonElement.isJsonObject()) {
- for (Entry<String, JsonElement> entry : jsonElement.getAsJsonObject().entrySet()) {
- if (entry.getValue().isJsonPrimitive() && entry.getValue().getAsJsonPrimitive().isString()) {
- translateStringValues(entry.getKey(), entry.getValue().getAsString(), jsonElement);
- } else {
- removeAllQuotes(entry.getValue());
- }
- }
- }
- return jsonElement;
- }
-
- /**
- * This method rework the payload attribute (yaml) that is normally wrapped in a
- * string when coming from the UI.
- *
- * @param policyJson The operational policy json config
- * @return The same object reference but modified
- */
- public static JsonElement reworkPayloadAttributes(JsonElement policyJson) {
- for (JsonElement policy : policyJson.getAsJsonObject().get("policies").getAsJsonArray()) {
- JsonElement payloadElem = policy.getAsJsonObject().get("payload");
- String payloadString = payloadElem != null ? payloadElem.getAsString() : "";
- if (!payloadString.isEmpty()) {
- Map<String, String> testMap = new Yaml().load(payloadString);
- String json = new GsonBuilder().create().toJson(testMap);
- policy.getAsJsonObject().add("payload", new GsonBuilder().create().fromJson(json, JsonElement.class));
- }
- }
- return policyJson;
- }
-
- private static void replacePropertiesIfEmpty(JsonElement policy, String key, String valueIfEmpty) {
- JsonElement payloadElem = policy.getAsJsonObject().get(key);
- String payloadString = payloadElem != null ? payloadElem.getAsString() : "";
- if (payloadString.isEmpty()) {
- policy.getAsJsonObject().addProperty(key, valueIfEmpty);
- }
- }
-
- private static JsonElement fulfillPoliciesTreeField(JsonElement policyJson) {
- for (JsonElement policy : policyJson.getAsJsonObject().get("policies").getAsJsonArray()) {
- replacePropertiesIfEmpty(policy, "success", "final_success");
- replacePropertiesIfEmpty(policy, "failure", "final_failure");
- replacePropertiesIfEmpty(policy, "failure_timeout", "final_failure_timeout");
- replacePropertiesIfEmpty(policy, "failure_retries", "final_failure_retries");
- replacePropertiesIfEmpty(policy, "failure_exception", "final_failure_exception");
- replacePropertiesIfEmpty(policy, "failure_guard", "final_failure_guard");
- // Again special case for payload, should remove it if it's there but empty
- // otherwise policy crashes
- JsonElement payloadElem = policy.getAsJsonObject().get("payload");
- if (payloadElem != null && payloadElem.isJsonPrimitive() && payloadElem.getAsString().isEmpty()) {
- policy.getAsJsonObject().remove("payload");
- }
- }
- return policyJson;
- }
-
- private static Map<String, Object> createMap(JsonElement jsonElement) {
- Map<String, Object> mapResult = new TreeMap<>();
-
- if (jsonElement.isJsonObject()) {
- for (Entry<String, JsonElement> entry : jsonElement.getAsJsonObject().entrySet()) {
- if (entry.getValue().isJsonPrimitive() && entry.getValue().getAsJsonPrimitive().isString()) {
- mapResult.put(entry.getKey(), entry.getValue().getAsString());
- } else if (entry.getValue().isJsonPrimitive() && entry.getValue().getAsJsonPrimitive().isBoolean()) {
- mapResult.put(entry.getKey(), entry.getValue().getAsBoolean());
- } else if (entry.getValue().isJsonPrimitive() && entry.getValue().getAsJsonPrimitive().isNumber()) {
- // Only int ro long normally, we don't need float here
- mapResult.put(entry.getKey(), entry.getValue().getAsLong());
- } else if (entry.getValue().isJsonArray()) {
- List<Map<String, Object>> newArray = new ArrayList<>();
- mapResult.put(entry.getKey(), newArray);
- for (JsonElement element : entry.getValue().getAsJsonArray()) {
- newArray.add(createMap(element));
- }
- } else if (entry.getValue().isJsonObject()) {
- mapResult.put(entry.getKey(), createMap(entry.getValue()));
- }
- }
- }
- return mapResult;
- }
-
- /**
- * This method transforms the configuration json to a Yaml format.
- *
- * @param operationalPolicyJsonElement The operational policy json config
- * @return The Yaml as string
- */
- public static String createPolicyPayloadYamlLegacy(JsonElement operationalPolicyJsonElement) {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.PLAIN);
- options.setIndent(2);
- options.setPrettyFlow(true);
- // Policy can't support { } in the yaml
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- return (new Yaml(options)).dump(createMap(fulfillPoliciesTreeField(
- removeAllQuotes(reworkActorAttributes(operationalPolicyJsonElement.getAsJsonObject().deepCopy())))));
- }
-
- /**
- * This method load mandatory field in the operational policy configuration
- * JSON.
- *
- * @param configurationsJson The operational policy JSON
- * @param loop The parent loop object
- */
- public static void preloadConfiguration(JsonObject configurationsJson, Loop loop) {
- if (configurationsJson != null && configurationsJson.entrySet().isEmpty()) {
- JsonObject controlLoopName = new JsonObject();
- controlLoopName.addProperty("controlLoopName",
- loop != null ? loop.getName() : "Empty (NO loop loaded yet)");
- JsonObject controlLoop = new JsonObject();
- controlLoop.add("controlLoop", controlLoopName);
- configurationsJson.add("operational_policy", controlLoop);
- }
- }
-
- /**
- * This method rework on the actor/recipe and payload attribute.
- *
- * @param policyJson The operational policy json config
- * @return The same object reference but modified
- */
- public static JsonElement reworkActorAttributes(JsonElement policyJson) {
- for (JsonElement policy : policyJson.getAsJsonObject().get(POLICIES).getAsJsonArray()) {
- JsonObject actor = policy.getAsJsonObject().get(ACTOR).getAsJsonObject();
- policy.getAsJsonObject().remove(ACTOR);
- String actorStr = actor.getAsJsonObject().get(ACTOR).getAsString();
- policy.getAsJsonObject().addProperty(ACTOR, actorStr);
-
- if ("CDS".equalsIgnoreCase(actorStr)) {
- policy.getAsJsonObject().addProperty(RECIPE, getRecipe(actor));
- addCdsPayloadAttributes(actor.getAsJsonObject(RECIPE), policy);
- } else {
- policy.getAsJsonObject().addProperty(RECIPE,
- actor.getAsJsonObject().get(RECIPE).getAsString());
- addPayloadAttributes(actor, policy);
- }
- }
- return policyJson;
- }
-
- private static void addPayloadAttributes(JsonObject jsonObject,
- JsonElement policy) {
- JsonElement payloadElem = jsonObject.getAsJsonObject().get(PAYLOAD);
- String payloadString = payloadElem != null ? payloadElem.getAsString() : "";
- if (!payloadString.isEmpty()) {
- Map<String, String> testMap = new Yaml().load(payloadString);
- String json = new GsonBuilder().create().toJson(testMap);
- policy.getAsJsonObject().add(PAYLOAD,
- new GsonBuilder().create().fromJson(json, JsonElement.class));
- } else {
- policy.getAsJsonObject().addProperty(PAYLOAD, "");
- }
- }
-
- private static void addCdsPayloadAttributes(JsonObject jsonObject,
- JsonElement policy) {
- JsonElement payloadElem = jsonObject.getAsJsonObject().get(PAYLOAD);
- JsonObject payloadObject = payloadElem != null ?
- payloadElem.getAsJsonObject() : null;
- if (payloadObject != null) {
- /* Since policy expects payload to be map of string,
- converting data object to string. */
- JsonObject dataObject = payloadObject.get("data").getAsJsonObject();
- payloadObject.remove("data");
- payloadObject.addProperty("data", dataObject.toString());
- policy.getAsJsonObject().add(PAYLOAD,
- payloadObject);
- } else {
- policy.getAsJsonObject().addProperty(PAYLOAD, "");
- }
- }
-
- private static String getRecipe(JsonObject actor) {
- return actor.getAsJsonObject().get("recipe").getAsJsonObject().get("recipe").getAsString();
- }
-}
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
index b4020c18e..4b052427f 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -26,19 +26,10 @@ package org.onap.clamp.policy.operational;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
-import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@@ -50,7 +41,6 @@ import javax.persistence.Transient;
import org.apache.commons.lang3.RandomStringUtils;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
-import org.onap.clamp.clds.config.LegacyOperationalPolicyController;
import org.onap.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
@@ -58,8 +48,6 @@ import org.onap.clamp.loop.service.Service;
import org.onap.clamp.loop.template.LoopElementModel;
import org.onap.clamp.loop.template.PolicyModel;
import org.onap.clamp.policy.Policy;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
@Entity
@Table(name = "operational_policies")
@@ -139,10 +127,9 @@ public class OperationalPolicy extends Policy implements Serializable {
* @param service The loop service
* @param policyModel The policy model
* @param toscaConverter The tosca converter that must be used to create the Json representation
- * @throws IOException In case of issues with the legacy files (generated from resource files
*/
public OperationalPolicy(Loop loop, Service service, PolicyModel policyModel,
- ToscaConverterWithDictionarySupport toscaConverter) throws IOException {
+ ToscaConverterWithDictionarySupport toscaConverter) {
this(Policy.generatePolicyName("OPERATIONAL", service.getName(), service.getVersion(),
policyModel.getPolicyAcronym() + '_' + policyModel.getVersion(),
RandomStringUtils.randomAlphanumeric(3)),
@@ -182,18 +169,12 @@ public class OperationalPolicy extends Policy implements Serializable {
if (this.getPolicyModel() == null) {
return;
}
- if (this.isLegacy()) {
- // Op policy Legacy case
- LegacyOperationalPolicy.preloadConfiguration(this.getConfigurationsJson(), this.loop);
- this.setJsonRepresentation(OperationalPolicyRepresentationBuilder
- .generateOperationalPolicySchema(this.loop.getModelService()));
- }
- else {
- // Generic Case
- this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(
- this.getPolicyModel().getPolicyModelTosca(),
- this.getPolicyModel().getPolicyModelType(), serviceModel));
- }
+
+ // Generic Case
+ this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(
+ this.getPolicyModel().getPolicyModelTosca(),
+ this.getPolicyModel().getPolicyModelType(), serviceModel));
+
}
}
@@ -221,76 +202,17 @@ public class OperationalPolicy extends Policy implements Serializable {
if (other.name != null) {
return false;
}
- }
- else if (!name.equals(other.name)) {
- return false;
+ } else {
+ if (!name.equals(other.name)) {
+ return false;
+ }
}
return true;
}
- public Boolean isLegacy() {
- return (this.getPolicyModel() != null) && this.getPolicyModel().getPolicyModelType().contains(
- LegacyOperationalPolicyController.OPERATIONAL_POLICY_LEGACY);
- }
-
- /**
- * Create policy Yaml from json defined here.
- *
- * @return A string containing Yaml
- */
- public String createPolicyPayloadYaml() {
- JsonObject policyPayloadResult = new JsonObject();
-
- policyPayloadResult.addProperty("tosca_definitions_version", "tosca_simple_yaml_1_0_0");
-
- JsonObject topologyTemplateNode = new JsonObject();
- policyPayloadResult.add("topology_template", topologyTemplateNode);
-
- JsonArray policiesArray = new JsonArray();
- topologyTemplateNode.add("policies", policiesArray);
-
- JsonObject operationalPolicy = new JsonObject();
- policiesArray.add(operationalPolicy);
-
- JsonObject operationalPolicyDetails = new JsonObject();
- operationalPolicy.add(this.name, operationalPolicyDetails);
- operationalPolicyDetails.addProperty("type", "onap.policies.controlloop.Operational");
- operationalPolicyDetails.addProperty("version", "1.0.0");
-
- JsonObject metadata = new JsonObject();
- operationalPolicyDetails.add("metadata", metadata);
- metadata.addProperty("policy-id", this.name);
-
- operationalPolicyDetails.add("properties", LegacyOperationalPolicy
- .reworkActorAttributes(this.getConfigurationsJson().get("operational_policy").deepCopy()));
-
- DumperOptions options = new DumperOptions();
- options.setIndent(2);
- options.setPrettyFlow(true);
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- Gson gson = new GsonBuilder().create();
-
- return (new Yaml(options)).dump(gson.fromJson(gson.toJson(policyPayloadResult), Map.class));
- }
-
@Override
public String createPolicyPayload() throws UnsupportedEncodingException {
- if (isLegacy()) {
- // Now using the legacy payload fo Dublin
- JsonObject payload = new JsonObject();
- payload.addProperty("policy-id", this.getName());
- payload.addProperty("content",
- URLEncoder.encode(
- LegacyOperationalPolicy
- .createPolicyPayloadYamlLegacy(
- this.getConfigurationsJson().get("operational_policy")),
- StandardCharsets.UTF_8.toString()));
- String opPayload = new GsonBuilder().setPrettyPrinting().create().toJson(payload);
- logger.info("Operational policy payload: " + opPayload);
- return opPayload;
- }
- else {
- return super.createPolicyPayload();
- }
+ return super.createPolicyPayload();
+
}
}
diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties
index fba41348b..423c73e93 100644
--- a/src/main/resources/application-noaaf.properties
+++ b/src/main/resources/application-noaaf.properties
@@ -68,7 +68,7 @@ clamp.config.keyFile=classpath:/clds/aaf/org.onap.clamp.keyfile
server.servlet.context-path=/
#Modified engine-rest applicationpath
-spring.profiles.active=clamp-default,clamp-default-user,clamp-sdc-controller,clamp-ssl-config,clamp-policy-controller,legacy-operational-policy,default-dictionary-elements
+spring.profiles.active=clamp-default,clamp-default-user,clamp-sdc-controller,clamp-ssl-config,clamp-policy-controller,default-dictionary-elements
spring.http.converters.preferred-json-mapper=gson
#The max number of active threads in this pool
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 4ab551ea3..de32098fa 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -74,7 +74,7 @@ server.ssl.trust-store-password=enc:iDnPBBLq_EMidXlMa1FEuBR8TZzYxrCg66vq_XfLHdJ
server.servlet.context-path=/
#Modified engine-rest applicationpath
-spring.profiles.active=clamp-default,clamp-aaf-authentication,clamp-sdc-controller,clamp-ssl-config,clamp-policy-controller,legacy-operational-policy,default-dictionary-elements
+spring.profiles.active=clamp-default,clamp-aaf-authentication,clamp-sdc-controller,clamp-ssl-config,clamp-policy-controller,default-dictionary-elements
spring.http.converters.preferred-json-mapper=gson
#The max number of active threads in this pool
diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
index 86bc8c07e..aa8054c47 100644
--- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
@@ -35,7 +35,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.transaction.Transactional;
-
import org.apache.commons.lang3.RandomStringUtils;
import org.json.JSONException;
import org.junit.Assert;
@@ -43,7 +42,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.clamp.clds.Application;
-import org.onap.clamp.clds.config.LegacyOperationalPolicyController;
import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
@@ -75,7 +73,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
-@ActiveProfiles({"clamp-default", "clamp-default-user", "clamp-sdc-controller", "legacy-operational-policy"})
+@ActiveProfiles({"clamp-default", "clamp-default-user", "clamp-sdc-controller"})
public class CsarInstallerItCase {
private static final String CSAR_ARTIFACT_NAME_CDS = "example/sdc/service_Vloadbalancerms_cds.csar";
@@ -166,13 +164,6 @@ public class CsarInstallerItCase {
@Test
@Transactional
- public void testPolicyModelAddedAtStartup() {
- assertThat(policyModelsRepository.findByPolicyModelType(
- LegacyOperationalPolicyController.OPERATIONAL_POLICY_LEGACY).get(0)).isNotNull();
- }
-
- @Test
- @Transactional
public void testGetPolicyModelYaml() throws IOException, SdcToscaParserException, CsarHandlerException {
INotificationData notificationData = Mockito.mock(INotificationData.class);
IArtifactInfo serviceArtifacts = Mockito.mock(IArtifactInfo.class);
diff --git a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
index 6a646e3e1..4d2bfe280 100644
--- a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
+++ b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
@@ -23,7 +23,6 @@
package org.onap.clamp.loop;
-import static org.assertj.core.api.Assertions.assertThat;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.io.IOException;
@@ -31,7 +30,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.clamp.clds.config.LegacyOperationalPolicyController;
import org.onap.clamp.clds.util.ResourceFileUtils;
import org.onap.clamp.loop.components.external.ExternalComponentState;
import org.onap.clamp.loop.components.external.PolicyComponent;
@@ -40,6 +38,8 @@ import org.onap.clamp.loop.template.PolicyModel;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class PolicyComponentTest {
/**
@@ -267,7 +267,7 @@ public class PolicyComponentTest {
new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null, "pdpGroup2", "pdpSubgroup1");
loopTest.addMicroServicePolicy(microServicePolicy2);
- PolicyModel policyModel2 = new PolicyModel(LegacyOperationalPolicyController.OPERATIONAL_POLICY_LEGACY, null,
+ PolicyModel policyModel2 = new PolicyModel("onap.policies.monitoring.test2", null,
"1.0.0");
OperationalPolicy opPolicy =
new OperationalPolicy("opPolicy", new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class),
diff --git a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
deleted file mode 100644
index 36f000720..000000000
--- a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 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.clamp.policy.microservice;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.clamp.clds.util.ResourceFileUtils;
-import org.onap.clamp.loop.template.PolicyModel;
-import org.onap.clamp.policy.operational.LegacyOperationalPolicy;
-import org.onap.clamp.policy.operational.OperationalPolicy;
-
-public class OperationalPolicyPayloadTest {
-
- @Test
- public void testOperationalPolicyLegacyPayloadConstruction() throws IOException {
- JsonObject jsonConfig = new GsonBuilder().create().fromJson(
- ResourceFileUtils.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class);
- OperationalPolicy policy = new OperationalPolicy("testPolicy.legacy", jsonConfig, null,
- new PolicyModel("onap.policies.controlloop.Operational.legacy", "", "1.0.0", "test"), null, null, null);
-
- assertThat(policy.createPolicyPayloadYaml())
- .isEqualTo(ResourceFileUtils.getResourceAsString("tosca/operational-policy-payload.yaml"));
-
- assertThat(policy.createPolicyPayload())
- .isEqualTo(ResourceFileUtils.getResourceAsString("tosca/operational-policy-payload.json"));
- }
-
- @Test
- public void testLegacyOperationalPolicyPayloadConstruction() throws IOException {
- JsonObject jsonConfig = new GsonBuilder().create().fromJson(
- ResourceFileUtils.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class);
- assertThat(LegacyOperationalPolicy.createPolicyPayloadYamlLegacy(jsonConfig.get("operational_policy")))
- .isEqualTo(ResourceFileUtils.getResourceAsString("tosca/operational-policy-payload-legacy.yaml"));
- }
-}
diff --git a/src/test/resources/tosca/operational-policy-payload-legacy.yaml b/src/test/resources/tosca/operational-policy-payload-legacy.yaml
deleted file mode 100644
index 1108ec8b9..000000000
--- a/src/test/resources/tosca/operational-policy-payload-legacy.yaml
+++ /dev/null
@@ -1,90 +0,0 @@
-controlLoop:
- abatement: true
- controlLoopName: LOOP_ASJOy_v1_0_ResourceInstanceName1_tca
- timeout: 0
- trigger_policy: policy1
-policies:
-- actor: APPC
- failure: policy2
- failure_exception: final_failure_exception
- failure_guard: final_failure_guard
- failure_retries: final_failure_retries
- failure_timeout: final_failure_timeout
- id: policy1
- payload:
- configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[10].value","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[15].value","enabled":"$.vf-module-topology.vf-module-parameters.param[22].value"}]'
- requestParameters: '{"usePreload":true,"userParams":[]}'
- recipe: Restart
- retry: 0
- success: final_success
- target:
- resourceID: vLoadBalancerMS
- type: VNF
- timeout: 0
-- actor: SO
- failure: final_failure
- failure_exception: final_failure_exception
- failure_guard: final_failure_guard
- failure_retries: final_failure_retries
- failure_timeout: final_failure_timeout
- id: policy2
- recipe: VF Module Create
- retry: 0
- success: final_success
- target:
- modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52
- modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043
- modelName: Vloadbalancerms..vpkg..module-1
- modelVersion: 1
- modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc
- resourceID: Vloadbalancerms..vpkg..module-1
- type: VFMODULE
- timeout: 0
-- actor: CDS
- failure: final_failure
- failure_exception: final_failure_exception
- failure_guard: final_failure_guard
- failure_retries: final_failure_retries
- failure_timeout: final_failure_timeout
- id: policy3
- payload:
- artifact_name: baseconfiguration
- artifact_version: 1.0.0
- data: '{"resource-assignment-properties":{"request-id":"request-id","service-instance-id":"service-instance-id","vnf-id":"vnf-id","action-name":"action-name","scope-type":"scope-type","hostname":"hostname","vnf_name":"vnf_name"}}'
- mode: async
- recipe: resource-assignment
- retry: 0
- success: final_success
- target:
- modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52
- modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043
- modelName: Vloadbalancerms..vpkg..module-1
- modelVersion: 1
- modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc
- resourceID: Vloadbalancerms..vpkg..module-1
- type: VFMODULE
- timeout: 0
-- actor: CDS
- failure: final_failure
- failure_exception: final_failure_exception
- failure_guard: final_failure_guard
- failure_retries: final_failure_retries
- failure_timeout: final_failure_timeout
- id: policy4
- payload:
- artifact_name: baseconfiguration
- artifact_version: 1.0.0
- data: '{}'
- mode: async
- recipe: modify-config
- retry: 0
- success: final_success
- target:
- modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52
- modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043
- modelName: Vloadbalancerms..vpkg..module-1
- modelVersion: 1
- modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc
- resourceID: Vloadbalancerms..vpkg..module-1
- type: VFMODULE
- timeout: 0
diff --git a/src/test/resources/tosca/operational-policy-payload.json b/src/test/resources/tosca/operational-policy-payload.json
deleted file mode 100644
index 0bb5582eb..000000000
--- a/src/test/resources/tosca/operational-policy-payload.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "policy-id": "testPolicy.legacy",
- "content": "controlLoop%3A%0A++abatement%3A+true%0A++controlLoopName%3A+LOOP_ASJOy_v1_0_ResourceInstanceName1_tca%0A++timeout%3A+0%0A++trigger_policy%3A+policy1%0Apolicies%3A%0A-+actor%3A+APPC%0A++failure%3A+policy2%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy1%0A++payload%3A%0A++++configurationParameters%3A+%27%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B10%5D.value%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B15%5D.value%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B22%5D.value%22%7D%5D%27%0A++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D%27%0A++recipe%3A+Restart%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++resourceID%3A+vLoadBalancerMS%0A++++type%3A+VNF%0A++timeout%3A+0%0A-+actor%3A+SO%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy2%0A++recipe%3A+VF+Module+Create%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A-+actor%3A+CDS%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy3%0A++payload%3A%0A++++artifact_name%3A+baseconfiguration%0A++++artifact_version%3A+1.0.0%0A++++data%3A+%27%7B%22resource-assignment-properties%22%3A%7B%22request-id%22%3A%22request-id%22%2C%22service-instance-id%22%3A%22service-instance-id%22%2C%22vnf-id%22%3A%22vnf-id%22%2C%22action-name%22%3A%22action-name%22%2C%22scope-type%22%3A%22scope-type%22%2C%22hostname%22%3A%22hostname%22%2C%22vnf_name%22%3A%22vnf_name%22%7D%7D%27%0A++++mode%3A+async%0A++recipe%3A+resource-assignment%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A-+actor%3A+CDS%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy4%0A++payload%3A%0A++++artifact_name%3A+baseconfiguration%0A++++artifact_version%3A+1.0.0%0A++++data%3A+%27%7B%7D%27%0A++++mode%3A+async%0A++recipe%3A+modify-config%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A"
-} \ No newline at end of file
diff --git a/src/test/resources/tosca/operational-policy-payload.yaml b/src/test/resources/tosca/operational-policy-payload.yaml
deleted file mode 100644
index a756b57d6..000000000
--- a/src/test/resources/tosca/operational-policy-payload.yaml
+++ /dev/null
@@ -1,100 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-topology_template:
- policies:
- - testPolicy.legacy:
- type: onap.policies.controlloop.Operational
- version: 1.0.0
- metadata:
- policy-id: testPolicy.legacy
- properties:
- controlLoop:
- timeout: '0'
- abatement: 'True'
- trigger_policy: policy1
- controlLoopName: LOOP_ASJOy_v1_0_ResourceInstanceName1_tca
- policies:
- - id: policy1
- retry: '0'
- timeout: '0'
- success: final_success
- failure: policy2
- failure_timeout: final_failure_timeout
- failure_retries: final_failure_retries
- failure_exception: final_failure_exception
- failure_guard: final_failure_guard
- target:
- type: VNF
- resourceID: vLoadBalancerMS
- actor: APPC
- recipe: Restart
- payload:
- requestParameters: '{"usePreload":true,"userParams":[]}'
- configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[10].value","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[15].value","enabled":"$.vf-module-topology.vf-module-parameters.param[22].value"}]'
- - id: policy2
- retry: '0'
- timeout: '0'
- success: final_success
- failure: final_failure
- failure_timeout: final_failure_timeout
- failure_retries: final_failure_retries
- failure_exception: final_failure_exception
- failure_guard: final_failure_guard
- target:
- type: VFMODULE
- resourceID: Vloadbalancerms..vpkg..module-1
- modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043
- modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc
- modelName: Vloadbalancerms..vpkg..module-1
- modelVersion: '1'
- modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52
- actor: SO
- recipe: VF Module Create
- payload: ''
- - id: policy3
- retry: '0'
- timeout: '0'
- success: final_success
- failure: final_failure
- failure_timeout: final_failure_timeout
- failure_retries: final_failure_retries
- failure_exception: final_failure_exception
- failure_guard: final_failure_guard
- target:
- type: VFMODULE
- resourceID: Vloadbalancerms..vpkg..module-1
- modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043
- modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc
- modelName: Vloadbalancerms..vpkg..module-1
- modelVersion: '1'
- modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52
- actor: CDS
- recipe: resource-assignment
- payload:
- artifact_name: baseconfiguration
- artifact_version: 1.0.0
- mode: async
- data: '{"resource-assignment-properties":{"request-id":"request-id","service-instance-id":"service-instance-id","vnf-id":"vnf-id","action-name":"action-name","scope-type":"scope-type","hostname":"hostname","vnf_name":"vnf_name"}}'
- - id: policy4
- retry: '0'
- timeout: '0'
- success: final_success
- failure: final_failure
- failure_timeout: final_failure_timeout
- failure_retries: final_failure_retries
- failure_exception: final_failure_exception
- failure_guard: final_failure_guard
- target:
- type: VFMODULE
- resourceID: Vloadbalancerms..vpkg..module-1
- modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043
- modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc
- modelName: Vloadbalancerms..vpkg..module-1
- modelVersion: '1'
- modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52
- actor: CDS
- recipe: modify-config
- payload:
- artifact_name: baseconfiguration
- artifact_version: 1.0.0
- mode: async
- data: '{}'