Unit/SONAR/Checkstyle in ONAP-REST 12/98512/3
authorliamfallon <liam.fallon@est.tech>
Mon, 18 Nov 2019 12:36:28 +0000 (12:36 +0000)
committerliamfallon <liam.fallon@est.tech>
Mon, 18 Nov 2019 15:27:15 +0000 (15:27 +0000)
Util package of ONAP-REST, with JUnit added and
SONAR/Checkstyle issues addressed. In cases where a class name change
caused an update in another package, the license header on files for
those knock on changes are not updated.

Issue-ID: POLICY-2131

Change-Id: Ic134408efe76b9838f5607a07f1735d12bd41032
Signed-off-by: liamfallon <liam.fallon@est.tech>
28 files changed:
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewOptimizationModel.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryController.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/model/RemoveGroupPolicy.java
ONAP-REST/src/main/java/org/onap/policy/rest/util/LockdownListener.java
ONAP-REST/src/main/java/org/onap/policy/rest/util/MsAttributeObject.java [moved from ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java with 56% similarity]
ONAP-REST/src/main/java/org/onap/policy/rest/util/MsAttributeValue.java [moved from ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeValue.java with 59% similarity]
ONAP-REST/src/main/java/org/onap/policy/rest/util/MsModelUtils.java [moved from ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java with 72% similarity]
ONAP-REST/src/main/java/org/onap/policy/rest/util/ParserException.java
ONAP-REST/src/main/java/org/onap/policy/rest/util/PdpPolicyContainer.java [moved from ONAP-REST/src/main/java/org/onap/policy/rest/util/PDPPolicyContainer.java with 66% similarity]
ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyContainer.java
ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifier.java
ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
ONAP-REST/src/test/java/org/onap/policy/rest/XacmlRestTest.java
ONAP-REST/src/test/java/org/onap/policy/rest/jpa/GetterSetterToStringTest.java [moved from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ModelsTest.java with 98% similarity]
ONAP-REST/src/test/java/org/onap/policy/rest/util/DummyPolicyContainer.java [new file with mode: 0644]
ONAP-REST/src/test/java/org/onap/policy/rest/util/MsAttributeObjectTest.java [moved from ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java with 90% similarity]
ONAP-REST/src/test/java/org/onap/policy/rest/util/MsModelUtilsTest.java [moved from ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java with 82% similarity]
ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java [deleted file]
ONAP-REST/src/test/java/org/onap/policy/rest/util/ParserExceptionTest.java [new file with mode: 0644]
ONAP-REST/src/test/java/org/onap/policy/rest/util/PdpPolicyContainerTest.java [new file with mode: 0644]
ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java
ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateOptimizationController.java

index ea5e8aa..e18628d 100644 (file)
@@ -49,16 +49,16 @@ import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
 import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
 import org.onap.policy.rest.jpa.MicroServiceModels;
 import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
-import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
+import org.onap.policy.rest.util.MsModelUtils.ModelType;
 
 public class CreateNewMicroServiceModel {
     private static final Logger logger = FlexLogger.getLogger(CreateNewMicroServiceModel.class);
     private MicroServiceModels newModel = null;
-    private HashMap<String, MSAttributeObject> classMap = new HashMap<>();
+    private HashMap<String, MsAttributeObject> classMap = new HashMap<>();
 
-    private MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
+    private MsModelUtils utils = new MsModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
 
     public CreateNewMicroServiceModel(String fileName, String serviceName, String string, String version) {
         super();
@@ -84,7 +84,7 @@ public class CreateNewMicroServiceModel {
         this.newModel.setUserCreatedBy(userInfo);
         String cleanUpFile = null;
 
-        Map<String, MSAttributeObject> tempMap = new HashMap<>();
+        Map<String, MsAttributeObject> tempMap = new HashMap<>();
         // Need to delete the file
         if (importFile.contains(".zip")) {
             extractFolder(randomID + ".zip");
@@ -100,7 +100,7 @@ public class CreateNewMicroServiceModel {
                 cleanUpFile = "ExtractDir" + File.separator + randomID + ".yml";
 
             } else {
-                tempMap = utils.processEpackage("ExtractDir" + File.separator + randomID + ".xmi", MODEL_TYPE.XMI);
+                tempMap = utils.processEpackage("ExtractDir" + File.separator + randomID + ".xmi", ModelType.XMI);
                 classMap.putAll(tempMap);
                 cleanUpFile = "ExtractDir" + File.separator + randomID + ".xmi";
             }
@@ -111,7 +111,7 @@ public class CreateNewMicroServiceModel {
     }
 
     private void processFiles(String modelName, List<File> fileList) {
-        Map<String, MSAttributeObject> tempMap;
+        Map<String, MsAttributeObject> tempMap;
         for (File file : fileList) {
             if (file.isFile()) {
                 int indx = file.getName().lastIndexOf('.');
@@ -123,7 +123,7 @@ public class CreateNewMicroServiceModel {
 
                 } else {
 
-                    tempMap = utils.processEpackage(file.getAbsolutePath(), MODEL_TYPE.XMI);
+                    tempMap = utils.processEpackage(file.getAbsolutePath(), ModelType.XMI);
                     classMap.putAll(tempMap);
                 }
             }
@@ -149,7 +149,7 @@ public class CreateNewMicroServiceModel {
 
             utils.parseTosca(fileName);
 
-            MSAttributeObject msAttributes = new MSAttributeObject();
+            MsAttributeObject msAttributes = new MsAttributeObject();
             msAttributes.setClassName(modelName);
 
             LinkedHashMap<String, String> returnAttributeList = new LinkedHashMap<>();
@@ -256,7 +256,7 @@ public class CreateNewMicroServiceModel {
     public Map<String, String> addValuesToNewModel(String type) {
 
         Map<String, String> successMap = new HashMap<>();
-        MSAttributeObject mainClass = null;
+        MsAttributeObject mainClass = null;
         List<String> dependency = null;
         String subAttribute = null;
 
@@ -317,7 +317,7 @@ public class CreateNewMicroServiceModel {
                 dependency = utils.getFullDependencyList(dependency, classMap);
                 if (!dependency.isEmpty()) {
                     for (String element : dependency) {
-                        MSAttributeObject temp = new MSAttributeObject();
+                        MsAttributeObject temp = new MsAttributeObject();
                         if (classMap.containsKey(element)) {
                             temp = classMap.get(element);
                             mainClass.addAllRefAttribute(temp.getRefAttribute());
index 0f52b9b..8c63a27 100644 (file)
@@ -45,19 +45,19 @@ import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
 import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
 import org.onap.policy.rest.jpa.OptimizationModels;
 import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
-import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
+import org.onap.policy.rest.util.MsModelUtils.ModelType;
 
 public class CreateNewOptimizationModel {
     private static final Logger logger = FlexLogger.getLogger(CreateNewOptimizationModel.class);
     private OptimizationModels newModel = null;
-    private HashMap<String, MSAttributeObject> classMap = new HashMap<>();
+    private HashMap<String, MsAttributeObject> classMap = new HashMap<>();
 
     private static final String EXTRACTDIR = "ExtractDir";
     private static final String SUCCESS = "success";
 
-    MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
+    MsModelUtils utils = new MsModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
 
     public CreateNewOptimizationModel() {
         super();
@@ -75,7 +75,7 @@ public class CreateNewOptimizationModel {
         this.newModel.setUserCreatedBy(userInfo);
         String cleanUpFile = null;
 
-        Map<String, MSAttributeObject> tempMap = new HashMap<>();
+        Map<String, MsAttributeObject> tempMap = new HashMap<>();
         // Need to delete the file
         if (importFile.contains(".zip")) {
             extractFolder(randomID + ".zip");
@@ -103,7 +103,7 @@ public class CreateNewOptimizationModel {
                 cleanUpFile = EXTRACTDIR + File.separator + randomID + ".yml";
 
             } else {
-                tempMap = utils.processEpackage(EXTRACTDIR + File.separator + randomID + ".xmi", MODEL_TYPE.XMI);
+                tempMap = utils.processEpackage(EXTRACTDIR + File.separator + randomID + ".xmi", ModelType.XMI);
                 classMap.putAll(tempMap);
                 cleanUpFile = EXTRACTDIR + File.separator + randomID + ".xmi";
             }
@@ -118,7 +118,7 @@ public class CreateNewOptimizationModel {
 
             utils.parseTosca(fileName);
 
-            MSAttributeObject msAttributes = new MSAttributeObject();
+            MsAttributeObject msAttributes = new MsAttributeObject();
             msAttributes.setClassName(modelName);
 
             LinkedHashMap<String, String> returnAttributeList = new LinkedHashMap<>();
@@ -216,7 +216,7 @@ public class CreateNewOptimizationModel {
     public Map<String, String> addValuesToNewModel() {
 
         Map<String, String> successMap = new HashMap<>();
-        MSAttributeObject mainClass;
+        MsAttributeObject mainClass;
 
         if (!classMap.containsKey(this.newModel.getModelName())) {
             logger.error(
index b9e1ce1..566ac14 100644 (file)
@@ -54,8 +54,8 @@ import org.onap.policy.rest.jpa.MicroServiceModels;
 import org.onap.policy.rest.jpa.MicroserviceHeaderdeFaults;
 import org.onap.policy.rest.jpa.PrefixList;
 import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Controller;
@@ -75,7 +75,7 @@ public class MicroServiceDictionaryController {
     private static String getDictionary = "getDictionary";
     private static String errorMsg = "error";
     private static String dictionaryDBQuery = "dictionaryDBQuery";
-    private LinkedHashMap<String, MSAttributeObject> classMap;
+    private LinkedHashMap<String, MsAttributeObject> classMap;
     private List<String> modelList = new ArrayList<>();
     private static String dictionaryFields = "dictionaryFields";
     private static String duplicateResponseString = "Duplicate";
@@ -109,7 +109,7 @@ public class MicroServiceDictionaryController {
         MicroServiceDictionaryController.commonClassDao = commonClassDao;
     }
 
-    MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
+    MsModelUtils utils = new MsModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
 
     private MicroServiceModels newModel;
 
@@ -650,12 +650,12 @@ public class MicroServiceDictionaryController {
                     Set<String> keys = jsonObject.keySet();
                     for (String key : keys) {
                         String value = jsonObject.get(key).toString();
-                        MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
+                        MsAttributeObject msAttributeObject = mapper1.readValue(value, MsAttributeObject.class);
                         classMap.put(key, msAttributeObject);
                     }
 
                     userId = root.get("userid").textValue();
-                    MSAttributeObject mainClass = classMap.get(this.newModel.getModelName());
+                    MsAttributeObject mainClass = classMap.get(this.newModel.getModelName());
                     this.newModel.setDependency("[]");
                     String value = new Gson().toJson(mainClass.getSubClass());
                     this.newModel.setSubAttributes(value);
@@ -703,7 +703,7 @@ public class MicroServiceDictionaryController {
                             Set<String> keys = jsonObject.keySet();
                             for (String key : keys) {
                                 String value = jsonObject.get(key).toString();
-                                MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
+                                MsAttributeObject msAttributeObject = mapper1.readValue(value, MsAttributeObject.class);
                                 classMap.put(key, msAttributeObject);
                             }
                         }
@@ -769,11 +769,11 @@ public class MicroServiceDictionaryController {
         utils.removeData(request, response, microServiceModelsDictionaryDatas, MicroServiceModels.class);
     }
 
-    private void addValuesToNewModel(HashMap<String, MSAttributeObject> classMap) {
+    private void addValuesToNewModel(HashMap<String, MsAttributeObject> classMap) {
         // Loop through the classmap and pull out the required info for the new file.
         String subAttribute = null;
 
-        MSAttributeObject mainClass = classMap.get(this.newModel.getModelName());
+        MsAttributeObject mainClass = classMap.get(this.newModel.getModelName());
 
         if (mainClass != null) {
             String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "},
@@ -781,7 +781,7 @@ public class MicroServiceDictionaryController {
             ArrayList<String> dependency = new ArrayList<>(Arrays.asList(dependTemp.split(",")));
             dependency = getFullDependencyList(dependency);
             for (String element : dependency) {
-                MSAttributeObject temp = classMap.get(element);
+                MsAttributeObject temp = classMap.get(element);
                 if (temp != null) {
                     mainClass.addAllRefAttribute(temp.getRefAttribute());
                     mainClass.addAllAttribute(temp.getAttribute());
@@ -812,7 +812,7 @@ public class MicroServiceDictionaryController {
         returnList.addAll(dependency);
         for (String element : dependency) {
             if (classMap.containsKey(element)) {
-                MSAttributeObject value = classMap.get(element);
+                MsAttributeObject value = classMap.get(element);
                 String rawValue =
                         StringUtils.replaceEach(value.getDependency(), new String[] {"[", "]"}, new String[] {"", ""});
                 workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));
index 52394ba..a24ee02 100644 (file)
@@ -43,8 +43,8 @@ import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
 import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.OptimizationModels;
 import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Controller;
@@ -57,7 +57,7 @@ public class OptimizationDictionaryController {
     private static CommonClassDao commonClassDao;
 
     private static String operation = "operation";
-    private LinkedHashMap<String, MSAttributeObject> classMap;
+    private LinkedHashMap<String, MsAttributeObject> classMap;
     private static String dictionaryFields = "dictionaryFields";
     private static String duplicateResponseString = "Duplicate";
     private static String optimizationModelsDictionaryDatas = "optimizationModelsDictionaryDatas";
@@ -85,7 +85,7 @@ public class OptimizationDictionaryController {
         OptimizationDictionaryController.commonClassDao = commonClassDao;
     }
 
-    MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
+    MsModelUtils utils = new MsModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
 
     private OptimizationModels newModel;
 
@@ -157,12 +157,12 @@ public class OptimizationDictionaryController {
                     Set<String> keys = jsonObject.keySet();
                     for (String key : keys) {
                         String value = jsonObject.get(key).toString();
-                        MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
+                        MsAttributeObject msAttributeObject = mapper1.readValue(value, MsAttributeObject.class);
                         classMap.put(key, msAttributeObject);
                     }
 
                     userId = root.get("userid").textValue();
-                    MSAttributeObject mainClass = classMap.get(this.newModel.getModelName());
+                    MsAttributeObject mainClass = classMap.get(this.newModel.getModelName());
                     this.newModel.setDependency("[]");
                     String value = new Gson().toJson(mainClass.getSubClass());
                     this.newModel.setSubattributes(value);
@@ -212,7 +212,7 @@ public class OptimizationDictionaryController {
                             Set<String> keys = jsonObject.keySet();
                             for (String key : keys) {
                                 String value = jsonObject.get(key).toString();
-                                MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
+                                MsAttributeObject msAttributeObject = mapper1.readValue(value, MsAttributeObject.class);
                                 classMap.put(key, msAttributeObject);
                             }
                         }
@@ -279,11 +279,11 @@ public class OptimizationDictionaryController {
         dUtils.removeData(request, response, optimizationModelsDictionaryDatas, OptimizationModels.class);
     }
 
-    private void addValuesToNewModel(HashMap<String, MSAttributeObject> classMap) {
+    private void addValuesToNewModel(HashMap<String, MsAttributeObject> classMap) {
         // Loop through the classmap and pull out the required info for the new file.
         String subAttribute = null;
 
-        MSAttributeObject mainClass = classMap.get(this.newModel.getModelName());
+        MsAttributeObject mainClass = classMap.get(this.newModel.getModelName());
 
         if (mainClass != null) {
             String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "},
@@ -291,7 +291,7 @@ public class OptimizationDictionaryController {
             ArrayList<String> dependency = new ArrayList<>(Arrays.asList(dependTemp.split(",")));
             dependency = getFullDependencyList(dependency);
             for (String element : dependency) {
-                MSAttributeObject temp = classMap.get(element);
+                MsAttributeObject temp = classMap.get(element);
                 if (temp != null) {
                     mainClass.addAllRefAttribute(temp.getRefAttribute());
                     mainClass.addAllAttribute(temp.getAttribute());
@@ -322,7 +322,7 @@ public class OptimizationDictionaryController {
         returnList.addAll(dependency);
         for (String element : dependency) {
             if (classMap.containsKey(element)) {
-                MSAttributeObject value = classMap.get(element);
+                MsAttributeObject value = classMap.get(element);
                 String rawValue =
                         StringUtils.replaceEach(value.getDependency(), new String[] {"[", "]"}, new String[] {"", ""});
                 workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));
index b83db1f..908353b 100644 (file)
@@ -26,14 +26,14 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.onap.policy.rest.util.PDPPolicyContainer;
+import org.onap.policy.rest.util.PdpPolicyContainer;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
 import org.onap.policy.xacml.std.pap.StdPDPGroup;
 
 public class RemoveGroupPolicy {
 
     // Container from where we are fetching the policies
-    private static PDPPolicyContainer policyContainer;
+    private static PdpPolicyContainer policyContainer;
 
     private StdPDPGroup updatedObject;
     private final StdPDPGroup group;
@@ -57,7 +57,7 @@ public class RemoveGroupPolicy {
         if (this.group == null) {
             return;
         }
-        setRemoveGroupPolicy(new PDPPolicyContainer(group));
+        setRemoveGroupPolicy(new PdpPolicyContainer(group));
     }
 
     /**
@@ -71,7 +71,7 @@ public class RemoveGroupPolicy {
         this.isSaved = true;
     }
 
-    private static void setRemoveGroupPolicy(PDPPolicyContainer pdpPolicyContainer) {
+    private static void setRemoveGroupPolicy(PdpPolicyContainer pdpPolicyContainer) {
         RemoveGroupPolicy.policyContainer = pdpPolicyContainer;
     }
 
index 1111609..019e15d 100644 (file)
@@ -3,13 +3,14 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
  * ============LICENSE_END=========================================================
  */
 
-/**
- * 
- */
 package org.onap.policy.rest.util;
 
 public interface LockdownListener {
     /**
-     * lockdown has been set in database
+     * lockdown has been set in database.
      */
     public void lockdownSet();
 
     /**
-     * lockdown has been unset in the database
+     * lockdown has been unset in the database.
      */
     public void lockdownUnset();
 }
@@ -3,6 +3,7 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2017,2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +24,12 @@ package org.onap.policy.rest.util;
 import java.util.HashMap;
 import java.util.Map;
 
-public class MSAttributeObject {
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class MsAttributeObject {
 
     private String className;
     private Map<String, String> attribute = new HashMap<>();
@@ -36,38 +42,6 @@ public class MSAttributeObject {
     private String ruleFormation;
     private String dataOrderInfo;
 
-    public Map<String, String> getRefAttribute() {
-        return refAttribute;
-    }
-
-    public void setRefAttribute(Map<String, String> refAttribute) {
-        this.refAttribute = refAttribute;
-    }
-
-    public String getClassName() {
-        return className;
-    }
-
-    public void setClassName(String className) {
-        this.className = className;
-    }
-
-    public Map<String, String> getAttribute() {
-        return attribute;
-    }
-
-    public void setAttribute(Map<String, String> attribute) {
-        this.attribute = attribute;
-    }
-
-    public Map<String, String> getEnumType() {
-        return enumType;
-    }
-
-    public void setEnumType(Map<String, String> enumType) {
-        this.enumType = enumType;
-    }
-
     public void addAttribute(String key, String value) {
         this.attribute.put(key, value);
     }
@@ -84,38 +58,14 @@ public class MSAttributeObject {
         this.refAttribute.putAll(map);
     }
 
-    public Map<String, Object> getSubClass() {
-        return subClass;
-    }
-
-    public void setSubClass(Map<String, Object> subClass) {
-        this.subClass = subClass;
-    }
-
     public void addAllSubClass(Map<String, Object> subClass) {
         this.subClass.putAll(subClass);
     }
 
-    public String getDependency() {
-        return dependency;
-    }
-
-    public void setDependency(String dependency) {
-        this.dependency = dependency;
-    }
-
     public void addSingleEnum(String key, String value) {
         this.enumType.put(key, value);
     }
 
-    public Map<String, String> getMatchingSet() {
-        return matchingSet;
-    }
-
-    public void setMatchingSet(Map<String, String> matchingSet) {
-        this.matchingSet = matchingSet;
-    }
-
     public void addMatchingSet(String key, String value) {
         this.matchingSet.put(key, value);
     }
@@ -123,28 +73,4 @@ public class MSAttributeObject {
     public void addMatchingSet(Map<String, String> matchingSet) {
         this.matchingSet.putAll(matchingSet);
     }
-
-    public boolean isPolicyTempalate() {
-        return policyTempalate;
-    }
-
-    public void setPolicyTempalate(boolean policyTempalate) {
-        this.policyTempalate = policyTempalate;
-    }
-
-    public String getRuleFormation() {
-        return ruleFormation;
-    }
-
-    public void setRuleFormation(String ruleFormation) {
-        this.ruleFormation = ruleFormation;
-    }
-
-    public String getDataOrderInfo() {
-        return dataOrderInfo;
-    }
-
-    public void setDataOrderInfo(String dataOrderInfo) {
-        this.dataOrderInfo = dataOrderInfo;
-    }
 }
@@ -3,13 +3,14 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
 
 package org.onap.policy.rest.util;
 
-public class MSAttributeValue{
-    public String getName() {
-        return name;
-    }
-    public void setName(String name) {
-        this.name = name;
-    }
-    public String getType() {
-        return type;
-    }
-    public void setType(String type) {
-        this.type = type;
-    }
-    public Boolean getRequired() {
-        return required;
-    }
-    public void setRequired(Boolean required) {
-        this.required = required;
-    }
-    public Boolean getArrayValue() {
-        return arrayValue;
-    }
-    public void setArrayValue(Boolean arrayValue) {
-        this.arrayValue = arrayValue;
-    }
-    public String getDefaultValue() {
-        return defaultValue;
-    }
-    public void setDefaultValue(String defaultValue) {
-        this.defaultValue = defaultValue;
-    }
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class MsAttributeValue {
     private String name;
     private String type;
     private Boolean required;
     private Boolean arrayValue;
     private String defaultValue;
-
 }
@@ -24,6 +24,7 @@ package org.onap.policy.rest.util;
 
 import com.att.research.xacml.util.XACMLProperties;
 import com.google.gson.Gson;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -40,6 +41,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+
+import lombok.Getter;
+import lombok.Setter;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -69,19 +74,54 @@ import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.DictionaryData;
 import org.yaml.snakeyaml.Yaml;
 
+@Getter
+@Setter
+public class MsModelUtils {
 
-public class MSModelUtils {
+    private static final Log logger = LogFactory.getLog(MsModelUtils.class);
+
+    // String constants
+    private static final String BOOLEAN = "boolean";
+    private static final String CONFIGURATION = "configuration";
+    private static final String DATATYPE = "data_types.policy.data.";
+    private static final String DATA_TYPE = "data_types";
+    private static final String DEFAULT = ".default";
+    private static final String DEFAULTVALUE = ":defaultValue-";
+    private static final String DESCRIPTION = ".description";
+    private static final String DESCRIPTION_KEY = "description";
+    private static final String DESCRIPTION_TOKEN = ":description-";
+    private static final String DICTIONARY = "dictionary:";
+    private static final String DICTIONARYNAME = "dictionaryName";
+    private static final String ERROR = "error";
+    private static final String E_PROXY_URI = "eProxyURI:";
+    private static final String INTEGER = "integer";
+    private static final String JSON_MODEL = "JSON_MODEL";
+    private static final String LIST = "list";
+    private static final String MANYFALSE = ":MANY-false";
+    private static final String MANYTRUE = ":MANY-true";
+    private static final String MAP = "map";
+    private static final String MATCHABLE = ".matchable";
+    private static final String MATCHABLEKEY = "matchable";
+    private static final String MATCHINGTRUE = "matching-true";
+    private static final String NODE_TYPE = "node_types";
+    private static final String PROPERTIES = ".properties.";
+    private static final String PROPERTIES_KEY = "properties";
+    private static final String REQUIRED = ".required";
+    private static final String REQUIREDFALSE = ":required-false";
+    private static final String REQUIREDTRUE = ":required-true";
+    private static final String REQUIREDVALUE = ":required-";
+    private static final String STRING = "string";
+    private static final String TOSCA_DEFINITION_VERSION = "tosca_definitions_version";
+    private static final String TOSCA_SIMPLE_YAML_1_0_0 = "tosca_simple_yaml_1_0_0";
+    private static final String TYPE = ".type";
 
-    private static final Log logger = LogFactory.getLog(MSModelUtils.class);
+    private static CommonClassDao commonClassDao;
 
-    private HashMap<String, MSAttributeObject> classMap = new HashMap<>();
+    private HashMap<String, MsAttributeObject> classMap = new HashMap<>();
     private HashMap<String, String> enumMap = new HashMap<>();
     private HashMap<String, String> matchingClass = new HashMap<>();
-    private String configuration = "configuration";
-    private String dictionary = "dictionary";
     private String onap = "";
     private String policy = "";
-    private String eProxyURI = "eProxyURI:";
     private List<String> orderedElements = new ArrayList<>();
     private String dataOrderInfo = "";
     private Set<String> uniqueDataKeys = new HashSet<>();
@@ -90,80 +130,87 @@ public class MSModelUtils {
     private String referenceAttributes;
     private LinkedHashMap<String, Object> retmap = new LinkedHashMap<>();
     private Map<String, String> matchableValues;
-    private static final String PROPERTIES = ".properties.";
-    private static final String DATATYPE = "data_types.policy.data.";
-    private static final String TYPE = ".type";
-    private static final String REQUIRED = ".required";
-    private static final String DICTIONARYNAME = "dictionaryName";
-    private static final String DICTIONARY = "dictionary:";
-    private static final String MATCHABLE = ".matchable";
-    public static final String STRING = "string";
-    public static final String INTEGER = "integer";
-    private static final String BOOLEAN = "boolean";
-    public static final String LIST = "list";
-    public static final String MAP = "map";
-    private static final String DEFAULT = ".default";
-    private static final String MANYFALSE = ":MANY-false";
-    private static final String DESCRIPTION = ".description";
-
-    private static final String MANYTRUE = ":MANY-true";
-    private static final String DEFAULTVALUE = ":defaultValue-";
-    private static final String REQUIREDVALUE = ":required-";
-    private static final String MATCHABLEKEY = "matchable";
-    private static final String REQUIREDFALSE = ":required-false";
-    private static final String REQUIREDTRUE = ":required-true";
-    private static final String MATCHINGTRUE = "matching-true";
-    private static final String DESCRIPTION_KEY = "description";
-    private static final String DESCRIPTION_TOKEN = ":description-";
-    private static final String PROPERTIES_KEY = "properties";
-    private static final String DATA_TYPE = "data_types";
-    private static final String ERROR = "error";
-    private static final String NODE_TYPE = "node_types";
-    private static final String TOSCA_DEFINITION_VERSION = "tosca_definitions_version";
-    private static final String TOSCA_SIMPLE_YAML_1_0_0 = "tosca_simple_yaml_1_0_0";
-    private static final String JSON_MODEL = "JSON_MODEL";
     private StringBuilder dataListBuffer = new StringBuilder();
     private List<String> dataConstraints = new ArrayList<>();
     private String attributeString = null;
     private boolean isDuplicatedAttributes = false;
     private String jsonRuleFormation = null;
 
-    private static CommonClassDao commonClassDao;
-
-    public MSModelUtils() {
-        // Default Constructor
+    /**
+     * The Enum AnnotationType.
+     */
+    private enum AnnotationType {
+        MATCHING,
+        VALIDATION,
+        DICTIONARY
     }
 
-    public MSModelUtils(CommonClassDao commonClassDao) {
-        MSModelUtils.commonClassDao = commonClassDao;
+    /**
+     * The Enum ModelType.
+     */
+    public enum ModelType {
+        XMI
     }
 
-    public MSModelUtils(String onap, String policy) {
-        this.onap = onap;
-        this.policy = policy;
+    /**
+     * The Enum SearchType.
+     */
+    public enum SearchType {
+        TOSCA_DEFINITION_VERSION,
+        TOSCA_SIMPLE_YAML_1_0_0,
+        NODE_TYPE,
+        DATA_TYPE,
+        JSON_MODEL
     }
 
-    private enum ANNOTATION_TYPE {
-        MATCHING, VALIDATION, DICTIONARY
-    };
+    /**
+     * Instantiates a new ms model utils.
+     */
+    public MsModelUtils() {
+        // Default Constructor
+    }
 
-    public enum MODEL_TYPE {
-        XMI
-    };
+    /**
+     * Instantiates a new ms model utils.
+     *
+     * @param commonClassDao the common class dao
+     */
+    public MsModelUtils(CommonClassDao commonClassDao) {
+        MsModelUtils.commonClassDao = commonClassDao;
+    }
 
-    public enum SearchType {
-        TOSCA_DEFINITION_VERSION, TOSCA_SIMPLE_YAML_1_0_0, NODE_TYPE, DATA_TYPE, JSON_MODEL
+    /**
+     * Instantiates a new ms model utils.
+     *
+     * @param onap the onap
+     * @param policy the policy
+     */
+    public MsModelUtils(String onap, String policy) {
+        this.onap = onap;
+        this.policy = policy;
     }
 
-    public Map<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model) {
-        if (model == MODEL_TYPE.XMI) {
-            processXMIEpackage(file);
+    /**
+     * Process epackage.
+     *
+     * @param file the file
+     * @param model the model
+     * @return the map
+     */
+    public Map<String, MsAttributeObject> processEpackage(String file, ModelType model) {
+        if (model == ModelType.XMI) {
+            processXmiEpackage(file);
         }
         return classMap;
 
     }
 
-    private void processXMIEpackage(String xmiFile) {
+    /**
+     * Process XMI epackage.
+     *
+     * @param xmiFile the xmi file
+     */
+    private void processXmiEpackage(String xmiFile) {
         EPackage root = getEpackage(xmiFile);
         TreeIterator<EObject> treeItr = root.eAllContents();
         String className;
@@ -173,14 +220,16 @@ public class MSModelUtils {
         while (treeItr.hasNext()) {
             EObject obj = treeItr.next();
             if (obj instanceof EClassifier) {
-                EClassifier eClassifier = (EClassifier) obj;
-                className = eClassifier.getName();
+                EClassifier eclassifier = (EClassifier) obj;
+                className = eclassifier.getName();
 
                 if (obj instanceof EEnum) {
                     enumMap.putAll(getEEnum(obj));
                 } else if (obj instanceof EClass) {
-                    String temp = getDependencyList(eClassifier).toString();
-                    returnValue = StringUtils.replaceEach(temp, new String[] {"[", "]"}, new String[] {"", ""});
+                    String temp = getDependencyList(eclassifier).toString();
+                    returnValue = StringUtils.replaceEach(temp, new String[]
+                        { "[", "]" }, new String[]
+                        { "", "" });
                     getAttributes(className, returnValue, root);
                 }
             }
@@ -194,6 +243,9 @@ public class MSModelUtils {
         }
     }
 
+    /**
+     * Check for matching class.
+     */
     private void checkForMatchingClass() {
         HashMap<String, String> tempAttribute = new HashMap<>();
 
@@ -202,12 +254,12 @@ public class MSModelUtils {
             if (classMap.containsKey(key)) {
                 Map<String, String> listAttributes = classMap.get(key).getAttribute();
                 Map<String, String> listRef = classMap.get(key).getRefAttribute();
-                for (Entry<String, String> eSet : listAttributes.entrySet()) {
-                    String key2 = eSet.getKey();
+                for (Entry<String, String> eset : listAttributes.entrySet()) {
+                    String key2 = eset.getKey();
                     tempAttribute.put(key2, MATCHINGTRUE);
                 }
-                for (Entry<String, String> eSet : listRef.entrySet()) {
-                    String key3 = eSet.getKey();
+                for (Entry<String, String> eset : listRef.entrySet()) {
+                    String key3 = eset.getKey();
                     tempAttribute.put(key3, MATCHINGTRUE);
                 }
 
@@ -217,12 +269,16 @@ public class MSModelUtils {
 
     }
 
-
-
+    /**
+     * Update matching.
+     *
+     * @param tempAttribute the temp attribute
+     * @param key the key
+     */
     private void updateMatching(HashMap<String, String> tempAttribute, String key) {
-        Map<String, MSAttributeObject> newClass = classMap;
+        Map<String, MsAttributeObject> newClass = classMap;
 
-        for (Entry<String, MSAttributeObject> updateClass : newClass.entrySet()) {
+        for (Entry<String, MsAttributeObject> updateClass : newClass.entrySet()) {
             Map<String, String> valueMap = updateClass.getValue().getMatchingSet();
             String keymap = updateClass.getKey();
             if (valueMap.containsKey(key)) {
@@ -235,17 +291,26 @@ public class MSModelUtils {
         }
     }
 
+    /**
+     * Adds the enum class map.
+     */
     private void addEnumClassMap() {
-        for (Entry<String, MSAttributeObject> value : classMap.entrySet()) {
+        for (Entry<String, MsAttributeObject> value : classMap.entrySet()) {
             value.getValue().setEnumType(enumMap);
         }
     }
 
+    /**
+     * Gets the epackage.
+     *
+     * @param xmiFile the xmi file
+     * @return the epackage
+     */
     private EPackage getEpackage(String xmiFile) {
         ResourceSet resSet = new ResourceSetImpl();
         Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
-        Map<String, Object> m = reg.getExtensionToFactoryMap();
-        m.put("xmi", new XMIResourceFactoryImpl());
+        Map<String, Object> objectMap = reg.getExtensionToFactoryMap();
+        objectMap.put("xmi", new XMIResourceFactoryImpl());
         Resource resource = resSet.getResource(URI.createFileURI(xmiFile), true);
         try {
             resource.load(Collections.emptyMap());
@@ -256,14 +321,20 @@ public class MSModelUtils {
         return (EPackage) resource.getContents().get(0);
     }
 
+    /**
+     * Gets the e enum.
+     *
+     * @param obj the obj
+     * @return the e enum
+     */
     private HashMap<String, String> getEEnum(EObject obj) {
         List<String> valueList = new ArrayList<>();
         HashMap<String, String> returnMap = new HashMap<>();
         EEnum eenum = (EEnum) obj;
 
         String name = eenum.getName();
-        for (EEnumLiteral eEnumLiteral : eenum.getELiterals()) {
-            Enumerator instance = eEnumLiteral.getInstance();
+        for (EEnumLiteral enumLiteral : eenum.getELiterals()) {
+            Enumerator instance = enumLiteral.getInstance();
             String value = instance.getLiteral();
             valueList.add(value);
         }
@@ -271,12 +342,19 @@ public class MSModelUtils {
         return returnMap;
     }
 
+    /**
+     * Gets the attributes.
+     *
+     * @param className the class name
+     * @param dependency the dependency
+     * @param root the root
+     */
     public void getAttributes(String className, String dependency, EPackage root) {
         List<String> dpendList = new ArrayList<>();
         if (dependency != null) {
             dpendList = new ArrayList<>(Arrays.asList(dependency.split(",")));
         }
-        MSAttributeObject msAttributeObject = new MSAttributeObject();
+        MsAttributeObject msAttributeObject = new MsAttributeObject();
         msAttributeObject.setClassName(className);
         String extendClass = getSubTypes(root, className);
         Map<String, String> returnRefList = getRefAttributeList(root, className, extendClass);
@@ -293,6 +371,14 @@ public class MSModelUtils {
         this.classMap.put(className, msAttributeObject);
     }
 
+    /**
+     * Gets the annotation.
+     *
+     * @param root the root
+     * @param className the class name
+     * @param extendClass the extend class
+     * @return the annotation
+     */
     private HashMap<String, String> getAnnotation(EPackage root, String className, String extendClass) {
         TreeIterator<EObject> treeItr = root.eAllContents();
         boolean requiredAttribute = false;
@@ -318,43 +404,63 @@ public class MSModelUtils {
         return annotationSet;
     }
 
+    /**
+     * Find matching annotation.
+     *
+     * @param annotationSet the annotation set
+     * @param obj the obj
+     */
     private void findMatchingAnnotation(HashMap<String, String> annotationSet, EObject obj) {
-        EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-        if (eStrucClassifier.getEAnnotations().isEmpty()) {
+        EStructuralFeature estrucClassifier = (EStructuralFeature) obj;
+        if (estrucClassifier.getEAnnotations().isEmpty()) {
             return;
         }
-        String matching = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
+        String matching = annotationValue(estrucClassifier, AnnotationType.MATCHING, policy);
         if (matching != null) {
             if (obj instanceof EReference) {
                 EClass refType = ((EReference) obj).getEReferenceType();
                 annotationSet.put(refType.getName(), matching);
                 matchingClass.put(refType.getName(), matching);
             } else {
-                annotationSet.put(eStrucClassifier.getName(), matching);
+                annotationSet.put(estrucClassifier.getName(), matching);
             }
         }
 
     }
 
+    /**
+     * Check annotation.
+     *
+     * @param annotationSet the annotation set
+     * @param obj the obj
+     */
     private void checkAnnotation(HashMap<String, String> annotationSet, EStructuralFeature obj) {
-        EStructuralFeature eStrucClassifier = obj;
-        if (eStrucClassifier.getEAnnotations().isEmpty()) {
+        EStructuralFeature estrucClassifier = obj;
+        if (estrucClassifier.getEAnnotations().isEmpty()) {
             return;
         }
-        String matching = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
+        String matching = annotationValue(estrucClassifier, AnnotationType.MATCHING, policy);
         if (matching != null) {
-            annotationSet.put(eStrucClassifier.getName(), matching);
+            annotationSet.put(estrucClassifier.getName(), matching);
         }
-        String range = annotationValue(eStrucClassifier, ANNOTATION_TYPE.VALIDATION, policy);
+        String range = annotationValue(estrucClassifier, AnnotationType.VALIDATION, policy);
         if (range != null) {
-            annotationSet.put(eStrucClassifier.getName(), range);
+            annotationSet.put(estrucClassifier.getName(), range);
         }
-        String annotationDict = annotationValue(eStrucClassifier, ANNOTATION_TYPE.DICTIONARY, policy);
+        String annotationDict = annotationValue(estrucClassifier, AnnotationType.DICTIONARY, policy);
         if (annotationDict != null) {
-            annotationSet.put(eStrucClassifier.getName(), annotationDict);
+            annotationSet.put(estrucClassifier.getName(), annotationDict);
         }
     }
 
+    /**
+     * Gets the sub attribute list.
+     *
+     * @param root the root
+     * @param className the class name
+     * @param superClass the super class
+     * @return the sub attribute list
+     */
     private Map<String, Object> getSubAttributeList(EPackage root, String className, String superClass) {
         TreeIterator<EObject> treeItr = root.eAllContents();
         boolean requiredAttribute = false;
@@ -375,32 +481,45 @@ public class MSModelUtils {
             }
 
             if (requiredAttribute && (obj instanceof EStructuralFeature)) {
-                EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-                if (!eStrucClassifier.getEAnnotations().isEmpty()) {
-                    updateSubAttributes(subAttribute, obj, eStrucClassifier);
+                EStructuralFeature estrucClassifier = (EStructuralFeature) obj;
+                if (!estrucClassifier.getEAnnotations().isEmpty()) {
+                    updateSubAttributes(subAttribute, obj, estrucClassifier);
                 }
             }
         }
         return subAttribute;
     }
 
+    /**
+     * Update sub attributes.
+     *
+     * @param subAttribute the sub attribute
+     * @param obj the obj
+     * @param estrucClassifier the e struc classifier
+     */
     private void updateSubAttributes(Map<String, Object> subAttribute, EObject obj,
-            EStructuralFeature eStrucClassifier) {
+                    EStructuralFeature estrucClassifier) {
         if (!(obj instanceof EReference)) {
             return;
         }
-        if (annotationTest(eStrucClassifier, configuration, onap)) {
+        if (annotationTest(estrucClassifier, CONFIGURATION, onap)) {
             EClass refType = ((EReference) obj).getEReferenceType();
-            if (!refType.toString().contains(eProxyURI)) {
+            if (!refType.toString().contains(E_PROXY_URI)) {
                 String required = REQUIREDFALSE;
-                if (eStrucClassifier.getLowerBound() == 1) {
+                if (estrucClassifier.getLowerBound() == 1) {
                     required = REQUIREDTRUE;
                 }
-                subAttribute.put(eStrucClassifier.getName(), refType.getName() + required);
+                subAttribute.put(estrucClassifier.getName(), refType.getName() + required);
             }
         }
     }
 
+    /**
+     * Check defult value.
+     *
+     * @param defultValue the defult value
+     * @return the string
+     */
     public String checkDefultValue(String defultValue) {
         if (defultValue != null) {
             return DEFAULTVALUE + defultValue;
@@ -409,19 +528,40 @@ public class MSModelUtils {
 
     }
 
+    /**
+     * Check required pattern.
+     *
+     * @param upper the upper
+     * @param lower the lower
+     * @return the string
+     */
     public String checkRequiredPattern(int upper, int lower) {
         String pattern = XACMLProperties.getProperty(XacmlRestProperties.PROP_XCORE_REQUIRED_PATTERN);
         if (pattern != null && upper == Integer.parseInt(pattern.split(",")[1])
-                && lower == Integer.parseInt(pattern.split(",")[0])) {
+                        && lower == Integer.parseInt(pattern.split(",")[0])) {
             return REQUIREDTRUE;
         }
         return REQUIREDFALSE;
     }
 
+    /**
+     * Builds the java object.
+     *
+     * @param map the map
+     * @return the JSON object
+     */
     public JSONObject buildJavaObject(Map<String, String> map) {
         return new JSONObject(map);
     }
 
+    /**
+     * Gets the ref attribute list.
+     *
+     * @param root the root
+     * @param className the class name
+     * @param superClass the super class
+     * @return the ref attribute list
+     */
     public Map<String, String> getRefAttributeList(EPackage root, String className, String superClass) {
 
         TreeIterator<EObject> treeItr = root.eAllContents();
@@ -442,13 +582,13 @@ public class MSModelUtils {
             }
 
             if (requiredAttribute && (obj instanceof EStructuralFeature)) {
-                EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-                if (!eStrucClassifier.getEAnnotations().isEmpty()) {
-                    annotation = annotationTest(eStrucClassifier, configuration, onap);
+                EStructuralFeature estrucClassifier = (EStructuralFeature) obj;
+                if (!estrucClassifier.getEAnnotations().isEmpty()) {
+                    annotation = annotationTest(estrucClassifier, CONFIGURATION, onap);
                     if (annotation && obj instanceof EReference) {
-                        updRefAttributes(refAttribute, (EStructuralFeature) obj, eStrucClassifier);
+                        updRefAttributes(refAttribute, (EStructuralFeature) obj, estrucClassifier);
                     } else if (annotation && obj instanceof EAttributeImpl) {
-                        updEnumTypeRefAttrib(refAttribute, (EStructuralFeature) obj, eStrucClassifier);
+                        updEnumTypeRefAttrib(refAttribute, (EStructuralFeature) obj, estrucClassifier);
                     }
                 }
             }
@@ -457,8 +597,15 @@ public class MSModelUtils {
         return refAttribute;
     }
 
+    /**
+     * Upd enum type ref attrib.
+     *
+     * @param refAttribute the ref attribute
+     * @param obj the obj
+     * @param estrucClassifier the e struc classifier
+     */
     private void updEnumTypeRefAttrib(HashMap<String, String> refAttribute, EStructuralFeature obj,
-            EStructuralFeature eStrucClassifier) {
+                    EStructuralFeature estrucClassifier) {
         EClassifier refType = ((EAttributeImpl) obj).getEType();
         if (!(refType instanceof EEnumImpl)) {
             return;
@@ -469,40 +616,56 @@ public class MSModelUtils {
         if (obj.getLowerBound() == 1) {
             required = REQUIREDTRUE;
         }
-        refAttribute.put(eStrucClassifier.getName(), refType.getName() + array + required);
+        refAttribute.put(estrucClassifier.getName(), refType.getName() + array + required);
     }
 
+    /**
+     * Upd ref attributes.
+     *
+     * @param refAttribute the ref attribute
+     * @param obj the obj
+     * @param estrucClassifier the e struc classifier
+     */
     private void updRefAttributes(HashMap<String, String> refAttribute, EStructuralFeature obj,
-            EStructuralFeature eStrucClassifier) {
+                    EStructuralFeature estrucClassifier) {
         EClass refType = ((EReference) obj).getEReferenceType();
-        if (refType.toString().contains(eProxyURI)) {
-            String one = refType.toString().split(eProxyURI)[1];
-            String refValue =
-                    StringUtils.replaceEach(one.split("#")[1], new String[] {"//", ")"}, new String[] {"", ""});
-            refAttribute.put(eStrucClassifier.getName(), refValue);
+        if (refType.toString().contains(E_PROXY_URI)) {
+            String one = refType.toString().split(E_PROXY_URI)[1];
+            String refValue = StringUtils.replaceEach(one.split("#")[1], new String[]
+                { "//", ")" }, new String[]
+                { "", "" });
+            refAttribute.put(estrucClassifier.getName(), refValue);
         } else {
             String required = REQUIREDFALSE;
             if (obj.getLowerBound() == 1) {
                 required = REQUIREDTRUE;
             }
-            refAttribute.put(eStrucClassifier.getName(),
-                    refType.getName() + arrayCheck(obj.getUpperBound()) + required);
+            refAttribute.put(estrucClassifier.getName(),
+                            refType.getName() + arrayCheck(obj.getUpperBound()) + required);
         }
     }
 
-    private boolean annotationTest(EStructuralFeature eStrucClassifier, String annotation, String type) {
+    /**
+     * Annotation test.
+     *
+     * @param estrucClassifier the e struc classifier
+     * @param annotation the annotation
+     * @param type the type
+     * @return true, if successful
+     */
+    private boolean annotationTest(EStructuralFeature estrucClassifier, String annotation, String type) {
         String annotationType;
-        EAnnotation eAnnotation;
+        EAnnotation eannotation;
         String onapType;
         String onapValue;
 
-        EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
+        EList<EAnnotation> value = estrucClassifier.getEAnnotations();
 
         for (int i = 0; i < value.size(); i++) {
             annotationType = value.get(i).getSource();
-            eAnnotation = eStrucClassifier.getEAnnotations().get(i);
-            onapType = eAnnotation.getDetails().get(0).getValue();
-            onapValue = eAnnotation.getDetails().get(0).getKey();
+            eannotation = estrucClassifier.getEAnnotations().get(i);
+            onapType = eannotation.getDetails().get(0).getValue();
+            onapValue = eannotation.getDetails().get(0).getKey();
 
             if (annotationType.contains(type) && onapType.contains(annotation)) {
                 return true;
@@ -516,22 +679,29 @@ public class MSModelUtils {
         return false;
     }
 
-
-    private String annotationValue(EStructuralFeature eStrucClassifier, ANNOTATION_TYPE annotation, String type) {
+    /**
+     * Annotation value.
+     *
+     * @param estrucClassifier the e struc classifier
+     * @param annotation the annotation
+     * @param type the type
+     * @return the string
+     */
+    private String annotationValue(EStructuralFeature estrucClassifier, AnnotationType annotation, String type) {
         String annotationType;
-        EAnnotation eAnnotation;
+        EAnnotation eannotation;
         String onapType;
         String onapValue = null;
 
-        EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
+        EList<EAnnotation> value = estrucClassifier.getEAnnotations();
 
         for (int i = 0; i < value.size(); i++) {
             annotationType = value.get(i).getSource();
-            eAnnotation = eStrucClassifier.getEAnnotations().get(i);
-            onapType = eAnnotation.getDetails().get(0).getKey();
+            eannotation = estrucClassifier.getEAnnotations().get(i);
+            onapType = eannotation.getDetails().get(0).getKey();
             if (annotationType.contains(type) && onapType.compareToIgnoreCase(annotation.toString()) == 0) {
-                onapValue = eAnnotation.getDetails().get(0).getValue();
-                if (annotation == ANNOTATION_TYPE.VALIDATION) {
+                onapValue = eannotation.getDetails().get(0).getValue();
+                if (annotation == AnnotationType.VALIDATION) {
                     return onapValue;
                 } else {
                     return onapType + "-" + onapValue;
@@ -542,23 +712,33 @@ public class MSModelUtils {
         return onapValue;
     }
 
+    /**
+     * Checks if is required attribute.
+     *
+     * @param obj the obj
+     * @param className the class name
+     * @return true, if is required attribute
+     */
     public boolean isRequiredAttribute(EObject obj, String className) {
-        EClassifier eClassifier = (EClassifier) obj;
-        String workingClass = eClassifier.getName().trim();
-        if (workingClass.equalsIgnoreCase(className)) {
-            return true;
-        }
-
-        return false;
+        EClassifier eclassifier = (EClassifier) obj;
+        String workingClass = eclassifier.getName().trim();
+        return workingClass.equalsIgnoreCase(className);
     }
 
+    /**
+     * Checks if is policy template.
+     *
+     * @param root the root
+     * @param className the class name
+     * @return true, if is policy template
+     */
     private boolean isPolicyTemplate(EPackage root, String className) {
         boolean result = false;
         for (EClassifier classifier : root.getEClassifiers()) {
             if (classifier instanceof EClass) {
-                EClass eClass = (EClass) classifier;
-                if (eClass.getName().contentEquals(className)) {
-                    result = checkPolicyTemplate(eClass);
+                EClass eclass = (EClass) classifier;
+                if (eclass.getName().contentEquals(className)) {
+                    result = checkPolicyTemplate(eclass);
                     break;
                 }
             }
@@ -566,8 +746,14 @@ public class MSModelUtils {
         return result;
     }
 
-    private boolean checkPolicyTemplate(EClass eClass) {
-        EList<EAnnotation> value = eClass.getEAnnotations();
+    /**
+     * Check policy template.
+     *
+     * @param eclass the e class
+     * @return true, if successful
+     */
+    private boolean checkPolicyTemplate(EClass eclass) {
+        EList<EAnnotation> value = eclass.getEAnnotations();
         for (EAnnotation workingValue : value) {
             EMap<String, String> keyMap = workingValue.getDetails();
             if (keyMap.containsKey("policyTemplate")) {
@@ -577,6 +763,13 @@ public class MSModelUtils {
         return false;
     }
 
+    /**
+     * Gets the sub types.
+     *
+     * @param root the root
+     * @param className the class name
+     * @return the sub types
+     */
     private String getSubTypes(EPackage root, String className) {
         String returnSubTypes = null;
         for (EClassifier classifier : root.getEClassifiers()) {
@@ -587,17 +780,33 @@ public class MSModelUtils {
         return returnSubTypes;
     }
 
+    /**
+     * Find sub types.
+     *
+     * @param className the class name
+     * @param returnSubTypes the return sub types
+     * @param classifier the classifier
+     * @return the string
+     */
     private String findSubTypes(String className, String returnSubTypes, EClass classifier) {
-        EClass eClass = classifier;
+        EClass eclass = classifier;
 
-        for (EClass eSuperType : eClass.getEAllSuperTypes()) {
-            if (eClass.getName().contentEquals(className)) {
-                returnSubTypes = eSuperType.getName();
+        for (EClass esuperType : eclass.getEAllSuperTypes()) {
+            if (eclass.getName().contentEquals(className)) {
+                returnSubTypes = esuperType.getName();
             }
         }
         return returnSubTypes;
     }
 
+    /**
+     * Gets the attribute list.
+     *
+     * @param root the root
+     * @param className the class name
+     * @param superClass the super class
+     * @return the attribute list
+     */
     public Map<String, String> getAttributeList(EPackage root, String className, String superClass) {
 
         TreeIterator<EObject> treeItr = root.eAllContents();
@@ -612,9 +821,9 @@ public class MSModelUtils {
             }
 
             if (requiredAttribute && (obj instanceof EStructuralFeature)) {
-                EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-                if (!eStrucClassifier.getEAnnotations().isEmpty()) {
-                    checkStrucClassifier(refAttribute, obj, eStrucClassifier);
+                EStructuralFeature estrucClassifier = (EStructuralFeature) obj;
+                if (!estrucClassifier.getEAnnotations().isEmpty()) {
+                    checkStrucClassifier(refAttribute, obj, estrucClassifier);
                 }
             }
         }
@@ -622,31 +831,52 @@ public class MSModelUtils {
 
     }
 
+    /**
+     * Check struc classifier.
+     *
+     * @param refAttribute the ref attribute
+     * @param obj the obj
+     * @param estrucClassifier the e struc classifier
+     */
     private void checkStrucClassifier(HashMap<String, String> refAttribute, EObject obj,
-            EStructuralFeature eStrucClassifier) {
+                    EStructuralFeature estrucClassifier) {
         EClassifier refType = ((EStructuralFeature) obj).getEType();
-        boolean annotation = annotationTest(eStrucClassifier, configuration, onap);
-        boolean dictionaryTest = annotationTest(eStrucClassifier, dictionary, policy);
+        boolean annotation = annotationTest(estrucClassifier, CONFIGURATION, onap);
+        boolean dictionaryTest = annotationTest(estrucClassifier, DICTIONARY, policy);
         if (annotation && !(obj instanceof EReference) && !(refType instanceof EEnumImpl)) {
-            updEReferenceAttrib(refAttribute, dictionaryTest, (EStructuralFeature) obj, eStrucClassifier);
+            updEReferenceAttrib(refAttribute, dictionaryTest, (EStructuralFeature) obj, estrucClassifier);
         }
     }
 
+    /**
+     * Upd E reference attrib.
+     *
+     * @param refAttribute the ref attribute
+     * @param dictionaryTest the dictionary test
+     * @param obj the obj
+     * @param estrucClassifier the e struc classifier
+     */
     private void updEReferenceAttrib(HashMap<String, String> refAttribute, boolean dictionaryTest,
-            EStructuralFeature obj, EStructuralFeature eStrucClassifier) {
-        String eType;
-        String name = eStrucClassifier.getName();
+                    EStructuralFeature obj, EStructuralFeature estrucClassifier) {
+        String etype;
+        String name = estrucClassifier.getName();
         if (dictionaryTest) {
-            eType = annotationValue(eStrucClassifier, ANNOTATION_TYPE.DICTIONARY, policy);
+            etype = annotationValue(estrucClassifier, AnnotationType.DICTIONARY, policy);
         } else {
-            eType = eStrucClassifier.getEType().getInstanceClassName();
+            etype = estrucClassifier.getEType().getInstanceClassName();
         }
         String defaultValue = checkDefultValue(obj.getDefaultValueLiteral());
         String array = arrayCheck(obj.getUpperBound());
         String required = checkRequiredPattern(obj.getUpperBound(), obj.getLowerBound());
-        refAttribute.put(name, eType + defaultValue + required + array);
+        refAttribute.put(name, etype + defaultValue + required + array);
     }
 
+    /**
+     * Array check.
+     *
+     * @param upperBound the upper bound
+     * @return the string
+     */
     public String arrayCheck(int upperBound) {
 
         if (upperBound == -1) {
@@ -656,17 +886,25 @@ public class MSModelUtils {
         return MANYFALSE;
     }
 
-    public List<String> getDependencyList(EClassifier eClassifier) {
-        List<String> returnValue = new ArrayList<>();;
-        EList<EClass> somelist = ((EClass) eClassifier).getEAllSuperTypes();
+    /**
+     * Gets the dependency list.
+     *
+     * @param eclassifier the e classifier
+     * @return the dependency list
+     */
+    public List<String> getDependencyList(EClassifier eclassifier) {
+        List<String> returnValue = new ArrayList<>();
+        ;
+        EList<EClass> somelist = ((EClass) eclassifier).getEAllSuperTypes();
         if (somelist.isEmpty()) {
             return returnValue;
         }
         for (EClass depend : somelist) {
-            if (depend.toString().contains(eProxyURI)) {
-                String one = depend.toString().split(eProxyURI)[1];
-                String value =
-                        StringUtils.replaceEach(one.split("#")[1], new String[] {"//", ")"}, new String[] {"", ""});
+            if (depend.toString().contains(E_PROXY_URI)) {
+                String one = depend.toString().split(E_PROXY_URI)[1];
+                String value = StringUtils.replaceEach(one.split("#")[1], new String[]
+                    { "//", ")" }, new String[]
+                    { "", "" });
                 returnValue.add(value);
             }
         }
@@ -674,8 +912,16 @@ public class MSModelUtils {
         return returnValue;
     }
 
+    /**
+     * Builds the sub list.
+     *
+     * @param subClassAttributes the sub class attributes
+     * @param classMap the class map
+     * @param className the class name
+     * @return the map
+     */
     public Map<String, String> buildSubList(Map<String, String> subClassAttributes,
-            Map<String, MSAttributeObject> classMap, String className) {
+                    Map<String, MsAttributeObject> classMap, String className) {
         Map<String, String> missingValues = new HashMap<>();
         Map<String, String> workingMap;
         boolean enumType;
@@ -701,15 +947,22 @@ public class MSModelUtils {
         return missingValues;
     }
 
-    public Map<String, Map<String, String>> recursiveReference(Map<String, MSAttributeObject> classMap,
-            String className) {
+    /**
+     * Recursive reference.
+     *
+     * @param classMap the class map
+     * @param className the class name
+     * @return the map
+     */
+    public Map<String, Map<String, String>> recursiveReference(Map<String, MsAttributeObject> classMap,
+                    String className) {
 
         Map<String, Map<String, String>> returnObject = new HashMap<>();
         Map<String, String> returnClass = getRefclass(classMap, className);
         returnObject.put(className, returnClass);
         for (Entry<String, String> reAttribute : returnClass.entrySet()) {
             if (reAttribute.getValue().split(":")[1].contains("MANY")
-                    && classMap.get(reAttribute.getValue().split(":")[0]) != null) {
+                            && classMap.get(reAttribute.getValue().split(":")[0]) != null) {
                 returnObject.putAll(recursiveReference(classMap, reAttribute.getValue().split(":")[0]));
             }
 
@@ -719,7 +972,14 @@ public class MSModelUtils {
 
     }
 
-    public String createJson(Map<String, MSAttributeObject> classMap, String className) {
+    /**
+     * Creates the json.
+     *
+     * @param classMap the class map
+     * @param className the class name
+     * @return the string
+     */
+    public String createJson(Map<String, MsAttributeObject> classMap, String className) {
         boolean enumType;
         Map<String, Map<String, String>> myObject = new HashMap<>();
         for (Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()) {
@@ -727,8 +987,8 @@ public class MSModelUtils {
             if (value != null) {
                 enumType = classMap.get(className).getEnumType().containsKey(value);
                 if (!enumType && map.getValue().split(":")[1].contains("MANY")) {
-                    Map<String, Map<String, String>> testRecursive =
-                            recursiveReference(classMap, map.getValue().split(":")[0]);
+                    Map<String, Map<String, String>> testRecursive = recursiveReference(classMap,
+                                    map.getValue().split(":")[0]);
                     myObject.putAll(testRecursive);
                 }
             }
@@ -738,7 +998,14 @@ public class MSModelUtils {
         return gson.toJson(myObject);
     }
 
-    public Map<String, String> getRefclass(Map<String, MSAttributeObject> classMap, String className) {
+    /**
+     * Gets the refclass.
+     *
+     * @param classMap the class map
+     * @param className the class name
+     * @return the refclass
+     */
+    public Map<String, String> getRefclass(Map<String, MsAttributeObject> classMap, String className) {
         HashMap<String, String> missingValues = new HashMap<>();
 
         if (classMap.get(className).getAttribute() != null || !classMap.get(className).getAttribute().isEmpty()) {
@@ -752,11 +1019,19 @@ public class MSModelUtils {
         return missingValues;
     }
 
-    public String createSubAttributes(List<String> dependency, Map<String, MSAttributeObject> classMap,
-            String modelName) {
+    /**
+     * Creates the sub attributes.
+     *
+     * @param dependency the dependency
+     * @param classMap the class map
+     * @param modelName the model name
+     * @return the string
+     */
+    public String createSubAttributes(List<String> dependency, Map<String, MsAttributeObject> classMap,
+                    String modelName) {
 
         HashMap<String, Object> workingMap = new HashMap<>();
-        MSAttributeObject tempObject;
+        MsAttributeObject tempObject;
         if (dependency != null) {
             if (dependency.isEmpty()) {
                 return "{}";
@@ -773,15 +1048,23 @@ public class MSModelUtils {
         return createJson(classMap, modelName);
     }
 
-    public List<String> getFullDependencyList(List<String> dependency, Map<String, MSAttributeObject> classMap) {
+    /**
+     * Gets the full dependency list.
+     *
+     * @param dependency the dependency
+     * @param classMap the class map
+     * @return the full dependency list
+     */
+    public List<String> getFullDependencyList(List<String> dependency, Map<String, MsAttributeObject> classMap) {
         ArrayList<String> returnList = new ArrayList<>();
         ArrayList<String> workingList;
         returnList.addAll(dependency);
         for (String element : dependency) {
             if (classMap.containsKey(element)) {
-                MSAttributeObject value = classMap.get(element);
-                String rawValue =
-                        StringUtils.replaceEach(value.getDependency(), new String[] {"[", "]"}, new String[] {"", ""});
+                MsAttributeObject value = classMap.get(element);
+                String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]
+                    { "[", "]" }, new String[]
+                    { "", "" });
                 workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));
                 for (String depend : workingList) {
                     updDependencyList(returnList, depend);
@@ -792,14 +1075,23 @@ public class MSModelUtils {
         return returnList;
     }
 
+    /**
+     * Upd dependency list.
+     *
+     * @param returnList the return list
+     * @param depend the depend
+     */
     private void updDependencyList(ArrayList<String> returnList, String depend) {
         if (!returnList.contains(depend) && !depend.isEmpty()) {
             returnList.add(depend.trim());
         }
     }
 
-    /*
-     * For TOSCA Model
+    /**
+     * Parses the TOSCA model.
+     *
+     * @param fileName the file name
+     * @return the string
      */
     public String parseTosca(String fileName) {
         Map<String, String> map = new LinkedHashMap<>();
@@ -824,14 +1116,21 @@ public class MSModelUtils {
         return null;
     }
 
-    @SuppressWarnings("unchecked")
+    /**
+     * Load.
+     *
+     * @param fileName the file name
+     * @return the map
+     * @throws IOException Signals that an I/O exception has occurred.
+     * @throws ParserException the parser exception
+     */
     public Map<String, String> load(String fileName) throws IOException, ParserException {
         File newConfiguration = new File(fileName);
         StringBuilder orderInfo = new StringBuilder("[");
         Yaml yaml = new Yaml();
         LinkedHashMap<Object, Object> yamlMap = null;
         try (InputStream is = new FileInputStream(newConfiguration)) {
-            yamlMap = (LinkedHashMap<Object, Object>) yaml.load(is);
+            yamlMap = yaml.load(is);
         } catch (FileNotFoundException e) {
             logger.error(e);
         } catch (Exception e) {
@@ -839,7 +1138,6 @@ public class MSModelUtils {
             throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file");
         }
 
-        StringBuilder sb = new StringBuilder();
         LinkedHashMap<String, String> settings = new LinkedHashMap<>();
         if (yamlMap == null) {
             return settings;
@@ -870,10 +1168,16 @@ public class MSModelUtils {
         }
 
         List<String> path = new ArrayList<>();
-        serializeMap(settings, sb, path, yamlMap);
+        serializeMap(settings, new StringBuilder(), path, yamlMap);
         return settings;
     }
 
+    /**
+     * Validations.
+     *
+     * @param yamlMap the yaml map
+     * @return the string
+     */
     @SuppressWarnings("unchecked")
     private String validations(@SuppressWarnings("rawtypes") Map yamlMap) {
 
@@ -888,8 +1192,7 @@ public class MSModelUtils {
             // Get a set of the entries
             @SuppressWarnings("rawtypes")
             Set<Entry> entries = yamlMap.entrySet();
-            for (@SuppressWarnings("rawtypes")
-                Map.Entry me : entries) {
+            for (Map.Entry<Object, Object> me : entries) {
                 if (TOSCA_SIMPLE_YAML_1_0_0.equals(me.getValue())) {
                     isToscaVersionValueFound = true;
                 }
@@ -945,9 +1248,18 @@ public class MSModelUtils {
         return null;
     }
 
-    @SuppressWarnings({"unchecked", "rawtypes"})
+    /**
+     * Serialize map.
+     *
+     * @param settings the settings
+     * @param sb the sb
+     * @param path the path
+     * @param yamlMap the yaml map
+     */
+    @SuppressWarnings(
+        { "unchecked", "rawtypes" })
     private void serializeMap(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
-            Map<Object, Object> yamlMap) {
+                    Map<Object, Object> yamlMap) {
         for (Map.Entry<Object, Object> entry : yamlMap.entrySet()) {
 
             if (entry.getValue() instanceof Map) {
@@ -964,9 +1276,17 @@ public class MSModelUtils {
         }
     }
 
+    /**
+     * Serialize list.
+     *
+     * @param settings the settings
+     * @param sb the sb
+     * @param path the path
+     * @param yamlList the yaml list
+     */
     @SuppressWarnings("unchecked")
     private void serializeList(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
-            List<String> yamlList) {
+                    List<String> yamlList) {
         int counter = 0;
         for (Object listEle : yamlList) {
             if (listEle instanceof Map) {
@@ -984,8 +1304,17 @@ public class MSModelUtils {
         }
     }
 
+    /**
+     * Serialize value.
+     *
+     * @param settings the settings
+     * @param sb the sb
+     * @param path the path
+     * @param name the name
+     * @param value the value
+     */
     private void serializeValue(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
-            String name, Object value) {
+                    String name, Object value) {
         if (value == null) {
             return;
         }
@@ -997,7 +1326,11 @@ public class MSModelUtils {
         settings.put(sb.toString(), value.toString());
     }
 
-
+    /**
+     * Parses the data and policy nodes.
+     *
+     * @param map the map
+     */
     void parseDataAndPolicyNodes(Map<String, String> map) {
         for (String key : map.keySet()) {
             if (key.contains("policy.nodes.Root")) {
@@ -1018,6 +1351,12 @@ public class MSModelUtils {
         }
     }
 
+    /**
+     * String between dots.
+     *
+     * @param str the str
+     * @return the int
+     */
     // Second index of dot should be returned.
     public int stringBetweenDots(String str) {
         String stringToSearch = str;
@@ -1032,7 +1371,11 @@ public class MSModelUtils {
         return uniqueKeys.size();
     }
 
-
+    /**
+     * String between dots for data fields.
+     *
+     * @param str the str
+     */
     public void stringBetweenDotsForDataFields(String str) {
         String stringToSearch = str;
         String[] ss = stringToSearch.split("\\.");
@@ -1045,6 +1388,11 @@ public class MSModelUtils {
         }
     }
 
+    /**
+     * Construct json for data fields.
+     *
+     * @param dataMapForJson the data map for json
+     */
     void constructJsonForDataFields(LinkedHashMap<String, String> dataMapForJson) {
         LinkedHashMap<String, LinkedHashMap<String, String>> dataMapKey = new LinkedHashMap<>();
         LinkedHashMap<String, String> hmSub;
@@ -1066,14 +1414,14 @@ public class MSModelUtils {
         JSONObject mainObject = new JSONObject();
         JSONObject json;
         for (Map.Entry<String, LinkedHashMap<String, String>> entry : dataMapKey.entrySet()) {
-            String s = entry.getKey();
+            String keyString = entry.getKey();
             json = new JSONObject();
-            HashMap<String, String> jsonHm = dataMapKey.get(s);
+            HashMap<String, String> jsonHm = dataMapKey.get(keyString);
             for (Map.Entry<String, String> entryMap : jsonHm.entrySet()) {
                 String key = entryMap.getKey();
                 json.put(key, jsonHm.get(key));
             }
-            mainObject.put(s, json);
+            mainObject.put(keyString, json);
         }
         Iterator<String> keysItr = mainObject.keys();
         while (keysItr.hasNext()) {
@@ -1087,6 +1435,12 @@ public class MSModelUtils {
         logger.info("###############################################################################");
     }
 
+    /**
+     * Parses the data nodes.
+     *
+     * @param map the map
+     * @return the linked hash map
+     */
     LinkedHashMap<String, String> parseDataNodes(Map<String, String> map) {
         LinkedHashMap<String, String> dataMapForJson = new LinkedHashMap<>();
         matchableValues = new HashMap<>();
@@ -1113,13 +1467,10 @@ public class MSModelUtils {
                     requiredValue = "false";
                 }
                 if (INTEGER.equalsIgnoreCase(typeValue) || STRING.equalsIgnoreCase(typeValue)
-                        || typeValue.equalsIgnoreCase(BOOLEAN)) {
-                    String findDefault =
-                            DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + DEFAULT;
-                    String findDescription =
-                            DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + DESCRIPTION;
+                                || typeValue.equalsIgnoreCase(BOOLEAN)) {
+                    String findDefault = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
+                                    + DEFAULT;
                     String defaultValue = map.get(findDefault);
-                    String descriptionDefined = map.get(findDescription);
                     logger.info("defaultValue is:" + defaultValue);
                     logger.info("requiredValue is:" + requiredValue);
 
@@ -1127,16 +1478,19 @@ public class MSModelUtils {
                     attributeIndividualStringBuilder.append(typeValue + DEFAULTVALUE);
                     attributeIndividualStringBuilder.append(defaultValue + REQUIREDVALUE);
                     attributeIndividualStringBuilder.append(requiredValue + MANYFALSE);
-                    attributeIndividualStringBuilder.append(DESCRIPTION_TOKEN + descriptionDefined);
+
+                    String findDescription = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
+                                    + DESCRIPTION;
+                    attributeIndividualStringBuilder.append(DESCRIPTION_TOKEN + map.get(findDescription));
                     dataMapForJson.put(uniqueDataKey, attributeIndividualStringBuilder.toString());
                 } else if (LIST.equalsIgnoreCase(typeValue) || MAP.equalsIgnoreCase(typeValue)) {
                     logger.info("requiredValue is:" + requiredValue);
                     String findList = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
-                            + ".entry_schema.type";
+                                    + ".entry_schema.type";
                     String findDefaultValue = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
-                            + ".entry_schema.default";
+                                    + ".entry_schema.default";
                     String findDescription = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
-                            + ".entry_schema.description";
+                                    + ".entry_schema.description";
                     String listValue = map.get(findList);
                     String defaultValue = map.get(findDefaultValue);
                     String description = map.get(findDescription);
@@ -1154,16 +1508,19 @@ public class MSModelUtils {
                             StringBuilder stringListItems = new StringBuilder();
                             if (LIST.equalsIgnoreCase(typeValue)) {
                                 stringListItems.append(uniqueDataKeySplit[1].toUpperCase() + DEFAULTVALUE + defaultValue
-                                        + REQUIREDVALUE + requiredValue + MANYFALSE + DESCRIPTION_TOKEN + description);
+                                                + REQUIREDVALUE + requiredValue + MANYFALSE + DESCRIPTION_TOKEN
+                                                + description);
                             } else if (MAP.equalsIgnoreCase(typeValue)) {
                                 stringListItems.append(uniqueDataKeySplit[1].toUpperCase() + DEFAULTVALUE + defaultValue
-                                        + REQUIREDVALUE + requiredValue + MANYTRUE + DESCRIPTION_TOKEN + description);
+                                                + REQUIREDVALUE + requiredValue + MANYTRUE + DESCRIPTION_TOKEN
+                                                + description);
                             }
                             dataMapForJson.put(uniqueDataKey, stringListItems.toString());
                             dataListBuffer.append(uniqueDataKeySplit[1].toUpperCase() + "=[");
                             for (int i = 0; i < 10; i++) {
                                 String findConstraints = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES
-                                        + uniqueDataKeySplit[1] + ".entry_schema.constraints.0.valid_values." + i;
+                                                + uniqueDataKeySplit[1] + ".entry_schema.constraints.0.valid_values."
+                                                + i;
                                 String constraintsValue = map.get(findConstraints);
                                 logger.info(constraintsValue);
                                 boolean ruleCheck = false;
@@ -1178,19 +1535,19 @@ public class MSModelUtils {
                                         ruleCheck = true;
                                         dictionaryNameValRule = dictionaryNameVal.split("#");
                                         dictFromDB = commonClassDao.getDataById(DictionaryData.class, DICTIONARYNAME,
-                                                dictionaryNameValRule[0]);
+                                                        dictionaryNameValRule[0]);
                                     } else {
                                         dictFromDB = commonClassDao.getDataById(DictionaryData.class, DICTIONARYNAME,
-                                                dictionaryName[1]);
+                                                        dictionaryName[1]);
                                     }
                                     if (dictFromDB != null && !dictFromDB.isEmpty()) {
                                         DictionaryData data = (DictionaryData) dictFromDB.get(0);
                                         if (ruleCheck) {
                                             constraintsValue = DICTIONARY + data.getDictionaryUrl() + "@"
-                                                    + data.getDictionaryDataByName() + "&Rule";
+                                                            + data.getDictionaryDataByName() + "&Rule";
                                         } else {
                                             constraintsValue = DICTIONARY + data.getDictionaryUrl() + "@"
-                                                    + data.getDictionaryDataByName();
+                                                            + data.getDictionaryDataByName();
                                         }
                                     }
                                     dataListBuffer.append(constraintsValue + ",");
@@ -1209,9 +1566,9 @@ public class MSModelUtils {
                     }
                 } else {
                     String findUserDefined = DATATYPE + uniqueDataKeySplit[0] + "." + PROPERTIES_KEY + "."
-                            + uniqueDataKeySplit[1] + TYPE;
+                                    + uniqueDataKeySplit[1] + TYPE;
                     String findDescription = DATATYPE + uniqueDataKeySplit[0] + "." + PROPERTIES_KEY + "."
-                            + uniqueDataKeySplit[1] + DESCRIPTION;
+                                    + uniqueDataKeySplit[1] + DESCRIPTION;
                     String userDefinedValue = map.get(findUserDefined);
                     String description = map.get(findDescription);
                     String trimValue = userDefinedValue.substring(userDefinedValue.lastIndexOf('.') + 1);
@@ -1230,8 +1587,15 @@ public class MSModelUtils {
         return dataMapForJson;
     }
 
+    /**
+     * Parses the policy nodes.
+     *
+     * @param map the map
+     * @return the linked hash map
+     * @throws ParserException the parser exception
+     */
     LinkedHashMap<String, LinkedHashMap<String, String>> parsePolicyNodes(Map<String, String> map)
-            throws ParserException {
+                    throws ParserException {
         LinkedHashMap<String, LinkedHashMap<String, String>> mapKey = new LinkedHashMap<>();
         for (String uniqueKey : uniqueKeys) {
             LinkedHashMap<String, String> hm;
@@ -1244,10 +1608,9 @@ public class MSModelUtils {
                         String keyStr = key.substring(key.lastIndexOf('.') + 1);
                         String valueStr = map.get(key);
                         if ("type".equalsIgnoreCase(keyStr) && key.contains("entry_schema.0.type")
-                                || key.contains("entry_schema.type") && valueStr.contains("policy.data.")) {
-                            throw new ParserException(
-                                    "For user defined object type, Please make sure no space between 'type:' and object "
-                                            + valueStr);
+                                        || key.contains("entry_schema.type") && valueStr.contains("policy.data.")) {
+                            throw new ParserException("For user defined object type,"
+                                            + " Please make sure no space between 'type:' and object " + valueStr);
 
                         }
                         if ("type".equals(keyStr)) {
@@ -1278,6 +1641,11 @@ public class MSModelUtils {
         return mapKey;
     }
 
+    /**
+     * Creates the attributes.
+     *
+     * @param mapKey the map key
+     */
     private void createAttributes(LinkedHashMap<String, LinkedHashMap<String, String>> mapKey) {
         StringBuilder attributeStringBuilder = new StringBuilder();
         StringBuilder referenceStringBuilder = new StringBuilder();
@@ -1287,8 +1655,8 @@ public class MSModelUtils {
             String keySetString = entry.getKey();
             LinkedHashMap<String, String> keyValues = mapKey.get(keySetString);
             if (keyValues.get("type") != null && (STRING.equalsIgnoreCase(keyValues.get("type"))
-                    || INTEGER.equalsIgnoreCase(keyValues.get("type"))
-                    || BOOLEAN.equalsIgnoreCase(keyValues.get("type")))) {
+                            || INTEGER.equalsIgnoreCase(keyValues.get("type"))
+                            || BOOLEAN.equalsIgnoreCase(keyValues.get("type")))) {
                 StringBuilder attributeIndividualStringBuilder = new StringBuilder();
                 attributeIndividualStringBuilder.append(keySetString + "=");
                 attributeIndividualStringBuilder.append(keyValues.get("type") + DEFAULTVALUE);
@@ -1322,7 +1690,7 @@ public class MSModelUtils {
                             String trimValue = value.substring(value.lastIndexOf('.') + 1);
                             StringBuilder referenceIndividualStringBuilder = new StringBuilder();
                             referenceIndividualStringBuilder.append(keySetString + "=" + trimValue + MANYTRUE
-                                    + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
+                                            + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
                             referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
                             isDefinedType = true;
                         }
@@ -1331,7 +1699,7 @@ public class MSModelUtils {
                 }
 
                 if (!isDefinedType && LIST.equalsIgnoreCase(keyValues.get("type"))
-                        && (constraints == null || constraints.isEmpty())) {
+                                && (constraints == null || constraints.isEmpty())) {
                     referenceStringBuilder.append(keySetString + "=MANY-true" + ",");
                 }
             } else {
@@ -1344,7 +1712,7 @@ public class MSModelUtils {
                     String trimValue = value.substring(value.lastIndexOf('.') + 1);
                     StringBuilder referenceIndividualStringBuilder = new StringBuilder();
                     referenceIndividualStringBuilder.append(keySetString + "=" + trimValue + MANYFALSE
-                            + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
+                                    + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
                     referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
                 } else {
                     logger.info("keyValues.get(type) is null/empty");
@@ -1357,8 +1725,8 @@ public class MSModelUtils {
                 for (String str : constraints) {
                     if (str.contains(DICTIONARY)) {
                         String[] dictionaryName = str.split(":");
-                        List<Object> dictFromDB =
-                                commonClassDao.getDataById(DictionaryData.class, DICTIONARYNAME, dictionaryName[1]);
+                        List<Object> dictFromDB = commonClassDao.getDataById(DictionaryData.class, DICTIONARYNAME,
+                                        dictionaryName[1]);
                         if (dictFromDB != null && !dictFromDB.isEmpty()) {
                             DictionaryData data = (DictionaryData) dictFromDB.get(0);
                             str = DICTIONARY + data.getDictionaryUrl() + "@" + data.getDictionaryDataByName();
@@ -1369,7 +1737,6 @@ public class MSModelUtils {
                 listBuffer.append("]#");
                 logger.info(listBuffer);
 
-
                 StringBuilder referenceIndividualStringBuilder = new StringBuilder();
                 referenceIndividualStringBuilder.append(keySetString + "=" + keySetString.toUpperCase() + MANYFALSE);
                 referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
@@ -1379,7 +1746,6 @@ public class MSModelUtils {
 
         dataListBuffer.append(listBuffer);
 
-
         logger.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
         logger.info("Whole attribute String is:" + attributeStringBuilder);
         logger.info("Whole reference String is:" + referenceStringBuilder);
@@ -1392,6 +1758,11 @@ public class MSModelUtils {
         this.attributeString = attributeStringBuilder.toString();
     }
 
+    /**
+     * Find node.
+     *
+     * @param map the map
+     */
     @SuppressWarnings("unchecked")
     private void findNode(LinkedHashMap<Object, Object> map) {
 
@@ -1413,6 +1784,11 @@ public class MSModelUtils {
 
     }
 
+    /**
+     * Save nodes.
+     *
+     * @param map the map
+     */
     private void saveNodes(LinkedHashMap<?, ?> map) {
 
         for (Entry<?, ?> entry : map.entrySet()) {
@@ -1425,61 +1801,4 @@ public class MSModelUtils {
             }
         }
     }
-
-    public String getAttributeString() {
-        return attributeString;
-    }
-
-    public void setAttributeString(String attributeString) {
-        this.attributeString = attributeString;
-    }
-
-    public LinkedHashMap<String, Object> getRetmap() {
-        return retmap;
-    }
-
-    public void setRetmap(LinkedHashMap<String, Object> retmap) {
-        this.retmap = retmap;
-    }
-
-    public Map<String, String> getMatchableValues() {
-        return matchableValues;
-    }
-
-    public void setMatchableValues(Map<String, String> matchableValues) {
-        this.matchableValues = matchableValues;
-    }
-
-    public String getReferenceAttributes() {
-        return referenceAttributes;
-    }
-
-    public void setReferenceAttributes(String referenceAttributes) {
-        this.referenceAttributes = referenceAttributes;
-    }
-
-    public String getListConstraints() {
-        return listConstraints;
-    }
-
-    public void setListConstraints(String listConstraints) {
-        this.listConstraints = listConstraints;
-    }
-
-    public String getDataOrderInfo() {
-        return dataOrderInfo;
-    }
-
-    public void setDataOrderInfo(String dataOrderInfo) {
-        this.dataOrderInfo = dataOrderInfo;
-    }
-
-    public String getJsonRuleFormation() {
-        return jsonRuleFormation;
-    }
-
-    public void setJsonRuleFormation(String jsonRuleFormation) {
-        this.jsonRuleFormation = jsonRuleFormation;
-    }
-
 }
index f509abd..5e034d2 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.rest.util;
 
-public class ParserException  extends Exception {
+public class ParserException extends Exception {
     private static final long serialVersionUID = -1166704711958410424L;
 
-    final String message;
-
-    ParserException(String message) {
-        this.message = message;
-    }
-
-    @Override
-    public String getMessage() {
-        return message;
+    public ParserException(String message) {
+        super(message);
     }
 }
\ No newline at end of file
@@ -3,13 +3,14 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
 
 package org.onap.policy.rest.util;
 
+import com.att.research.xacml.api.pap.PDP;
+import com.att.research.xacml.api.pap.PDPGroup;
+import com.att.research.xacml.api.pap.PDPPolicy;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -32,69 +38,56 @@ import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
 
-import com.att.research.xacml.api.pap.PDP;
-import com.att.research.xacml.api.pap.PDPGroup;
-import com.att.research.xacml.api.pap.PDPPolicy;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed {
+public class PdpPolicyContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed {
     private static final long serialVersionUID = 1L;
-    private static final Logger LOGGER = FlexLogger.getLogger(PDPPolicyContainer.class);
+    private static final Logger LOGGER = FlexLogger.getLogger(PdpPolicyContainer.class);
 
-     /**
-     * String identifier of a file's "Id" property.
-     */
     private static final String PROPERTY_ID = "Id";
-
-   /**
-     * String identifier of a file's "name" property.
-     */
     private static final String PROPERTY_NAME = "Name";
-
-    /**
-      * String identifier of a file's "name" property.
-      */
     private static final String PROPERTY_VERSION = "Version";
-     
-    /**
-     * String identifier of a file's "Description" property.
-     */
     private static final String PROPERTY_DESCRIPTION = "Description";
-    
-    /**
-     * String identifier of a file's "IsRoot" property.
-     */
     private static final String PROPERTY_ISROOT = "Root";
 
     /**
      * List of the string identifiers for the available properties.
      */
     private static Collection<String> pDPPolicyProperties;
+
     private final transient Object data;
     private transient List<PDPPolicy> policies;
-    
+
+    /**
+     * Instantiates a new pdp policy container.
+     *
+     * @param data the data
+     */
     @SuppressWarnings("unchecked")
-    public PDPPolicyContainer(Object data) {
+    public PdpPolicyContainer(Object data) {
         super();
         this.data = data;
         if (this.data instanceof PDPGroup) {
-            policies = new ArrayList<> (((PDPGroup) this.data).getPolicies());
+            policies = new ArrayList<>(((PDPGroup) this.data).getPolicies());
         }
         if (this.data instanceof PDP) {
-            policies = new ArrayList<> (((PDP) this.data).getPolicies());
+            policies = new ArrayList<>(((PDP) this.data).getPolicies());
         }
         if (this.data instanceof Set) {
-            policies = new ArrayList<> ((Set<PDPPolicy>)data);
+            policies = new ArrayList<>((Set<PDPPolicy>) data);
         }
         if (this.policies == null) {
             LOGGER.info("NULL policies");
-            throw new NullPointerException("PDPPolicyContainer created with unexpected Object type '" + data.getClass().getName() + "'");
+            throw new NullPointerException("PDPPolicyContainer created with unexpected Object type '"
+                            + data.getClass().getName() + "'");
         }
         this.setContainer(this);
     }
 
+    /**
+     * Next item id.
+     *
+     * @param itemId the item id
+     * @return the object
+     */
     @Override
     public Object nextItemId(Object itemId) {
         if (LOGGER.isTraceEnabled()) {
@@ -104,9 +97,15 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         if (index == -1 || ((index + 1) >= this.policies.size())) {
             return null;
         }
-        return new PDPPolicyItem(this.policies.get(index + 1));
+        return new PdpPolicyItem(this.policies.get(index + 1));
     }
 
+    /**
+     * Prev item id.
+     *
+     * @param itemId the item id
+     * @return the object
+     */
     @Override
     public Object prevItemId(Object itemId) {
         if (LOGGER.isTraceEnabled()) {
@@ -116,9 +115,14 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         if (index <= 0) {
             return null;
         }
-        return new PDPPolicyItem(this.policies.get(index - 1));
+        return new PdpPolicyItem(this.policies.get(index - 1));
     }
 
+    /**
+     * First item id.
+     *
+     * @return the object
+     */
     @Override
     public Object firstItemId() {
         if (LOGGER.isTraceEnabled()) {
@@ -127,9 +131,14 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         if (this.policies.isEmpty()) {
             return null;
         }
-        return new PDPPolicyItem(this.policies.get(0));
+        return new PdpPolicyItem(this.policies.get(0));
     }
 
+    /**
+     * Last item id.
+     *
+     * @return the object
+     */
     @Override
     public Object lastItemId() {
         if (LOGGER.isTraceEnabled()) {
@@ -138,9 +147,15 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         if (this.policies.isEmpty()) {
             return null;
         }
-        return new PDPPolicyItem(this.policies.get(this.policies.size() - 1));
+        return new PdpPolicyItem(this.policies.get(this.policies.size() - 1));
     }
 
+    /**
+     * Checks if is first id.
+     *
+     * @param itemId the item id
+     * @return true, if is first id
+     */
     @Override
     public boolean isFirstId(Object itemId) {
         if (LOGGER.isTraceEnabled()) {
@@ -152,6 +167,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return itemId.equals(this.policies.get(0));
     }
 
+    /**
+     * Checks if is last id.
+     *
+     * @param itemId the item id
+     * @return true, if is last id
+     */
     @Override
     public boolean isLastId(Object itemId) {
         if (LOGGER.isTraceEnabled()) {
@@ -163,16 +184,32 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return itemId.equals(this.policies.get(this.policies.size() - 1));
     }
 
+    /**
+     * Adds the item after.
+     *
+     * @param previousItemId the previous item id
+     * @return the object
+     */
     @Override
     public Object addItemAfter(Object previousItemId) {
         return null;
     }
 
+    /**
+     * Gets the container property ids.
+     *
+     * @return the container property ids
+     */
     @Override
     public Collection<?> getContainerPropertyIds() {
         return pDPPolicyProperties;
     }
 
+    /**
+     * Gets the item ids.
+     *
+     * @return the item ids
+     */
     @Override
     public Collection<?> getItemIds() {
         final Collection<Object> items = new ArrayList<>();
@@ -180,7 +217,30 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return Collections.unmodifiableCollection(items);
     }
 
+    /**
+     * Gets the item ids.
+     *
+     * @param startIndex the start index
+     * @param numberOfItems the number of items
+     * @return the item ids
+     */
+    @Override
+    public List<?> getItemIds(int startIndex, int numberOfItems) {
+        if (LOGGER.isTraceEnabled()) {
+            LOGGER.trace("getItemIds: " + startIndex + " " + numberOfItems);
+        }
+        if (numberOfItems < 0) {
+            throw new IllegalArgumentException();
+        }
+        return this.policies.subList(startIndex, startIndex + numberOfItems);
+    }
 
+    /**
+     * Gets the type.
+     *
+     * @param propertyId the property id
+     * @return the type
+     */
     @Override
     public Class<?> getType(Object propertyId) {
         if (propertyId.equals(PROPERTY_ID)) {
@@ -201,6 +261,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return null;
     }
 
+    /**
+     * Size.
+     *
+     * @return the int
+     */
     @Override
     public int size() {
         if (LOGGER.isTraceEnabled()) {
@@ -209,6 +274,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return this.policies.size();
     }
 
+    /**
+     * Contains id.
+     *
+     * @param itemId the item id
+     * @return true, if successful
+     */
     @Override
     public boolean containsId(Object itemId) {
         if (LOGGER.isTraceEnabled()) {
@@ -217,11 +288,22 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return this.policies.contains(itemId);
     }
 
+    /**
+     * Adds the item.
+     *
+     * @return the object
+     */
     @Override
     public Object addItem() {
         throw new UnsupportedOperationException("Cannot add an empty policy.");
     }
 
+    /**
+     * Removes the item.
+     *
+     * @param itemId the item id
+     * @return true, if successful
+     */
     @Override
     public boolean removeItem(Object itemId) {
         if (LOGGER.isTraceEnabled()) {
@@ -231,34 +313,59 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         StdPDPPolicy pdpPolicy = null;
         try {
-            pdpPolicy = mapper.readValue(itemId.toString() , StdPDPPolicy.class);
-            for(int i = 0; i< policies.size(); i++){
-                if(policies.get(i).getId().equalsIgnoreCase(pdpPolicy.getId())){
+            pdpPolicy = mapper.readValue(itemId.toString(), StdPDPPolicy.class);
+            for (int i = 0; i < policies.size(); i++) {
+                if (policies.get(i).getId().equalsIgnoreCase(pdpPolicy.getId())) {
                     return this.policies.remove(this.policies.get(i));
                 }
             }
         } catch (Exception e) {
-            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While Mapping the Removing Policy from PDP Group to Std Policy"+e);
+            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE
+                            + "Exception Occured While Mapping the Removing Policy from PDP Group to Std Policy" + e);
         }
         return this.policies.remove(itemId);
     }
 
+    /**
+     * Adds the container property.
+     *
+     * @param propertyId the property id
+     * @param type the type
+     * @param defaultValue the default value
+     * @return true, if successful
+     */
     @Override
-    public boolean addContainerProperty(Object propertyId, Class<?> type,
-            Object defaultValue) {
+    public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) {
         return false;
     }
 
+    /**
+     * Removes the container property.
+     *
+     * @param propertyId the property id
+     * @return true, if successful
+     */
     @Override
     public boolean removeContainerProperty(Object propertyId) {
         return false;
     }
 
+    /**
+     * Removes the all items.
+     *
+     * @return true, if successful
+     */
     @Override
     public boolean removeAllItems() {
         return false;
     }
 
+    /**
+     * Index of id.
+     *
+     * @param itemId the item id
+     * @return the int
+     */
     @Override
     public int indexOfId(Object itemId) {
         if (LOGGER.isTraceEnabled()) {
@@ -267,6 +374,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return this.policies.indexOf(itemId);
     }
 
+    /**
+     * Gets the id by index.
+     *
+     * @param index the index
+     * @return the id by index
+     */
     @Override
     public Object getIdByIndex(int index) {
         if (LOGGER.isTraceEnabled()) {
@@ -275,17 +388,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return this.policies.get(index);
     }
 
-    @Override
-    public List<?> getItemIds(int startIndex, int numberOfItems) {
-        if (LOGGER.isTraceEnabled()) {
-            LOGGER.trace("getItemIds: " + startIndex + " " + numberOfItems);
-        }
-        if (numberOfItems < 0) {
-            throw new IllegalArgumentException();
-        }
-        return this.policies.subList(startIndex, startIndex + numberOfItems);
-    }
-
+    /**
+     * Adds the item at.
+     *
+     * @param index the index
+     * @return the object
+     */
     @Override
     public Object addItemAt(int index) {
         if (LOGGER.isTraceEnabled()) {
@@ -294,13 +402,23 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
         return null;
     }
 
-    public class PDPPolicyItem {
+    public class PdpPolicyItem {
         private final PDPPolicy policy;
 
-        public PDPPolicyItem(PDPPolicy itemId) {
+        /**
+         * Instantiates a new PDP policy item.
+         *
+         * @param itemId the item id
+         */
+        public PdpPolicyItem(PDPPolicy itemId) {
             this.policy = itemId;
         }
 
+        /**
+         * Gets the id.
+         *
+         * @return the id
+         */
         public String getId() {
             if (LOGGER.isTraceEnabled()) {
                 LOGGER.trace("getId: " + this.policy);
@@ -308,6 +426,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
             return this.policy.getId();
         }
 
+        /**
+         * Gets the name.
+         *
+         * @return the name
+         */
         public String getName() {
             if (LOGGER.isTraceEnabled()) {
                 LOGGER.trace("getName: " + this.policy);
@@ -315,6 +438,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
             return this.policy.getName();
         }
 
+        /**
+         * Gets the version.
+         *
+         * @return the version
+         */
         public String getVersion() {
             if (LOGGER.isTraceEnabled()) {
                 LOGGER.trace("getVersion: " + this.policy);
@@ -322,6 +450,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
             return this.policy.getVersion();
         }
 
+        /**
+         * Gets the description.
+         *
+         * @return the description
+         */
         public String getDescription() {
             if (LOGGER.isTraceEnabled()) {
                 LOGGER.trace("getDescription: " + this.policy);
@@ -329,6 +462,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
             return this.policy.getDescription();
         }
 
+        /**
+         * Gets the root.
+         *
+         * @return the root
+         */
         public boolean getRoot() {
             if (LOGGER.isTraceEnabled()) {
                 LOGGER.trace("isRoot: " + this.policy);
@@ -336,8 +474,13 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
             return this.policy.isRoot();
         }
 
+        /**
+         * Sets the root.
+         *
+         * @param root the new root
+         */
         public void setRoot(Boolean root) {
-            ((StdPDPPolicy)this.policy).setRoot(root);
+            ((StdPDPPolicy) this.policy).setRoot(root);
         }
 
     }
index 80bb16d..42bee49 100644 (file)
@@ -3,13 +3,14 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
@@ -24,26 +25,24 @@ import java.io.Serializable;
 import java.util.Collection;
 import java.util.List;
 
-
-public interface PolicyContainer extends Serializable{
+public interface PolicyContainer extends Serializable {
 
     public Collection<?> getContainerPropertyIds();
-    
+
     public Collection<?> getItemIds();
 
     public Class<?> getType(Object propertyId);
 
     public int size();
-  
+
     public boolean containsId(Object itemId);
 
     public Object addItem();
-    
+
     public boolean removeItem(Object itemId);
 
-    public boolean addContainerProperty(Object propertyId, Class<?> type,
-            Object defaultValue);
-   
+    public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue);
+
     public boolean removeContainerProperty(Object propertyId);
 
     public boolean removeAllItems();
@@ -63,10 +62,9 @@ public interface PolicyContainer extends Serializable{
         public boolean isLastId(Object itemId);
 
         public Object addItemAfter(Object previousItemId);
-        
+
     }
 
-    
     public interface Indexed extends Ordered {
 
         public int indexOfId(Object itemId);
@@ -74,7 +72,7 @@ public interface PolicyContainer extends Serializable{
         public Object getIdByIndex(int index);
 
         public List<?> getItemIds(int startIndex, int numberOfItems);
-        
+
         public Object addItemAt(int index);
 
         public interface ItemAddEvent extends ItemSetChangeEvent {
@@ -86,9 +84,8 @@ public interface PolicyContainer extends Serializable{
             public int getAddedItemsCount();
         }
 
-     
         public interface ItemRemoveEvent extends ItemSetChangeEvent {
-          
+
             public Object getFirstItemId();
 
             public int getFirstIndex();
@@ -96,23 +93,21 @@ public interface PolicyContainer extends Serializable{
             public int getRemovedItemsCount();
         }
     }
-  
-    public interface ItemSetChangeEvent extends Serializable {
 
+    @FunctionalInterface
+    public interface ItemSetChangeEvent {
         public PolicyContainer getContainer();
     }
 
-    public interface ItemSetChangeListener extends Serializable {
-
+    @FunctionalInterface
+    public interface ItemSetChangeListener {
         public void containerItemSetChange(PolicyContainer.ItemSetChangeEvent event);
     }
 
     public interface ItemSetChangeNotifier extends Serializable {
 
-        public void addItemSetChangeListener(
-                PolicyContainer.ItemSetChangeListener listener);
+        public void addItemSetChangeListener(PolicyContainer.ItemSetChangeListener listener);
 
-        public void removeItemSetChangeListener(
-                PolicyContainer.ItemSetChangeListener listener);
+        public void removeItemSetChangeListener(PolicyContainer.ItemSetChangeListener listener);
     }
 }
index 16e4670..d708301 100644 (file)
@@ -3,13 +3,14 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
@@ -20,7 +21,6 @@
 
 package org.onap.policy.rest.util;
 
-
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.EventObject;
@@ -29,19 +29,18 @@ import java.util.LinkedList;
 import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeEvent;
 import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeListener;
 
-
-
 public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChangeNotifier {
     private static final long serialVersionUID = 1L;
+
     private Collection<PolicyContainer.ItemSetChangeListener> itemSetChangeListeners = null;
     private PolicyContainer container = null;
-    
+
     public PolicyItemSetChangeNotifier() {
         // Empty constructor
     }
-    
-    protected void setContainer(PolicyContainer c) {
-        this.container = c;
+
+    protected void setContainer(PolicyContainer container) {
+        this.container = container;
     }
 
     @Override
@@ -49,7 +48,8 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
         if (getItemSetChangeListeners() == null) {
             setItemSetChangeListeners(new LinkedList<PolicyContainer.ItemSetChangeListener>());
         }
-        getItemSetChangeListeners().add(listener);     }
+        getItemSetChangeListeners().add(listener);
+    }
 
     @Override
     public void removeItemSetChangeListener(ItemSetChangeListener listener) {
@@ -58,8 +58,8 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
         }
     }
 
-    protected static class BaseItemSetChangeEvent extends EventObject implements
-        PolicyContainer.ItemSetChangeEvent, Serializable {
+    protected static class BaseItemSetChangeEvent extends EventObject
+                    implements PolicyContainer.ItemSetChangeEvent, Serializable {
         private static final long serialVersionUID = 1L;
 
         protected BaseItemSetChangeEvent(PolicyContainer source) {
@@ -72,14 +72,14 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
         }
     }
 
-    protected void setItemSetChangeListeners(
-            Collection<PolicyContainer.ItemSetChangeListener> itemSetChangeListeners) {
+    protected void setItemSetChangeListeners(Collection<PolicyContainer.ItemSetChangeListener> itemSetChangeListeners) {
         this.itemSetChangeListeners = itemSetChangeListeners;
     }
+
     protected Collection<PolicyContainer.ItemSetChangeListener> getItemSetChangeListeners() {
         return itemSetChangeListeners;
     }
-  
+
     protected void fireItemSetChange() {
         fireItemSetChange(new BaseItemSetChangeEvent(this.container));
     }
@@ -88,8 +88,7 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
         if (getItemSetChangeListeners() != null) {
             final Object[] l = getItemSetChangeListeners().toArray();
             for (int i = 0; i < l.length; i++) {
-                ((PolicyContainer.ItemSetChangeListener) l[i])
-                        .containerItemSetChange(event);
+                ((PolicyContainer.ItemSetChangeListener) l[i]).containerItemSetChange(event);
             }
         }
     }
index da54b05..6bab919 100644 (file)
@@ -3,13 +3,14 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
@@ -26,9 +27,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
-
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.StringReader;
@@ -42,12 +40,16 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+
 import javax.json.Json;
 import javax.json.JsonException;
 import javax.json.JsonObject;
 import javax.json.JsonReader;
 import javax.json.JsonValue;
 
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.json.JSONArray;
@@ -67,42 +69,55 @@ import org.onap.policy.xacml.util.XACMLPolicyScanner;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-
 @Service
 public class PolicyValidation {
-
     private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidation.class);
 
-    public static final String CONFIG_POLICY = "Config";
-    public static final String ACTION_POLICY = "Action";
-    public static final String DECISION_POLICY = "Decision";
-    public static final String DECISION_POLICY_MS = "Decision_MS";
-    public static final String CLOSEDLOOP_POLICY = "ClosedLoop_Fault";
-    public static final String CLOSEDLOOP_PM = "ClosedLoop_PM";
-    public static final String ENFORCER_CONFIG_POLICY = "Enforcer Config";
-    public static final String MICROSERVICES = "Micro Service";
-    public static final String FIREWALL = "Firewall Config";
-    public static final String OPTIMIZATION="Optimization";
-    public static final String BRMSPARAM = "BRMS_Param";
-    public static final String BRMSRAW = "BRMS_Raw";
-    public static final String HTML_ITALICS_LNBREAK = "</i><br>";
-    public static final String SUCCESS = "success";
-    public static final String EMPTY_COMPONENT_ATTR =
-            "Component Attributes: One or more Fields in Component Attributes is Empty.";
-    public static final String ISREQUIRED = " is required";
-    public static final String SPACESINVALIDCHARS = " : value has spaces or invalid characters</i><br>";
-    private static final String REQUIRED_ATTRIBUTE = "required-true";
+    private static final String ACTION_POLICY = "Action";
+    private static final String BOOLEAN = "boolean";
+    private static final String BRMSPARAM = "BRMS_Param";
+    private static final String BRMSRAW = "BRMS_Raw";
+    private static final String CLOSEDLOOP_PM = "ClosedLoop_PM";
+    private static final String CLOSEDLOOP_POLICY = "ClosedLoop_Fault";
+    private static final String CONFIG_POLICY = "Config";
     private static final String DECISION_MS_MODEL = "MicroService_Model";
+    private static final String DECISION_POLICY = "Decision";
+    private static final String DECISION_POLICY_MS = "Decision_MS";
+    private static final String ENFORCER_CONFIG_POLICY = "Enforcer Config";
+    private static final String FIREWALL = "Firewall Config";
+    private static final String HTML_ITALICS_LNBREAK = "</i><br>";
+    private static final String INTEGER = "integer";
+    private static final String ISREQUIRED = " is required";
+    private static final String JAVA = "java";
+    private static final String LIST = "list";
+    private static final String MAP = "map";
+    private static final String MICROSERVICES = "Micro Service";
+    private static final String MISSING_COMPONENT_ATTRIBUTE_VALUE = "<b>Component Attributes</b>:"
+                    + "<i> has one missing Component Attribute value</i><br>";
+    private static final String MISSING_ATTRIBUTE_VALUE = "<b>Rule Attributes</b>:"
+                    + "<i> has one missing Attribute value</i><br>";
+    private static final String MISSING_COMPONENT_ATTRIBUTE_KEY = "<b>Component Attributes</b>:"
+                    + "<i> has one missing Component Attribute key</i><br>";
+    private static final String OPTIMIZATION = "Optimization";
     private static final String RAW = "Raw";
+    private static final String REQUIRED_ATTRIBUTE = "required-true";
+    private static final String RULE_ALGORITHMS = "<b>Rule Algorithms</b>:<i>";
+    private static final String SELECT_AT_LEAST_ONE_D2_VIRTUALIZED_SERVICES = "<b>D2/Virtualized Services</b>: "
+                    + "<i>Select at least one D2/Virtualized Services";
+    private static final String SPACESINVALIDCHARS = " : value has spaces or invalid characters</i><br>";
+    private static final String STRING = "string";
+    private static final String SUCCESS = "success";
+    private static final String VALUE = "value";
 
     private static Map<String, String> mapAttribute = new HashMap<>();
     private static Map<String, String> jsonRequestMap = new HashMap<>();
     private static List<String> modelRequiredFieldsList = new ArrayList<>();
-    private Set<String> allReqTrueKeys = new HashSet<>();
-    private Set<String> allOptReqTrueKeys = new HashSet<>();
 
     private static CommonClassDao commonClassDao;
 
+    private Set<String> allReqTrueKeys = new HashSet<>();
+    private Set<String> allOptReqTrueKeys = new HashSet<>();
+
     @Autowired
     public PolicyValidation(CommonClassDao commonClassDao) {
         PolicyValidation.commonClassDao = commonClassDao;
@@ -115,7 +130,6 @@ public class PolicyValidation {
         // Empty constructor
     }
 
-
     /**
      * Validate policy.
      *
@@ -148,68 +162,64 @@ public class PolicyValidation {
             }
 
             if (!"API".equals(policyData.getApiflag()) && policyData.getAttributes() != null
-                    && !policyData.getAttributes().isEmpty()) {
+                            && !policyData.getAttributes().isEmpty()) {
                 for (Object attribute : policyData.getAttributes()) {
                     if (attribute instanceof LinkedHashMap<?, ?>) {
-                        String value = null;
+                        String attValue = null;
                         String key = null;
                         if (((LinkedHashMap<?, ?>) attribute).get("key") != null) {
                             key = ((LinkedHashMap<?, ?>) attribute).get("key").toString();
                             if (!PolicyUtils.policySpecialCharWithDashValidator(key).contains(SUCCESS)) {
-                                responseString.append("<b>Attributes or Component Attributes</b>:<i>" + value
-                                        + SPACESINVALIDCHARS);
+                                responseString.append("<b>Attributes or Component Attributes</b>:<i>" + attValue
+                                                + SPACESINVALIDCHARS);
                                 valid = false;
                             }
                         } else {
                             if (CONFIG_POLICY.equals(policyData.getPolicyType())) {
                                 if ("Base".equals(policyData.getConfigPolicyType())) {
-                                    responseString
-                                    .append("<b>Attributes</b>:<i> has one missing Attribute key</i><br>");
+                                    responseString.append(
+                                                    "<b>Attributes</b>:<i> has one missing Attribute key</i><br>");
                                 }
                                 if (BRMSPARAM.equals(policyData.getConfigPolicyType())
-                                        || BRMSRAW.equals(policyData.getConfigPolicyType())) {
-                                    responseString
-                                    .append("<b>Rule Attributes</b>:<i> has one missing Attribute key</i><br>");
+                                                || BRMSRAW.equals(policyData.getConfigPolicyType())) {
+                                    responseString.append(
+                                                    "<b>Rule Attributes</b>:<i> has one missing Attribute key</i><br>");
                                 }
                             } else {
-                                responseString.append(
-                                        "<b>Component Attributes</b>:<i> has one missing Component Attribute key</i><br>");
+                                responseString.append(MISSING_COMPONENT_ATTRIBUTE_KEY);
                             }
                             valid = false;
                         }
-                        if (((LinkedHashMap<?, ?>) attribute).get("value") != null) {
-                            value = ((LinkedHashMap<?, ?>) attribute).get("value").toString();
-                            if (!PolicyUtils.policySpecialCharWithDashValidator(value).contains(SUCCESS)) {
+                        if (((LinkedHashMap<?, ?>) attribute).get(VALUE) != null) {
+                            attValue = ((LinkedHashMap<?, ?>) attribute).get(VALUE).toString();
+                            if (!PolicyUtils.policySpecialCharWithDashValidator(attValue).contains(SUCCESS)) {
                                 if (CONFIG_POLICY.equals(policyData.getPolicyType())) {
                                     if ("Base".equals(policyData.getConfigPolicyType())) {
-                                        responseString.append("<b>Attributes</b>:<i>" + value
-                                                + SPACESINVALIDCHARS);
+                                        responseString.append("<b>Attributes</b>:<i>" + attValue + SPACESINVALIDCHARS);
                                     }
                                     if (BRMSPARAM.equals(policyData.getConfigPolicyType())
-                                            || BRMSRAW.equals(policyData.getConfigPolicyType())) {
-                                        responseString.append("<b>Rule Attributes</b>:<i>" + value
-                                                + SPACESINVALIDCHARS);
+                                                    || BRMSRAW.equals(policyData.getConfigPolicyType())) {
+                                        responseString.append(
+                                                        "<b>Rule Attributes</b>:<i>" + attValue + SPACESINVALIDCHARS);
                                     }
                                 } else {
-                                    responseString.append("<b>Component Attributes</b>:<i>" + value
-                                            + SPACESINVALIDCHARS);
+                                    responseString.append(
+                                                    "<b>Component Attributes</b>:<i>" + attValue + SPACESINVALIDCHARS);
                                 }
                                 valid = false;
                             }
                         } else {
                             if (CONFIG_POLICY.equals(policyData.getPolicyType())) {
                                 if ("Base".equals(policyData.getConfigPolicyType())) {
-                                    responseString
-                                    .append("<b>Attributes</b>:<i> has one missing Attribute value</i><br>");
+                                    responseString.append(
+                                                    "<b>Attributes</b>:<i> has one missing Attribute value</i><br>");
                                 }
                                 if (BRMSPARAM.equals(policyData.getConfigPolicyType())
-                                        || BRMSRAW.equals(policyData.getConfigPolicyType())) {
-                                    responseString.append(
-                                            "<b>Rule Attributes</b>:<i> has one missing Attribute value</i><br>");
+                                                || BRMSRAW.equals(policyData.getConfigPolicyType())) {
+                                    responseString.append(MISSING_ATTRIBUTE_VALUE);
                                 }
                             } else {
-                                responseString.append(
-                                        "<b>Component Attributes</b>:<i> has one missing Component Attribute value</i><br>");
+                                responseString.append(MISSING_COMPONENT_ATTRIBUTE_VALUE);
                             }
                             valid = false;
                         }
@@ -219,25 +229,24 @@ public class PolicyValidation {
 
             // Decision Policy Attributes Validation
             if (!"API".equals(policyData.getApiflag()) && policyData.getSettings() != null
-                    && !policyData.getSettings().isEmpty()) {
+                            && !policyData.getSettings().isEmpty()) {
                 for (Object attribute : policyData.getAttributes()) {
                     if (attribute instanceof LinkedHashMap<?, ?>) {
                         String value = null;
                         if (((LinkedHashMap<?, ?>) attribute).get("key") == null) {
-                            responseString
-                            .append("<b>Settings Attributes</b>:<i> has one missing Attribute key</i><br>");
+                            responseString.append(
+                                            "<b>Settings Attributes</b>:<i> has one missing Attribute key</i><br>");
                             valid = false;
                         }
-                        if (((LinkedHashMap<?, ?>) attribute).get("value") != null) {
-                            value = ((LinkedHashMap<?, ?>) attribute).get("value").toString();
+                        if (((LinkedHashMap<?, ?>) attribute).get(VALUE) != null) {
+                            value = ((LinkedHashMap<?, ?>) attribute).get(VALUE).toString();
                             if (!PolicyUtils.policySpecialCharValidator(value).contains(SUCCESS)) {
-                                responseString.append("<b>Settings Attributes</b>:<i>" + value
-                                        + SPACESINVALIDCHARS);
+                                responseString.append("<b>Settings Attributes</b>:<i>" + value + SPACESINVALIDCHARS);
                                 valid = false;
                             }
                         } else {
-                            responseString
-                            .append("<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>");
+                            responseString.append(
+                                            "<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>");
                             valid = false;
                         }
                     }
@@ -245,31 +254,28 @@ public class PolicyValidation {
             }
 
             if (!"API".equals(policyData.getApiflag()) && policyData.getRuleAlgorithmschoices() != null
-                    && !policyData.getRuleAlgorithmschoices().isEmpty()) {
+                            && !policyData.getRuleAlgorithmschoices().isEmpty()) {
                 for (Object attribute : policyData.getRuleAlgorithmschoices()) {
                     if (attribute instanceof LinkedHashMap<?, ?>) {
                         String label = ((LinkedHashMap<?, ?>) attribute).get("id").toString();
                         if (((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField1") == null) {
-                            responseString.append(
-                                    "<b>Rule Algorithms</b>:<i>" + label + " : Field 1 value is not selected</i><br>");
+                            responseString.append(RULE_ALGORITHMS + label + " : Field 1 value is not selected</i><br>");
                             valid = false;
                         }
                         if (((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmCombo") == null) {
-                            responseString.append(
-                                    "<b>Rule Algorithms</b>:<i>" + label + " : Field 2 value is not selected</i><br>");
+                            responseString.append(RULE_ALGORITHMS + label + " : Field 2 value is not selected</i><br>");
                             valid = false;
                         }
                         if (((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField2") != null) {
-                            String value =
-                                    ((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField2").toString();
+                            String value = ((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField2")
+                                            .toString();
                             if (!PolicyUtils.policySpecialCharValidator(value).contains(SUCCESS)) {
-                                responseString.append("<b>Rule Algorithms</b>:<i>" + label
-                                        + " : Field 3 value has special characters</i><br>");
+                                responseString.append(RULE_ALGORITHMS + label
+                                                + " : Field 3 value has special characters</i><br>");
                                 valid = false;
                             }
                         } else {
-                            responseString
-                            .append("<b>Rule Algorithms</b>:<i>" + label + " : Field 3 value is empty</i><br>");
+                            responseString.append(RULE_ALGORITHMS + label + " : Field 3 value is empty</i><br>");
                             valid = false;
                         }
                     }
@@ -278,14 +284,15 @@ public class PolicyValidation {
 
             if (CONFIG_POLICY.equalsIgnoreCase(policyData.getPolicyType())) {
                 if ("Base".equals(policyData.getConfigPolicyType())
-                        || CLOSEDLOOP_POLICY.equals(policyData.getConfigPolicyType())
-                        || CLOSEDLOOP_PM.equals(policyData.getConfigPolicyType())
-                        || ENFORCER_CONFIG_POLICY.equals(policyData.getConfigPolicyType())
-                        || MICROSERVICES.equals(policyData.getConfigPolicyType())
-                        || OPTIMIZATION.equals(policyData.getConfigPolicyType())) {
+                                || CLOSEDLOOP_POLICY.equals(policyData.getConfigPolicyType())
+                                || CLOSEDLOOP_PM.equals(policyData.getConfigPolicyType())
+                                || ENFORCER_CONFIG_POLICY.equals(policyData.getConfigPolicyType())
+                                || MICROSERVICES.equals(policyData.getConfigPolicyType())
+                                || OPTIMIZATION.equals(policyData.getConfigPolicyType())) {
 
                     if (!Strings.isNullOrEmpty(policyData.getOnapName())) {
-                        String onapNameValidate = PolicyUtils.policySpecialCharWithDashValidator(policyData.getOnapName());
+                        String onapNameValidate = PolicyUtils
+                                        .policySpecialCharWithDashValidator(policyData.getOnapName());
                         if (!onapNameValidate.contains(SUCCESS)) {
                             responseString.append("<b>OnapName</b>:<i>" + onapNameValidate + HTML_ITALICS_LNBREAK);
                             valid = false;
@@ -357,25 +364,25 @@ public class PolicyValidation {
                         if (configType != null) {
                             if ("JSON".equals(configType)) {
                                 if (!PolicyUtils.isJSONValid(configBodyData)) {
-                                    responseString
-                                    .append("Config Body: JSON Content is not valid" + HTML_ITALICS_LNBREAK);
+                                    responseString.append(
+                                                    "Config Body: JSON Content is not valid" + HTML_ITALICS_LNBREAK);
                                     valid = false;
                                 }
                             } else if ("XML".equals(configType)) {
                                 if (!PolicyUtils.isXMLValid(configBodyData)) {
-                                    responseString.append(
-                                            "Config Body: XML Content data is not valid" + HTML_ITALICS_LNBREAK);
+                                    responseString.append("Config Body: XML Content data is not valid"
+                                                    + HTML_ITALICS_LNBREAK);
                                     valid = false;
                                 }
                             } else if ("PROPERTIES".equals(configType)) {
                                 if (!PolicyUtils.isPropValid(configBodyData) || "".equals(configBodyData)) {
-                                    responseString
-                                    .append("Config Body: Property data is not valid" + HTML_ITALICS_LNBREAK);
+                                    responseString.append(
+                                                    "Config Body: Property data is not valid" + HTML_ITALICS_LNBREAK);
                                     valid = false;
                                 }
                             } else if ("OTHER".equals(configType) && ("".equals(configBodyData))) {
-                                responseString
-                                .append("Config Body: Config Body Should not be Empty" + HTML_ITALICS_LNBREAK);
+                                responseString.append(
+                                                "Config Body: Config Body Should not be Empty" + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             }
                         }
@@ -397,14 +404,14 @@ public class PolicyValidation {
                         valid = false;
                     }
                     if (policyData.getSecurityZone() == null || policyData.getSecurityZone().isEmpty()) {
-                        responseString
-                        .append("<b>Security Zone</b>:<i> Security Zone is required" + HTML_ITALICS_LNBREAK);
+                        responseString.append(
+                                        "<b>Security Zone</b>:<i> Security Zone is required" + HTML_ITALICS_LNBREAK);
                         valid = false;
                     }
                 }
                 // Validate BRMS_Param Policy Data
                 if (BRMSPARAM.equalsIgnoreCase(policyData.getConfigPolicyType())
-                        && Strings.isNullOrEmpty(policyData.getRuleName())) {
+                                && Strings.isNullOrEmpty(policyData.getRuleName())) {
                     responseString.append("<b>BRMS Template</b>:<i>BRMS Template is required" + HTML_ITALICS_LNBREAK);
                     valid = false;
                 }
@@ -415,8 +422,8 @@ public class PolicyValidation {
 
                         // If there are any error other than Annotations then this is not Valid
                         if (message.contains("[ERR")) {
-                            responseString.append(
-                                    "<b>Raw Rule Validate</b>:<i>Raw Rule has error" + message + HTML_ITALICS_LNBREAK);
+                            responseString.append("<b>Raw Rule Validate</b>:<i>Raw Rule has error" + message
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                     } else {
@@ -427,17 +434,17 @@ public class PolicyValidation {
                 // Validate ClosedLoop_PM Policy Data
                 if (CLOSEDLOOP_PM.equalsIgnoreCase(policyData.getConfigPolicyType())) {
                     try {
-                        if (Strings.isNullOrEmpty(
-                                policyData.getServiceTypePolicyName().get("serviceTypePolicyName").toString())) {
+                        if (Strings.isNullOrEmpty(policyData.getServiceTypePolicyName().get("serviceTypePolicyName")
+                                        .toString())) {
                             responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required"
-                                    + HTML_ITALICS_LNBREAK);
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
 
                     } catch (Exception e) {
                         LOGGER.error("ERROR in ClosedLoop_PM PolicyName", e);
                         responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required"
-                                + HTML_ITALICS_LNBREAK);
+                                        + HTML_ITALICS_LNBREAK);
                         valid = false;
                     }
 
@@ -451,11 +458,9 @@ public class PolicyValidation {
                                 valid = false;
                             }
                         }
-                        if ((pmBody.isGamma() || pmBody.isMcr() || pmBody.isTrinity() || pmBody.isvDNS()
-                                || pmBody.isvUSP()) != true) {
-                            responseString
-                            .append("<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services"
-                                    + HTML_ITALICS_LNBREAK);
+                        if (!pmBody.isGamma() && !pmBody.isMcr() && !pmBody.isTrinity() && !pmBody.isvDNS()
+                                        && !pmBody.isvUSP()) {
+                            responseString.append(SELECT_AT_LEAST_ONE_D2_VIRTUALIZED_SERVICES + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (pmBody.getGeoLink() != null && !pmBody.getGeoLink().isEmpty()) {
@@ -473,16 +478,17 @@ public class PolicyValidation {
                                     String attributeValidate = PolicyUtils.policySpecialCharValidator(value);
                                     if (!attributeValidate.contains(SUCCESS)) {
                                         responseString.append("<b>Attributes</b>:<i>" + key
-                                                + " : value has spaces or invalid characters" + HTML_ITALICS_LNBREAK);
+                                                        + " : value has spaces or invalid characters"
+                                                        + HTML_ITALICS_LNBREAK);
                                         valid = false;
                                     }
                                 }
                             }
                         }
                     } else {
-                        responseString
-                        .append("<b>D2/Virtualized Services</b>:<i>Select atleast one D2/Virtualized Services"
-                                + HTML_ITALICS_LNBREAK);
+                        responseString.append(
+                                        "<b>D2/Virtualized Services</b>:<i>Select atleast one D2/Virtualized Services"
+                                                        + HTML_ITALICS_LNBREAK);
                         valid = false;
                     }
                 }
@@ -497,38 +503,40 @@ public class PolicyValidation {
                                 String apiCondition = (String) json.get("conditions");
                                 if (Strings.isNullOrEmpty(apiCondition)) {
                                     responseString.append("<b>Conditions</b>: <i>Select At least one Condition"
-                                            + HTML_ITALICS_LNBREAK);
+                                                    + HTML_ITALICS_LNBREAK);
                                     return responseString;
                                 }
                             } else {
-                                responseString
-                                .append("<b>Conditions</b>: <i>There were no conditions provided in configBody json"
-                                        + HTML_ITALICS_LNBREAK);
+                                responseString.append("<b>Conditions</b>:"
+                                                + " <i>There were no conditions provided in configBody json"
+                                                + HTML_ITALICS_LNBREAK);
                                 return responseString;
                             }
                         } else {
                             if (policyData.getTrapDatas().getTrap1() != null) {
                                 if (policyData.getClearTimeOut() == null) {
-                                    responseString.append(
-                                            "<b>Trigger Clear TimeOut</b>: <i>Trigger Clear TimeOut is required when atleast One Trigger Signature is enabled</i><br>");
+                                    responseString.append("<b>Trigger Clear TimeOut</b>: "
+                                                    + "<i>Trigger Clear TimeOut is required when at "
+                                                    + "least One Trigger Signature is enabled</i><br>");
                                     valid = false;
                                 }
                                 if (policyData.getTrapMaxAge() == null) {
-                                    responseString.append(
-                                            "<b>Trap Max Age</b>: <i>Trap Max Age is required when atleast One Trigger Signature is enabled</i><br>");
+                                    responseString.append("<b>Trap Max Age</b>: <i>Trap Max Age is required when at "
+                                                    + "least One Trigger Signature is enabled</i><br>");
                                     valid = false;
                                 }
                             }
                             if (policyData.getFaultDatas().getTrap1() != null
-                                    && policyData.getVerificationclearTimeOut() == null) {
+                                            && policyData.getVerificationclearTimeOut() == null) {
                                 responseString.append(
-                                        "<b>Fault Clear TimeOut</b>: <i>Fault Clear TimeOut is required when atleast One Fault Signature is enabled</i><br>");
+                                                "<b>Fault Clear TimeOut</b>: <i>Fault Clear TimeOut is required when at"
+                                                                + "least One Fault Signature is enabled</i><br>");
                                 valid = false;
                             }
                         }
 
-                        ClosedLoopFaultBody faultBody =
-                                mapper.readValue(policyData.getJsonBody(), ClosedLoopFaultBody.class);
+                        ClosedLoopFaultBody faultBody = mapper.readValue(policyData.getJsonBody(),
+                                        ClosedLoopFaultBody.class);
                         if (faultBody.getEmailAddress() != null && !faultBody.getEmailAddress().isEmpty()) {
                             String result = emailValidation(faultBody.getEmailAddress(), responseString.toString());
                             if (!SUCCESS.equals(result)) {
@@ -537,26 +545,24 @@ public class PolicyValidation {
                             }
                         }
                         if (!(faultBody.isGamma() || faultBody.isMcr() || faultBody.isTrinity() || faultBody.isvDNS()
-                                || faultBody.isvUSP())) {
-                            responseString
-                            .append("<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services"
-                                    + HTML_ITALICS_LNBREAK);
+                                        || faultBody.isvUSP())) {
+                            responseString.append(SELECT_AT_LEAST_ONE_D2_VIRTUALIZED_SERVICES + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getActions() == null || faultBody.getActions().isEmpty()) {
-                            responseString
-                            .append("<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
+                            responseString.append(
+                                            "<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getClosedLoopPolicyStatus() == null
-                                || faultBody.getClosedLoopPolicyStatus().isEmpty()) {
-                            responseString.append(
-                                    "<b>Policy Status</b>: <i>Policy Status is required" + HTML_ITALICS_LNBREAK);
+                                        || faultBody.getClosedLoopPolicyStatus().isEmpty()) {
+                            responseString.append("<b>Policy Status</b>: <i>Policy Status is required"
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getConditions() == null) {
-                            responseString.append(
-                                    "<b>Conditions</b>: <i>Select At least one Condition" + HTML_ITALICS_LNBREAK);
+                            responseString.append("<b>Conditions</b>: <i>Select At least one Condition"
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getGeoLink() != null && !faultBody.getGeoLink().isEmpty()) {
@@ -567,28 +573,28 @@ public class PolicyValidation {
                             }
                         }
                         if (faultBody.getAgingWindow() == 0) {
-                            responseString
-                            .append("<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
+                            responseString.append(
+                                            "<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getTimeInterval() == 0) {
-                            responseString.append(
-                                    "<b>Time Interval</b>: <i>Time Interval is required" + HTML_ITALICS_LNBREAK);
+                            responseString.append("<b>Time Interval</b>: <i>Time Interval is required"
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getRetrys() == 0) {
                             responseString.append("<b>Number of Retries</b>: <i>Number of Retries is required"
-                                    + HTML_ITALICS_LNBREAK);
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getTimeOutvPRO() == 0) {
-                            responseString.append(
-                                    "<b>APP-C Timeout</b>: <i>APP-C Timeout is required" + HTML_ITALICS_LNBREAK);
+                            responseString.append("<b>APP-C Timeout</b>: <i>APP-C Timeout is required"
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getTimeOutRuby() == 0) {
-                            responseString
-                            .append("<b>TimeOutRuby</b>: <i>TimeOutRuby is required" + HTML_ITALICS_LNBREAK);
+                            responseString.append(
+                                            "<b>TimeOutRuby</b>: <i>TimeOutRuby is required" + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (faultBody.getVnfType() == null || faultBody.getVnfType().isEmpty()) {
@@ -596,31 +602,31 @@ public class PolicyValidation {
                             valid = false;
                         }
                     } else {
-                        responseString
-                        .append("<b>D2/Virtualized Services</b>: <i>Select atleast one D2/Virtualized Services"
-                                + HTML_ITALICS_LNBREAK);
-                        responseString
-                        .append("<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
-                        responseString
-                        .append("<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
-                        responseString
-                        .append("<b>Policy Status</b>: <i>Policy Status is required" + HTML_ITALICS_LNBREAK);
-                        responseString
-                        .append("<b>Conditions</b>: <i>Select Atleast one Condition" + HTML_ITALICS_LNBREAK);
+                        responseString.append(
+                                        "<b>D2/Virtualized Services</b>: <i>Select atleast one D2/Virtualized Services"
+                                                        + HTML_ITALICS_LNBREAK);
+                        responseString.append(
+                                        "<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
+                        responseString.append(
+                                        "<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
+                        responseString.append(
+                                        "<b>Policy Status</b>: <i>Policy Status is required" + HTML_ITALICS_LNBREAK);
+                        responseString.append(
+                                        "<b>Conditions</b>: <i>Select Atleast one Condition" + HTML_ITALICS_LNBREAK);
                         responseString.append("<b>PEP Name</b>: <i>PEP Name is required" + HTML_ITALICS_LNBREAK);
                         responseString.append("<b>PEP Action</b>: <i>PEP Action is required" + HTML_ITALICS_LNBREAK);
-                        responseString
-                        .append("<b>Time Interval</b>: <i>Time Interval is required" + HTML_ITALICS_LNBREAK);
                         responseString.append(
-                                "<b>Number of Retries</b>: <i>Number of Retries is required" + HTML_ITALICS_LNBREAK);
-                        responseString
-                        .append("<b>APP-C Timeout</b>: <i>APP-C Timeout is required" + HTML_ITALICS_LNBREAK);
+                                        "<b>Time Interval</b>: <i>Time Interval is required" + HTML_ITALICS_LNBREAK);
+                        responseString.append("<b>Number of Retries</b>: <i>Number of Retries is required"
+                                        + HTML_ITALICS_LNBREAK);
+                        responseString.append(
+                                        "<b>APP-C Timeout</b>: <i>APP-C Timeout is required" + HTML_ITALICS_LNBREAK);
                         responseString.append("<b>TimeOutRuby</b>: <i>TimeOutRuby is required" + HTML_ITALICS_LNBREAK);
                         responseString.append("<b>Vnf Type</b>: <i>Vnf Type is required" + HTML_ITALICS_LNBREAK);
                         valid = false;
                     }
                 }
-                
+
                 // Validate MicroService Policy Data
                 if (MICROSERVICES.equals(policyData.getConfigPolicyType())) {
                     boolean tmpValid = validateMsModel(policyData, responseString);
@@ -630,7 +636,7 @@ public class PolicyValidation {
                 }
 
                 // Validate Optimization Policy Data
-                if (OPTIMIZATION.equals(policyData.getConfigPolicyType())){
+                if (OPTIMIZATION.equals(policyData.getConfigPolicyType())) {
                     boolean tmpValid = validateOptimization(policyData, responseString);
                     if (!tmpValid) {
                         valid = false;
@@ -639,7 +645,7 @@ public class PolicyValidation {
             }
 
             if ((DECISION_POLICY.equalsIgnoreCase(policyData.getPolicyType()))
-                    || (DECISION_POLICY_MS.equalsIgnoreCase(policyData.getPolicyType()))) {
+                            || (DECISION_POLICY_MS.equalsIgnoreCase(policyData.getPolicyType()))) {
                 if (!RAW.equalsIgnoreCase(policyData.getRuleProvider())) {
                     if (!Strings.isNullOrEmpty(policyData.getOnapName())) {
                         String onapNameValidate = PolicyUtils.policySpecialCharValidator(policyData.getOnapName());
@@ -653,7 +659,8 @@ public class PolicyValidation {
                     }
                 }
                 if (RAW.equalsIgnoreCase(policyData.getRuleProvider())) {
-                    Object policy = XACMLPolicyScanner.readPolicy(new ByteArrayInputStream(StringEscapeUtils.unescapeXml(policyData.getRawXacmlPolicy()).getBytes(StandardCharsets.UTF_8)));
+                    Object policy = XACMLPolicyScanner.readPolicy(new ByteArrayInputStream(StringEscapeUtils
+                                    .unescapeXml(policyData.getRawXacmlPolicy()).getBytes(StandardCharsets.UTF_8)));
                     if (!(policy instanceof PolicySetType || policy instanceof PolicyType)) {
                         responseString.append("Raw XACML: The XACML Content is not valid" + HTML_ITALICS_LNBREAK);
                         valid = false;
@@ -690,7 +697,7 @@ public class PolicyValidation {
                             valid = false;
                         }
                         if (!policyData.getRainyday().getTreatmentTableChoices().isEmpty()
-                                && policyData.getRainyday().getTreatmentTableChoices() != null) {
+                                        && policyData.getRainyday().getTreatmentTableChoices() != null) {
 
                             for (Object treatmentMap : policyData.getRainyday().getTreatmentTableChoices()) {
                                 String errorCode = null;
@@ -706,20 +713,20 @@ public class PolicyValidation {
 
                                 }
                                 if (Strings.isNullOrEmpty(errorCode) && Strings.isNullOrEmpty(treatment)) {
-                                    responseString.append(
-                                            "Rainy Day <b>Error Code</b> and <b>Desired Treatment</b> cannot be empty<br>");
+                                    responseString.append("Rainy Day <b>Error Code</b> and "
+                                                    + "<b>Desired Treatment</b> cannot be empty<br>");
                                     valid = false;
                                     break;
                                 }
                                 if (Strings.isNullOrEmpty(errorCode)) {
-                                    responseString.append(
-                                            "Rainy Day <b>Error Code</b> is Required for each Desired Treatment<br>");
+                                    responseString.append("Rainy Day <b>Error Code</b> is Required "
+                                                    + "for each Desired Treatment<br>");
                                     valid = false;
                                     break;
                                 }
                                 if (Strings.isNullOrEmpty(treatment)) {
-                                    responseString.append(
-                                            "Rainy Day <b>Desired Treatment</b> is Required for each Error Code<br>");
+                                    responseString.append("Rainy Day <b>Desired Treatment"
+                                                    + "</b> is Required for each Error Code<br>");
                                     valid = false;
                                     break;
                                 }
@@ -733,8 +740,8 @@ public class PolicyValidation {
                 }
 
                 if ("GUARD_YAML".equals(policyData.getRuleProvider())
-                        || "GUARD_BL_YAML".equals(policyData.getRuleProvider())
-                        || "GUARD_MIN_MAX".equals(policyData.getRuleProvider())) {
+                                || "GUARD_BL_YAML".equals(policyData.getRuleProvider())
+                                || "GUARD_MIN_MAX".equals(policyData.getRuleProvider())) {
                     if (policyData.getYamlparams() == null) {
                         responseString.append("<b> Guard Params are Required </b>" + HTML_ITALICS_LNBREAK);
                         valid = false;
@@ -748,13 +755,13 @@ public class PolicyValidation {
                             valid = false;
                         }
                         if (Strings.isNullOrEmpty(policyData.getYamlparams().getGuardActiveStart())) {
-                            responseString.append(
-                                    "Guard Params <b>Guard Active Start</b> is Required " + HTML_ITALICS_LNBREAK);
+                            responseString.append("Guard Params <b>Guard Active Start</b> is Required "
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if (Strings.isNullOrEmpty(policyData.getYamlparams().getGuardActiveEnd())) {
-                            responseString
-                            .append("Guard Params <b>Guard Active End</b> is Required " + HTML_ITALICS_LNBREAK);
+                            responseString.append(
+                                            "Guard Params <b>Guard Active End</b> is Required " + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                         if ("GUARD_YAML".equals(policyData.getRuleProvider())) {
@@ -762,22 +769,22 @@ public class PolicyValidation {
                                 responseString.append(" Guard Params <b>Limit</b> is Required " + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             } else if (!PolicyUtils.isInteger(policyData.getYamlparams().getLimit())) {
-                                responseString
-                                .append(" Guard Params <b>Limit</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+                                responseString.append(
+                                                " Guard Params <b>Limit</b> Should be Integer " + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             }
                             if (Strings.isNullOrEmpty(policyData.getYamlparams().getTimeWindow())) {
-                                responseString
-                                .append("Guard Params <b>Time Window</b> is Required" + HTML_ITALICS_LNBREAK);
+                                responseString.append(
+                                                "Guard Params <b>Time Window</b> is Required" + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             } else if (!PolicyUtils.isInteger(policyData.getYamlparams().getTimeWindow())) {
-                                responseString.append(
-                                        " Guard Params <b>Time Window</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+                                responseString.append(" Guard Params <b>Time Window</b> Should be Integer "
+                                                + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             }
                             if (Strings.isNullOrEmpty(policyData.getYamlparams().getTimeUnits())) {
-                                responseString
-                                .append("Guard Params <b>Time Units</b> is Required" + HTML_ITALICS_LNBREAK);
+                                responseString.append(
+                                                "Guard Params <b>Time Units</b> is Required" + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             }
                         } else if ("GUARD_MIN_MAX".equals(policyData.getRuleProvider())) {
@@ -785,32 +792,32 @@ public class PolicyValidation {
                                 responseString.append(" Guard Params <b>Min</b> is Required " + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             } else if (!PolicyUtils.isInteger(policyData.getYamlparams().getMin())) {
-                                responseString
-                                .append(" Guard Params <b>Min</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+                                responseString.append(
+                                                " Guard Params <b>Min</b> Should be Integer " + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             }
                             if (Strings.isNullOrEmpty(policyData.getYamlparams().getMax())) {
                                 responseString.append(" Guard Params <b>Max</b> is Required " + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             } else if (!PolicyUtils.isInteger(policyData.getYamlparams().getMax())) {
-                                responseString
-                                .append(" Guard Params <b>Max</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+                                responseString.append(
+                                                " Guard Params <b>Max</b> Should be Integer " + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             }
                         } else if ("GUARD_BL_YAML".equals(policyData.getRuleProvider())
-                                && "Use Manual Entry".equals(policyData.getBlackListEntryType())) {
+                                        && "Use Manual Entry".equals(policyData.getBlackListEntryType())) {
 
                             if (policyData.getYamlparams().getBlackList() == null
-                                    || policyData.getYamlparams().getBlackList().isEmpty()) {
-                                responseString
-                                .append(" Guard Params <b>BlackList</b> is Required " + HTML_ITALICS_LNBREAK);
+                                            || policyData.getYamlparams().getBlackList().isEmpty()) {
+                                responseString.append(
+                                                " Guard Params <b>BlackList</b> is Required " + HTML_ITALICS_LNBREAK);
                                 valid = false;
                             } else {
                                 for (String blackList : policyData.getYamlparams().getBlackList()) {
-                                    if (blackList == null
-                                            || !(SUCCESS.equals(PolicyUtils.policySpecialCharValidator(blackList)))) {
+                                    if (blackList == null || !(SUCCESS
+                                                    .equals(PolicyUtils.policySpecialCharValidator(blackList)))) {
                                         responseString.append(" Guard Params <b>BlackList</b> Should be valid String"
-                                                + HTML_ITALICS_LNBREAK);
+                                                        + HTML_ITALICS_LNBREAK);
                                         valid = false;
                                         break;
                                     }
@@ -829,21 +836,21 @@ public class PolicyValidation {
                         valid = false;
                     }
                 } else {
-                    responseString.append(
-                            "<b>ActionPerformer</b>:<i> ActionPerformer Should not be empty" + HTML_ITALICS_LNBREAK);
+                    responseString.append("<b>ActionPerformer</b>:<i> ActionPerformer Should not be empty"
+                                    + HTML_ITALICS_LNBREAK);
                     valid = false;
                 }
 
                 if (!Strings.isNullOrEmpty(policyData.getActionAttributeValue())) {
-                    String actionAttribute =
-                            PolicyUtils.policySpecialCharValidator(policyData.getActionAttributeValue());
+                    String actionAttribute = PolicyUtils
+                                    .policySpecialCharValidator(policyData.getActionAttributeValue());
                     if (!actionAttribute.contains(SUCCESS)) {
                         responseString.append("<b>ActionAttribute</b>:<i>" + actionAttribute + HTML_ITALICS_LNBREAK);
                         valid = false;
                     }
                 } else {
-                    responseString.append(
-                            "<b>ActionAttribute</b>:<i> ActionAttribute Should not be empty" + HTML_ITALICS_LNBREAK);
+                    responseString.append("<b>ActionAttribute</b>:<i> ActionAttribute Should not be empty"
+                                    + HTML_ITALICS_LNBREAK);
                     valid = false;
                 }
             }
@@ -853,7 +860,7 @@ public class PolicyValidation {
                 if (valid) {
                     if (commonClassDao != null) {
                         List<Object> spData = commonClassDao.getDataById(SafePolicyWarning.class, "riskType",
-                                policyData.getRiskType());
+                                        policyData.getRiskType());
                         if (!spData.isEmpty()) {
                             SafePolicyWarning safePolicyWarningData = (SafePolicyWarning) spData.get(0);
                             value = "<b>Message</b>:<i>" + safePolicyWarningData.getMessage() + "</i>";
@@ -890,14 +897,14 @@ public class PolicyValidation {
     private MicroServiceModels getAttributeObject(String name, String version) {
         MicroServiceModels workingModel = null;
         try {
-            List<Object> microServiceModelsData =
-                    commonClassDao.getDataById(MicroServiceModels.class, "modelName:version", name + ":" + version);
+            List<Object> microServiceModelsData = commonClassDao.getDataById(MicroServiceModels.class,
+                            "modelName:version", name + ":" + version);
             if (microServiceModelsData != null) {
                 workingModel = (MicroServiceModels) microServiceModelsData.get(0);
             }
         } catch (Exception e) {
             String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Template.  The template name, " + name
-                    + " was not found in the dictionary: ";
+                            + " was not found in the dictionary: ";
             LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message + e);
             return null;
         }
@@ -905,16 +912,17 @@ public class PolicyValidation {
         return workingModel;
     }
 
-    private OptimizationModels getOptimizationModelData(String name, String version) {  
+    private OptimizationModels getOptimizationModelData(String name, String version) {
         OptimizationModels workingModel = null;
-        try{
-            List<Object> optimizationModelsData = commonClassDao.getDataById(OptimizationModels.class, "modelName:version", name+":"+version);
-            if(optimizationModelsData != null){
+        try {
+            List<Object> optimizationModelsData = commonClassDao.getDataById(OptimizationModels.class,
+                            "modelName:version", name + ":" + version);
+            if (optimizationModelsData != null) {
                 workingModel = (OptimizationModels) optimizationModelsData.get(0);
             }
-        }catch(Exception e){
-            String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Template.  The template name, " 
-                    + name + " was not found in the dictionary: ";
+        } catch (Exception e) {
+            String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Template.  The template name, " + name
+                            + " was not found in the dictionary: ";
             LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message + e);
             return null;
         }
@@ -933,8 +941,9 @@ public class PolicyValidation {
                 pullJsonKeyPairs(value); // RECURSIVE CALL
             } else {
                 if (value.isArray()) {
-                    String newValue = StringUtils.replaceEach(value.toString(), new String[] {"[", "]", "\""},
-                            new String[] {"", "", ""});
+                    String newValue = StringUtils.replaceEach(value.toString(), new String[]
+                        { "[", "]", "\"" }, new String[]
+                        { "", "", "" });
                     mapAttribute.put(key, newValue);
                 } else {
                     mapAttribute.put(key, value.toString().trim());
@@ -958,11 +967,11 @@ public class PolicyValidation {
                 try {
                     String valueStr = value.toString();
                     String stringValue = valueStr.substring(valueStr.indexOf('[') + 1, valueStr.lastIndexOf(']'));
-                    
+
                     if (stringValue.isEmpty()) {
                         stringValue = "{\"test\":\"test\"}";
                     }
-                    
+
                     ObjectMapper mapper = new ObjectMapper();
                     JsonNode newValue = mapper.readTree(stringValue);
                     jsonRequestMap.put(key.trim(), value.toString().trim());
@@ -981,10 +990,9 @@ public class PolicyValidation {
         try (JsonReader jsonReader = Json.createReader(new StringReader(value))) {
             return jsonReader.readObject();
         } catch (JsonException | IllegalStateException e) {
-            LOGGER.info(
-                    XACMLErrorConstants.ERROR_DATA_ISSUE
-                    + "Improper JSON format... may or may not cause issues in validating the policy: " + value,
-                    e);
+            LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE
+                            + "Improper JSON format... may or may not cause issues in validating the policy: " + value,
+                            e);
             return null;
         }
     }
@@ -1044,13 +1052,13 @@ public class PolicyValidation {
             if (obj instanceof String && ((String) obj).contains(REQUIRED_ATTRIBUTE)) {
                 LOGGER.debug("key : " + key);
                 LOGGER.debug("obj : " + obj);
-                allReqTrueKeys.add(key);    //For MicroService policies
-                allOptReqTrueKeys.add(key); //For Optimization policies
-                
+                allReqTrueKeys.add(key); // For MicroService policies
+                allOptReqTrueKeys.add(key); // For Optimization policies
+
                 // get the type from value and add that one also
                 String type = StringUtils.substringBefore((String) obj, ":");
-                if (!StringUtils.isBlank(type) && !StringUtils.containsAny(type.toLowerCase(), MSModelUtils.STRING,
-                        MSModelUtils.INTEGER, MSModelUtils.LIST, MSModelUtils.MAP, "java", "boolean")) {
+                if (!StringUtils.isBlank(type) && !StringUtils.containsAny(type.toLowerCase(), STRING, INTEGER, LIST,
+                                MAP, JAVA, BOOLEAN)) {
                     allReqTrueKeys.add(type);
                 }
             }
@@ -1066,7 +1074,7 @@ public class PolicyValidation {
     }
 
     private boolean validateMsModel(PolicyRestAdapter policyData, StringBuilder responseString)
-            throws JsonProcessingException {
+                    throws JsonProcessingException {
         boolean valid = true;
         if (!Strings.isNullOrEmpty(policyData.getServiceType())) {
 
@@ -1102,7 +1110,7 @@ public class PolicyValidation {
                                 int startNum = Integer.parseInt(tempString[0]);
                                 int endNum = Integer.parseInt(tempString[1]);
                                 String returnString = "InvalidreturnModel Range:" + raMap.getKey() + " must be between "
-                                        + startNum + " - " + endNum + ",";
+                                                + startNum + " - " + endNum + ",";
 
                                 if (value != null) {
                                     if (PolicyUtils.isInteger(value.replace("\"", ""))) {
@@ -1117,8 +1125,8 @@ public class PolicyValidation {
                                     }
                                 } else {
                                     responseString.append("<b>" + raMap.getKey() + "</b>:<i>" + raMap.getKey()
-                                    + " is required for the MicroService model " + service
-                                    + HTML_ITALICS_LNBREAK);
+                                                    + " is required for the MicroService model " + service
+                                                    + HTML_ITALICS_LNBREAK);
                                     valid = false;
                                 }
 
@@ -1129,26 +1137,26 @@ public class PolicyValidation {
                         // model
                         if (Strings.isNullOrEmpty(policyData.getLocation())) {
                             responseString.append("<b>Micro Service Model</b>:<i> location is required for this model"
-                                    + HTML_ITALICS_LNBREAK);
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
 
                         if (Strings.isNullOrEmpty(policyData.getConfigName())) {
                             responseString.append("<b>Micro Service Model</b>:<i> configName is required for this model"
-                                    + HTML_ITALICS_LNBREAK);
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
 
                         if (Strings.isNullOrEmpty(policyData.getUuid())) {
                             responseString.append("<b>Micro Service Model</b>:<i> uuid is required for this model"
-                                    + HTML_ITALICS_LNBREAK);
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
-                        
+
                         if (Strings.isNullOrEmpty(policyData.getPolicyScope())) {
-                            responseString
-                            .append("<b>Micro Service Model</b>:<i> policyScope is required for this model"
-                                    + HTML_ITALICS_LNBREAK);
+                            responseString.append(
+                                            "<b>Micro Service Model</b>:<i> policyScope is required for this model"
+                                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                     }
@@ -1157,11 +1165,12 @@ public class PolicyValidation {
                     // GUI request are already validated from the SDK-APP
                     if ("API".equals(policyData.getApiflag())) {
                         // first , get the complete set of required fields
-                        populateReqFieldSet(new String[] {refAttributes, modelAttributes}, subAttributes);
+                        populateReqFieldSet(new String[]
+                            { refAttributes, modelAttributes }, subAttributes);
 
                         // ignore req fields in which parent is not reqd
-                        populateRequiredFields(new String[] {refAttributes, modelAttributes}, subAttributes,
-                                modelAttributes);
+                        populateRequiredFields(new String[]
+                            { refAttributes, modelAttributes }, subAttributes, modelAttributes);
 
                         if (modelRequiredFieldsList != null && !modelRequiredFieldsList.isEmpty()) {
                             // create jsonRequestMap with all json keys and values from request
@@ -1175,12 +1184,12 @@ public class PolicyValidation {
                                     String value = jsonRequestMap.get(requiredField);
                                     if (StringUtils.isBlank(value) || "\"\"".equals(value)) {
                                         responseString.append("<b>Micro Service Model</b>:<i> " + requiredField
-                                                + ISREQUIRED + HTML_ITALICS_LNBREAK);
+                                                        + ISREQUIRED + HTML_ITALICS_LNBREAK);
                                         valid = false;
                                     }
                                 } else {
-                                    responseString.append("<b>Micro Service Model</b>:<i> " + requiredField
-                                            + ISREQUIRED + HTML_ITALICS_LNBREAK);
+                                    responseString.append("<b>Micro Service Model</b>:<i> " + requiredField + ISREQUIRED
+                                                    + HTML_ITALICS_LNBREAK);
                                     valid = false;
                                 }
                             }
@@ -1188,12 +1197,13 @@ public class PolicyValidation {
                     }
                 } else {
                     responseString.append("<b>Micro Service Model</b>:<i> Invalid Model. The model name, " + service
-                            + " of version, " + version + " was not found in the dictionary" + HTML_ITALICS_LNBREAK);
+                                    + " of version, " + version + " was not found in the dictionary"
+                                    + HTML_ITALICS_LNBREAK);
                     valid = false;
                 }
             } else {
-                responseString.append(
-                        "<b>Micro Service Version</b>:<i> Micro Service Version is required" + HTML_ITALICS_LNBREAK);
+                responseString.append("<b>Micro Service Version</b>:<i> Micro Service Version is required"
+                                + HTML_ITALICS_LNBREAK);
                 valid = false;
             }
         } else {
@@ -1202,28 +1212,26 @@ public class PolicyValidation {
         }
 
         if (Strings.isNullOrEmpty(policyData.getPriority())
-                && !DECISION_MS_MODEL.equals(policyData.getRuleProvider())) {
+                        && !DECISION_MS_MODEL.equals(policyData.getRuleProvider())) {
             responseString.append("<b>Priority</b>:<i> Priority is required" + HTML_ITALICS_LNBREAK);
         }
 
-
         return valid;
     }
-    
+
     private boolean validateOptimization(PolicyRestAdapter policyData, StringBuilder responseString) {
         boolean valid = true;
-        
+
         // Checks for required policy data in request
         if (Strings.isNullOrEmpty(policyData.getServiceType())) {
-            responseString.append(
-                    "<b>Optimization Service</b>:<i> Optimization policy data is missing or invalid Json." 
+            responseString.append("<b>Optimization Service</b>:<i> Optimization policy data is missing or invalid Json."
                             + HTML_ITALICS_LNBREAK);
             return false;
         }
-        
+
         modelRequiredFieldsList.clear();
         pullJsonKeyPairs((JsonNode) policyData.getPolicyJSON());
-        
+
         // parse the service and version from the policy data
         String service;
         String version;
@@ -1234,22 +1242,20 @@ public class PolicyValidation {
             service = policyData.getServiceType();
             version = policyData.getVersion();
         }
-        
+
         // Checks for required version in policy data
         if (Strings.isNullOrEmpty(version)) {
-            responseString.append(
-                    "<b>Optimization Service Version</b>:<i> Optimization Service Version is required" 
+            responseString.append("<b>Optimization Service Version</b>:<i> Optimization Service Version is required"
                             + HTML_ITALICS_LNBREAK);
             return false;
         }
-            
+
         OptimizationModels returnModel = getOptimizationModelData(service, version);
-        
+
         // Checks if valid model exists in the database
         if (returnModel == null) {
-            responseString.append("<b>Optimization Service Model</b>:<i> Invalid Model. The model name, " 
-                    + service + " of version, " + version 
-                    + " was not found in the dictionary" + HTML_ITALICS_LNBREAK);
+            responseString.append("<b>Optimization Service Model</b>:<i> Invalid Model. The model name, " + service
+                            + " of version, " + version + " was not found in the dictionary" + HTML_ITALICS_LNBREAK);
             return false;
         }
 
@@ -1259,16 +1265,15 @@ public class PolicyValidation {
         String modelAttributes = returnModel.getAttributes();
 
         if (!Strings.isNullOrEmpty(annotation)) {
-            Map<String, String> rangeMap = Splitter.on(",").withKeyValueSeparator("=")
-                    .split(annotation);
-            for (Entry<String, String> rMap : rangeMap.entrySet()) {
-                if (rMap.getValue().contains("range::")) {
-                    String value = mapAttribute.get(rMap.getKey().trim());
-                    String[] tempString = rMap.getValue().split("::")[1].split("-");
+            Map<String, String> rangeMap = Splitter.on(",").withKeyValueSeparator("=").split(annotation);
+            for (Entry<String, String> rangeMapEntry : rangeMap.entrySet()) {
+                if (rangeMapEntry.getValue().contains("range::")) {
+                    String value = mapAttribute.get(rangeMapEntry.getKey().trim());
+                    String[] tempString = rangeMapEntry.getValue().split("::")[1].split("-");
                     int startNum = Integer.parseInt(tempString[0]);
                     int endNum = Integer.parseInt(tempString[1]);
-                    String returnString = "InvalidreturnModel Range:" + rMap.getKey()
-                    + " must be between " + startNum + " - " + endNum + ",";
+                    String returnString = "InvalidreturnModel Range:" + rangeMapEntry.getKey() + " must be between "
+                                    + startNum + " - " + endNum + ",";
 
                     if (value != null) {
                         if (PolicyUtils.isInteger(value.replace("\"", ""))) {
@@ -1282,9 +1287,8 @@ public class PolicyValidation {
                             valid = false;
                         }
                     } else {
-                        responseString.append("<b>" + rMap.getKey() + "</b>:<i>" + rMap.getKey()
-                        + " is required for the Optimization model " + service
-                        + HTML_ITALICS_LNBREAK);
+                        responseString.append("<b>" + rangeMapEntry.getKey() + "</b>:<i>" + rangeMapEntry.getKey()
+                                        + " is required for the Optimization model " + service + HTML_ITALICS_LNBREAK);
                         valid = false;
                     }
 
@@ -1296,12 +1300,13 @@ public class PolicyValidation {
         // GUI request are already validated from the SDK-APP
         if ("API".equals(policyData.getApiflag())) {
             // first , get the complete set of required fields
-            populateReqFieldSet(new String[] {refAttributes, modelAttributes}, subAttributes);
+            populateReqFieldSet(new String[]
+                { refAttributes, modelAttributes }, subAttributes);
 
             modelRequiredFieldsList.addAll(allOptReqTrueKeys);
-            
+
             if (modelRequiredFieldsList != null && !modelRequiredFieldsList.isEmpty()) {
-                
+
                 // create jsonRequestMap with all json keys and values from request
                 JsonNode rootNode = (JsonNode) policyData.getPolicyJSON();
                 jsonRequestMap.clear();
@@ -1312,13 +1317,13 @@ public class PolicyValidation {
                     if (jsonRequestMap.containsKey(requiredField)) {
                         String value = jsonRequestMap.get(requiredField);
                         if (StringUtils.isBlank(value) || "\"\"".equals(value)) {
-                            responseString.append("<b>Optimization Service Model</b>:<i> " 
-                                    + requiredField + ISREQUIRED + HTML_ITALICS_LNBREAK);
+                            responseString.append("<b>Optimization Service Model</b>:<i> " + requiredField + ISREQUIRED
+                                            + HTML_ITALICS_LNBREAK);
                             valid = false;
                         }
                     } else {
-                        responseString.append("<b>Optimization Service Model</b>:<i> " 
-                                + requiredField + ISREQUIRED + HTML_ITALICS_LNBREAK);
+                        responseString.append("<b>Optimization Service Model</b>:<i> " + requiredField + ISREQUIRED
+                                        + HTML_ITALICS_LNBREAK);
                         valid = false;
                     }
                 }
@@ -1334,7 +1339,7 @@ public class PolicyValidation {
     }
 
     private void populateRequiredFields(String[] attrArr, String subAttributes, String modelAttributes)
-            throws JsonProcessingException {
+                    throws JsonProcessingException {
         // get list of required fields from the ref_Attributes of the Model
         for (String attributes : attrArr) {
             if (!StringUtils.isBlank(attributes)) {
@@ -1367,7 +1372,6 @@ public class PolicyValidation {
         // Get all keys with "required-true" defined in their value from subAttribute
         getAllKeys(jsonSub);
 
-
         // parse refAttrbutes
         for (String attr : attrArr) {
             if (attr != null) {
@@ -1383,5 +1387,4 @@ public class PolicyValidation {
         }
     }
 
-
 }
index 779c522..8fdc1e1 100644 (file)
@@ -3,20 +3,28 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.rest.util;
+ */
+
+package org.onap.policy.rest.util;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Strings;
 
 import java.io.IOException;
 import java.io.StringReader;
@@ -43,29 +51,29 @@ import org.onap.policy.rest.adapter.RainyDayParams;
 import org.onap.policy.rest.adapter.YAMLParams;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Strings;
-
 public class PolicyValidationRequestWrapper {
-
-    private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationRequestWrapper.class);
-    public static final String CONFIG_NAME="configName";
-    public static final String INVALIDJSON = " improper JSON format: ";
-    public static final String ONAPNAME = "onapname";
-    public static final String CONTENT = "content";
-    public static final String GUARD = "guard";
-    public static final String LOCATION = "location";
-    public static final String POLICYSCOPE = "policyScope";
-    public static final String PRIORITY = "priority";
-    public static final String RISKLEVEL = "riskLevel";
-    public static final String RISKTYPE = "riskType";
-    public static final String SERVICE = "service";
-    public static final String VERSION = "version";
-
-    public static final String SERVICETYPE_POLICY_NAME = "serviceTypePolicyName";
-
+    private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationRequestWrapper.class);
+
+    private static final String CONFIG_NAME = "configName";
+    private static final String CONTENT = "content";
+    private static final String GUARD = "guard";
+    private static final String INVALIDJSON = " improper JSON format: ";
+    private static final String LOCATION = "location";
+    private static final String ONAPNAME = "onapname";
+    private static final String POLICYSCOPE = "policyScope";
+    private static final String PRIORITY = "priority";
+    private static final String RISKLEVEL = "riskLevel";
+    private static final String RISKTYPE = "riskType";
+    private static final String SERVICE = "service";
+    private static final String SERVICETYPE_POLICY_NAME = "serviceTypePolicyName";
+    private static final String VERSION = "version";
+
+    /**
+     * Populate request parameters.
+     *
+     * @param request the request
+     * @return the policy rest adapter
+     */
     public PolicyRestAdapter populateRequestParameters(HttpServletRequest request) {
 
         PolicyRestAdapter policyData = null;
@@ -76,11 +84,11 @@ public class PolicyValidationRequestWrapper {
             mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
             JsonNode root = mapper.readTree(request.getReader());
             policyData = mapper.readValue(root.get("policyData").toString(), PolicyRestAdapter.class);
-            if(root.get("trapData") != null){
+            if (root.get("trapData") != null) {
                 trapDatas = mapper.readValue(root.get("trapData").toString(), ClosedLoopFaultTrapDatas.class);
                 policyData.setTrapDatas(trapDatas);
             }
-            if(root.get("faultData") != null){
+            if (root.get("faultData") != null) {
                 faultDatas = mapper.readValue(root.get("faultData").toString(), ClosedLoopFaultTrapDatas.class);
                 policyData.setFaultDatas(faultDatas);
             }
@@ -88,74 +96,80 @@ public class PolicyValidationRequestWrapper {
             JsonObject json;
             json = stringToJsonObject(root.toString());
 
-            if(json != null){
-                if(json.containsKey("policyJSON")){
+            if (json != null) {
+                if (json.containsKey("policyJSON")) {
                     policyData.setPolicyJSON(root.get("policyJSON"));
-                }else{
+                } else {
                     String jsonBodyData = json.getJsonObject("policyData").get("jsonBodyData").toString();
                     policyData.setJsonBody(jsonBodyData);
                 }
             }
 
         } catch (Exception e) {
-            LOGGER.error("Exception Occured while populating request parameters: " +e);
+            LOGGER.error("Exception Occured while populating request parameters: " + e);
         }
 
         return policyData;
     }
 
+    /**
+     * Populate request parameters.
+     *
+     * @param parameters the parameters
+     * @return the policy rest adapter
+     */
     public PolicyRestAdapter populateRequestParameters(PolicyParameters parameters) {
 
         PolicyRestAdapter policyData = new PolicyRestAdapter();
-        
+
         /*
          * set policy adapter values for Building JSON object containing policy data
          */
-        //Common Policy Fields
+        // Common Policy Fields
         policyData.setPolicyName(parameters.getPolicyName());
         policyData.setOnapName(parameters.getOnapName());
-        policyData.setPriority(parameters.getPriority()); //Micro Service
-        policyData.setConfigName(parameters.getConfigName());  //Base and Firewall
-        policyData.setRiskType(parameters.getRiskType()); //Safe parameters Attributes
-        policyData.setRiskLevel(parameters.getRiskLevel());//Safe parameters Attributes
-        policyData.setGuard(String.valueOf(parameters.getGuard()));//Safe parameters Attributes
-        policyData.setTtlDate(convertDate(parameters.getTtlDate()));//Safe parameters Attributes
+        policyData.setPriority(parameters.getPriority()); // Micro Service
+        policyData.setConfigName(parameters.getConfigName()); // Base and Firewall
+        policyData.setRiskType(parameters.getRiskType()); // Safe parameters Attributes
+        policyData.setRiskLevel(parameters.getRiskLevel());// Safe parameters Attributes
+        policyData.setGuard(String.valueOf(parameters.getGuard()));// Safe parameters Attributes
+        policyData.setTtlDate(convertDate(parameters.getTtlDate()));// Safe parameters Attributes
         policyData.setApiflag("API");
 
-        //Some policies require jsonObject conversion from String for configBody (i.e. MicroService and Firewall)
+        // Some policies require jsonObject conversion from String for configBody (i.e. MicroService and Firewall)
         JsonObject json = null;
-        try{
-            if(parameters.getConfigBody()!= null){
+        try {
+            if (parameters.getConfigBody() != null) {
                 json = stringToJsonObject(parameters.getConfigBody());
             }
-        } catch(JsonException| IllegalStateException e){
-            String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ INVALIDJSON + parameters.getConfigBody();
+        } catch (JsonException | IllegalStateException e) {
+            String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
             LOGGER.error(message, e);
             return null;
         }
-        
-        if(parameters.getPolicyClass()!=null && !"Config".equals(parameters.getPolicyClass().toString())){
+
+        if (parameters.getPolicyClass() != null && !"Config".equals(parameters.getPolicyClass().toString())) {
 
             policyData.setPolicyType(parameters.getPolicyClass().toString());
 
-            //Get Matching attribute values
+            // Get Matching attribute values
             Map<AttributeType, Map<String, String>> attributes = parameters.getAttributes();
             Map<String, String> matching = null;
-            if(attributes != null){
+            if (attributes != null) {
                 matching = attributes.get(AttributeType.MATCHING);
             }
 
-            if("Decision".equals(parameters.getPolicyClass().toString())){
+            if ("Decision".equals(parameters.getPolicyClass().toString())) {
 
                 String ruleProvider = parameters.getRuleProvider().toString();
                 policyData.setRuleProvider(ruleProvider);
 
-                if("Rainy_Day".equals(ruleProvider)){
+                if ("Rainy_Day".equals(ruleProvider)) {
 
                     // Set Matching attributes in RainyDayParams in adapter
                     RainyDayParams rainyday = new RainyDayParams();
 
-                    if(matching != null) {
+                    if (matching != null) {
                         rainyday.setServiceType(matching.get("ServiceType"));
                         rainyday.setVnfType(matching.get("VNFType"));
                         rainyday.setBbid(matching.get("BB_ID"));
@@ -177,7 +191,7 @@ public class PolicyValidationRequestWrapper {
                     policyData.setRainyday(rainyday);
 
                 } else if ("GUARD_YAML".equals(ruleProvider) || "GUARD_BL_YAML".equals(ruleProvider)
-                        || "GUARD_MIN_MAX".equals(ruleProvider)) {
+                                || "GUARD_MIN_MAX".equals(ruleProvider)) {
 
                     // Set Matching attributes in YAMLParams in adapter
                     YAMLParams yamlparams = new YAMLParams();
@@ -188,20 +202,20 @@ public class PolicyValidationRequestWrapper {
                         yamlparams.setGuardActiveStart(matching.get("guardActiveStart"));
                         yamlparams.setGuardActiveEnd(matching.get("guardActiveEnd"));
 
-                        if("GUARD_YAML".equals(ruleProvider)){
+                        if ("GUARD_YAML".equals(ruleProvider)) {
                             yamlparams.setLimit(matching.get("limit"));
                             yamlparams.setTimeWindow(matching.get("timeWindow"));
                             yamlparams.setTimeUnits(matching.get("timeUnits"));
                         } else if ("GUARD_MIN_MAX".equals(ruleProvider)) {
                             yamlparams.setMin(matching.get("min"));
                             yamlparams.setMax(matching.get("max"));
-                        }else{
+                        } else {
 
                             List<String> blackList = new ArrayList<>();
 
-                            if(!Strings.isNullOrEmpty(matching.get("blackList"))){
+                            if (!Strings.isNullOrEmpty(matching.get("blackList"))) {
                                 String[] blackListArray = matching.get("blackList").split(",");
-                                for(String element : blackListArray){
+                                for (String element : blackListArray) {
                                     blackList.add(element);
                                 }
                             }
@@ -213,7 +227,7 @@ public class PolicyValidationRequestWrapper {
                     policyData.setYamlparams(yamlparams);
                 }
 
-            } else if("Action".equals(parameters.getPolicyClass().toString())){
+            } else if ("Action".equals(parameters.getPolicyClass().toString())) {
 
                 ArrayList<Object> ruleAlgorithmChoices = new ArrayList<>();
 
@@ -223,9 +237,8 @@ public class PolicyValidationRequestWrapper {
                 List<String> dyrnamicFieldTwoRuleAlgorithms = parameters.getDynamicRuleAlgorithmField2();
 
                 if (dynamicLabelRuleAlgorithms != null && !dynamicLabelRuleAlgorithms.isEmpty()) {
-                    int i = dynamicLabelRuleAlgorithms.size() - 1;
 
-                    for (String labelAttr : dynamicLabelRuleAlgorithms) {
+                    for (int i = dynamicLabelRuleAlgorithms.size() - 1; i >= 0; i--) {
                         LinkedHashMap<String, String> ruleAlgorithm = new LinkedHashMap<>();
 
                         String id = dynamicLabelRuleAlgorithms.get(i);
@@ -239,9 +252,6 @@ public class PolicyValidationRequestWrapper {
                         ruleAlgorithm.put("dynamicRuleAlgorithmField2", dynamicRuleAlgorithmField2);
 
                         ruleAlgorithmChoices.add(ruleAlgorithm);
-
-                        i--;
-
                     }
                 }
 
@@ -264,189 +274,193 @@ public class PolicyValidationRequestWrapper {
                 policyData.setActionPerformer(parameters.getActionPerformer());
 
             }
-        }else {
+        } else {
 
             policyData.setPolicyType("Config");
             policyData.setConfigPolicyType(parameters.getPolicyConfigType().toString());
 
-            //Config Specific
-            policyData.setConfigBodyData(parameters.getConfigBody()); //Base
-            policyData.setConfigType((parameters.getConfigBodyType()!=null) ? parameters.getConfigBodyType().toString().toUpperCase(): null);  //Base
+            // Config Specific
+            policyData.setConfigBodyData(parameters.getConfigBody()); // Base
+            policyData.setConfigType((parameters.getConfigBodyType() != null)
+                            ? parameters.getConfigBodyType().toString().toUpperCase()
+                            : null); // Base
 
-            if("FW".equalsIgnoreCase(parameters.getPolicyConfigType().toString())){
+            if ("FW".equalsIgnoreCase(parameters.getPolicyConfigType().toString())) {
 
                 policyData.setConfigPolicyType("Firewall Config");
 
                 // get values and attributes from the JsonObject
-                if(json != null){
-                    if (json.get("securityZoneId")!=null){
+                if (json != null) {
+                    if (json.get("securityZoneId") != null) {
                         String securityZone = json.get("securityZoneId").toString().replace("\"", "");
                         policyData.setSecurityZone(securityZone);
                     }
-                    if (json.get(CONFIG_NAME)!=null){
+                    if (json.get(CONFIG_NAME) != null) {
                         String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
                         policyData.setConfigName(configName);
                     }
                 }
 
-            }else if("MS".equals(parameters.getPolicyConfigType().toString())){
+            } else if ("MS".equals(parameters.getPolicyConfigType().toString())) {
 
                 policyData.setConfigPolicyType("Micro Service");
 
                 // get values and attributes from the JsonObject
-                if(json != null){
-                    if (json.containsKey(CONTENT)){
+                if (json != null) {
+                    if (json.containsKey(CONTENT)) {
                         String content = json.get(CONTENT).toString();
                         ObjectMapper mapper = new ObjectMapper();
-                        JsonNode policyJSON = null;
+                        JsonNode policyJson = null;
                         try {
-                            policyJSON = mapper.readTree(content);
+                            policyJson = mapper.readTree(content);
                         } catch (IOException e) {
-                            String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ INVALIDJSON + parameters.getConfigBody();
+                            String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON
+                                            + parameters.getConfigBody();
                             LOGGER.error(message, e);
                             return null;
                         }
-                        policyData.setPolicyJSON(policyJSON);
+                        policyData.setPolicyJSON(policyJson);
                     }
-                    if (json.containsKey(SERVICE)){
+                    if (json.containsKey(SERVICE)) {
                         String serviceType = json.get(SERVICE).toString().replace("\"", "");
                         policyData.setServiceType(serviceType);
                     }
-                    if (json.containsKey("uuid")){
+                    if (json.containsKey("uuid")) {
                         String uuid = json.get("uuid").toString().replace("\"", "");
                         policyData.setUuid(uuid);
                     }
-                    if (json.containsKey(LOCATION)){
+                    if (json.containsKey(LOCATION)) {
                         String msLocation = json.get(LOCATION).toString().replace("\"", "");
                         policyData.setLocation(msLocation);
                     }
-                    if (json.containsKey(CONFIG_NAME)){
+                    if (json.containsKey(CONFIG_NAME)) {
                         String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
                         policyData.setConfigName(configName);
                     }
-                    if(json.containsKey(PRIORITY)){
+                    if (json.containsKey(PRIORITY)) {
                         String priority = json.get(PRIORITY).toString().replace("\"", "");
                         policyData.setPriority(priority);
                     }
-                    if(json.containsKey(VERSION)){
+                    if (json.containsKey(VERSION)) {
                         String version = json.get(VERSION).toString().replace("\"", "");
                         policyData.setVersion(version);
                     }
-                    if(json.containsKey(POLICYSCOPE)){
+                    if (json.containsKey(POLICYSCOPE)) {
                         String policyScope = json.get(POLICYSCOPE).toString().replace("\"", "");
                         policyData.setPolicyScope(policyScope);
                     }
-                    if(json.containsKey(RISKTYPE)){
+                    if (json.containsKey(RISKTYPE)) {
                         String riskType = json.get(RISKTYPE).toString().replace("\"", "");
                         policyData.setRiskType(riskType);
                     }
-                    if(json.containsKey(RISKLEVEL)){
+                    if (json.containsKey(RISKLEVEL)) {
                         String riskLevel = json.get(RISKLEVEL).toString().replace("\"", "");
                         policyData.setRiskLevel(riskLevel);
                     }
-                    if(json.containsKey(GUARD)){
+                    if (json.containsKey(GUARD)) {
                         String guard = json.get(GUARD).toString().replace("\"", "");
                         policyData.setGuard(guard);
                     }
                 } else {
-                    String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ INVALIDJSON + parameters.getConfigBody();
+                    String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
                     LOGGER.error(message);
                     return null;
                 }
 
-            }else if("Optimization".equals(parameters.getPolicyConfigType().toString())){
+            } else if ("Optimization".equals(parameters.getPolicyConfigType().toString())) {
 
                 policyData.setConfigPolicyType("Optimization");
 
                 // get values and attributes from the JsonObject
-                if(json != null){
-                    if (json.containsKey(CONTENT)){
+                if (json != null) {
+                    if (json.containsKey(CONTENT)) {
                         String content = json.get(CONTENT).toString();
                         ObjectMapper mapper = new ObjectMapper();
-                        JsonNode policyJSON = null;
+                        JsonNode policyJson = null;
                         try {
-                            policyJSON = mapper.readTree(content);
+                            policyJson = mapper.readTree(content);
                         } catch (IOException e) {
-                            String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ INVALIDJSON + parameters.getConfigBody();
+                            String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON
+                                            + parameters.getConfigBody();
                             LOGGER.error(message, e);
                             return null;
                         }
-                        policyData.setPolicyJSON(policyJSON);
+                        policyData.setPolicyJSON(policyJson);
                     }
-                    if (json.containsKey(SERVICE)){
+                    if (json.containsKey(SERVICE)) {
                         String serviceType = json.get(SERVICE).toString().replace("\"", "");
                         policyData.setServiceType(serviceType);
                     }
-                    if (json.containsKey("uuid")){
+                    if (json.containsKey("uuid")) {
                         String uuid = json.get("uuid").toString().replace("\"", "");
                         policyData.setUuid(uuid);
                     }
-                    if (json.containsKey(LOCATION)){
+                    if (json.containsKey(LOCATION)) {
                         String msLocation = json.get(LOCATION).toString().replace("\"", "");
                         policyData.setLocation(msLocation);
                     }
-                    if (json.containsKey(CONFIG_NAME)){
+                    if (json.containsKey(CONFIG_NAME)) {
                         String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
                         policyData.setConfigName(configName);
                     }
-                    if(json.containsKey(PRIORITY)){
+                    if (json.containsKey(PRIORITY)) {
                         String priority = json.get(PRIORITY).toString().replace("\"", "");
                         policyData.setPriority(priority);
                     }
-                    if(json.containsKey(VERSION)){
+                    if (json.containsKey(VERSION)) {
                         String version = json.get(VERSION).toString().replace("\"", "");
                         policyData.setVersion(version);
                     }
-                    if(json.containsKey(POLICYSCOPE)){
+                    if (json.containsKey(POLICYSCOPE)) {
                         String policyScope = json.get(POLICYSCOPE).toString().replace("\"", "");
                         policyData.setPolicyScope(policyScope);
                     }
-                    if(json.containsKey(RISKTYPE)){
+                    if (json.containsKey(RISKTYPE)) {
                         String riskType = json.get(RISKTYPE).toString().replace("\"", "");
                         policyData.setRiskType(riskType);
                     }
-                    if(json.containsKey(RISKLEVEL)){
+                    if (json.containsKey(RISKLEVEL)) {
                         String riskLevel = json.get(RISKLEVEL).toString().replace("\"", "");
                         policyData.setRiskLevel(riskLevel);
                     }
-                    if(json.containsKey(GUARD)){
+                    if (json.containsKey(GUARD)) {
                         String guard = json.get(GUARD).toString().replace("\"", "");
                         policyData.setGuard(guard);
                     }
                 }
 
-            } else if("Fault".equals(parameters.getPolicyConfigType().toString())){
+            } else if ("Fault".equals(parameters.getPolicyConfigType().toString())) {
 
                 policyData.setConfigPolicyType("ClosedLoop_Fault");
 
-                if(json != null){
+                if (json != null) {
                     policyData.setJsonBody(json.toString());
-                    if (json.get(ONAPNAME)!=null){
+                    if (json.get(ONAPNAME) != null) {
                         String onapName = json.get(ONAPNAME).toString().replace("\"", "");
                         policyData.setOnapName(onapName);
                     }
                 }
 
-            } else if("PM".equals(parameters.getPolicyConfigType().toString())){
+            } else if ("PM".equals(parameters.getPolicyConfigType().toString())) {
 
                 policyData.setConfigPolicyType("ClosedLoop_PM");
 
-                if(json != null){
+                if (json != null) {
                     policyData.setJsonBody(json.toString());
-                    if (json.get(ONAPNAME)!=null){
+                    if (json.get(ONAPNAME) != null) {
                         String onapName = json.get(ONAPNAME).toString().replace("\"", "");
                         policyData.setOnapName(onapName);
                     }
-                    if (json.get(SERVICETYPE_POLICY_NAME)!=null){
+                    if (json.get(SERVICETYPE_POLICY_NAME) != null) {
                         String serviceType = json.get(SERVICETYPE_POLICY_NAME).toString().replace("\"", "");
                         LinkedHashMap<String, String> serviceTypePolicyName = new LinkedHashMap<>();
                         serviceTypePolicyName.put(SERVICETYPE_POLICY_NAME, serviceType);
                         policyData.setServiceTypePolicyName(serviceTypePolicyName);
                     }
                 }
-            } else if("BRMS_Param".equals(parameters.getPolicyConfigType().toString())){
-                Map<AttributeType, Map<String, String>> drlRuleAndUIParams = parameters.getAttributes();
-                Map<String, String> rule = drlRuleAndUIParams.get(AttributeType.RULE);
+            } else if ("BRMS_Param".equals(parameters.getPolicyConfigType().toString())) {
+                Map<AttributeType, Map<String, String>> drlRuleAndUiParams = parameters.getAttributes();
+                Map<String, String> rule = drlRuleAndUiParams.get(AttributeType.RULE);
                 policyData.setRuleName(rule.get("templateName"));
 
             }
@@ -455,23 +469,25 @@ public class PolicyValidationRequestWrapper {
         return policyData;
 
     }
-    
+
     private JsonObject stringToJsonObject(String value) {
-        try(JsonReader jsonReader = Json.createReader(new StringReader(value))){
+        try (JsonReader jsonReader = Json.createReader(new StringReader(value))) {
             return jsonReader.readObject();
-        } catch(JsonException| IllegalStateException e){
-            LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE+ "Improper JSON format... may or may not cause issues in validating the policy: " + value, e);
+        } catch (JsonException | IllegalStateException e) {
+            LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE
+                            + "Improper JSON format... may or may not cause issues in validating the policy: " + value,
+                            e);
             return null;
         }
     }
-    
+
     private String convertDate(Date date) {
         String strDate = null;
-        if (date!=null) {
+        if (date != null) {
             SimpleDateFormat dateformatJava = new SimpleDateFormat("dd-MM-yyyy");
             strDate = dateformatJava.format(date);
         }
-        return (strDate==null) ? "NA": strDate;
+        return (strDate == null) ? "NA" : strDate;
     }
 
 }
index 19800b4..3b03bdc 100644 (file)
@@ -26,9 +26,6 @@ import static org.junit.Assert.fail;
 
 import com.att.research.xacml.util.XACMLProperties;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -40,7 +37,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import javax.servlet.ReadListener;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletInputStream;
 import javax.servlet.ServletOutputStream;
@@ -199,8 +195,8 @@ public class XacmlRestTest extends Mockito {
     }
 
     @Test
-    public void testConstructorIsPrivate()
-            throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
+    public void testConstructorIsPrivate() throws NoSuchMethodException, IllegalAccessException,
+                    InvocationTargetException, InstantiationException {
         Constructor<XacmlRestProperties> constructor = XacmlRestProperties.class.getDeclaredConstructor();
         assertTrue(Modifier.isPrivate(constructor.getModifiers()));
         constructor.setAccessible(true);
@@ -289,9 +285,12 @@ public class XacmlRestTest extends Mockito {
         XacmlRest.dumpRequest(httpServletRequest);
 
         Map<String, String[]> parameterMap = new LinkedHashMap<>();
-        String[] mapValue0 = {"MapValue0"};
-        String[] mapValue1 = {"MapValue0"};
-        String[] mapValue2 = {};
+        String[] mapValue0 =
+            { "MapValue0" };
+        String[] mapValue1 =
+            { "MapValue0" };
+        String[] mapValue2 =
+            {};
         parameterMap.put("Key0", mapValue0);
         parameterMap.put("Key1", mapValue1);
         parameterMap.put("Key2", mapValue2);
@@ -33,7 +33,7 @@ import org.onap.policy.common.utils.test.ToStringTester;
 /**
  * Class to perform unit testing of POJOs.
  */
-public class ModelsTest {
+public class GetterSetterToStringTest {
     private static final String POJO_PACKAGE = "org.onap.policy.rest.jpa";
 
     @Test
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/DummyPolicyContainer.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/DummyPolicyContainer.java
new file mode 100644 (file)
index 0000000..3855767
--- /dev/null
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.util;
+
+import java.util.Collection;
+
+public class DummyPolicyContainer implements PolicyContainer {
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public Collection<?> getContainerPropertyIds() {
+        return null;
+    }
+
+    @Override
+    public Collection<?> getItemIds() {
+        return null;
+    }
+
+    @Override
+    public Class<?> getType(Object propertyId) {
+        return null;
+    }
+
+    @Override
+    public int size() {
+        return 0;
+    }
+
+    @Override
+    public boolean containsId(Object itemId) {
+        return false;
+    }
+
+    @Override
+    public Object addItem() {
+        return null;
+    }
+
+    @Override
+    public boolean removeItem(Object itemId) {
+        return false;
+    }
+
+    @Override
+    public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) {
+        return false;
+    }
+
+    @Override
+    public boolean removeContainerProperty(Object propertyId) {
+        return false;
+    }
+
+    @Override
+    public boolean removeAllItems() {
+        return false;
+    }
+}
@@ -3,6 +3,7 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 package org.onap.policy.rest.util;
 
 import static org.junit.Assert.assertTrue;
+
 import java.util.HashMap;
+
 import org.junit.Test;
 
-public class MSAttributeObjectTest {
+public class MsAttributeObjectTest {
 
     @Test
-    public void testMSAttributeObject() {
-        MSAttributeObject data = new MSAttributeObject();
+    public void testMsAttributeObject() {
+        MsAttributeObject data = new MsAttributeObject();
         data.setClassName("Test");
         assertTrue("Test".equals(data.getClassName()));
         data.setRefAttribute(new HashMap<>());
@@ -60,8 +63,8 @@ public class MSAttributeObjectTest {
     }
 
     @Test
-    public void testMSAttributeValue() {
-        MSAttributeValue data = new MSAttributeValue();
+    public void testMsAttributeValue() {
+        MsAttributeValue data = new MsAttributeValue();
         data.setName("Test");
         assertTrue("Test".equals(data.getName()));
         data.setType("Test");
@@ -3,6 +3,7 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -32,6 +34,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
 import org.apache.commons.lang.StringUtils;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,12 +42,17 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.DictionaryData;
-import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
+import org.onap.policy.rest.util.MsModelUtils.ModelType;
 
-public class MSModelUtilsTest {
-    private static Logger logger = FlexLogger.getLogger(MSModelUtilsTest.class);
+public class MsModelUtilsTest {
+    private static Logger logger = FlexLogger.getLogger(MsModelUtilsTest.class);
     private static CommonClassDao commonClassDao;
 
+    /**
+     * Set tests up.
+     *
+     * @throws Exception on setup failures
+     */
     @Before
     public void setUp() throws Exception {
         List<Object> dictionaryData = new ArrayList<Object>();
@@ -55,28 +63,28 @@ public class MSModelUtilsTest {
         logger.info("setUp: Entering");
         commonClassDao = mock(CommonClassDao.class);
         when(commonClassDao.getDataById(DictionaryData.class, "dictionaryName", "GocVNFType"))
-                .thenReturn(dictionaryData);
+                        .thenReturn(dictionaryData);
     }
 
     @Test
-    public void testMSModelUtils() {
-        HashMap<String, MSAttributeObject> classMap = new HashMap<>();
+    public void testMsModelUtils() {
+        HashMap<String, MsAttributeObject> classMap = new HashMap<>();
         ClassLoader classLoader = getClass().getClassLoader();
         File file = new File(classLoader.getResource("DKaTVESPolicy-v1802.xmi").getFile());
-        MSModelUtils utils = new MSModelUtils("http://org.onap", "http://org.onap.policy");
-        Map<String, MSAttributeObject> tempMap =
-                utils.processEpackage(file.getAbsolutePath().toString(), MODEL_TYPE.XMI);
+        MsModelUtils utils = new MsModelUtils("http://org.onap", "http://org.onap.policy");
+        Map<String, MsAttributeObject> tempMap = utils.processEpackage(file.getAbsolutePath().toString(),
+                        ModelType.XMI);
         classMap.putAll(tempMap);
-        MSAttributeObject mainClass = classMap.get("StandardDeviationThreshold");
-        String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "},
-                new String[] {"", "", ""});
+        MsAttributeObject mainClass = classMap.get("StandardDeviationThreshold");
+        String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]
+            { "[", "]", " " }, new String[]
+            { "", "", "" });
         List<String> dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(",")));
         dependency = utils.getFullDependencyList(dependency, classMap);
         String subAttribute = utils.createSubAttributes(dependency, classMap, "StandardDeviationThreshold");
         assertTrue(subAttribute != null);
     }
 
-
     /**
      * Run the void stringBetweenDots(String, String) method test.
      */
@@ -85,25 +93,24 @@ public class MSModelUtilsTest {
     public void testStringBetweenDots() {
 
         // expect: uniqueKeys should contain a string value
-        MSModelUtils controllerA = new MSModelUtils();
+        MsModelUtils controllerA = new MsModelUtils();
         String str = "testing\\.byCorrectWay\\.OfDATA";
         assertEquals(1, controllerA.stringBetweenDots(str));
 
         // expect: uniqueKeys should not contain a string value
         str = "testing\byWrongtWay.\\OfDATA";
-        MSModelUtils controllerB = new MSModelUtils();
+        MsModelUtils controllerB = new MsModelUtils();
         assertEquals(0, controllerB.stringBetweenDots(str));
     }
 
     /**
-     * Run the Map<String,String> load(String) method test.
+     * Run the load method test.
      */
-
     @Test
     public void testLoad() {
 
         boolean isLocalTesting = true;
-        MSModelUtils controller = new MSModelUtils();
+        MsModelUtils controller = new MsModelUtils();
         String fileName = null;
         Map<String, String> result = null;
         try {
@@ -146,7 +153,7 @@ public class MSModelUtilsTest {
             logger.error("Exception Occured while loading file" + e1);
         }
 
-        MSModelUtils controller = new MSModelUtils(commonClassDao);
+        MsModelUtils controller = new MsModelUtils(commonClassDao);
         if (isLocalTesting) {
             try {
                 controller.parseTosca(fileName);
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java
deleted file mode 100644 (file)
index 9302df3..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 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.rest.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.rest.util.PDPPolicyContainer.PDPPolicyItem;
-import org.onap.policy.xacml.std.pap.StdPDP;
-import org.onap.policy.xacml.std.pap.StdPDPGroup;
-import org.onap.policy.xacml.std.pap.StdPDPPolicy;
-import com.att.research.xacml.api.pap.PDP;
-import com.att.research.xacml.api.pap.PDPPolicy;
-
-public class PDPPolicyContainerTest {
-  StdPDPGroup group;
-  PDPPolicyContainer container;
-  StdPDPPolicy policy;
-
-  @Before
-  public void setUp() {
-    group = new StdPDPGroup();
-    group.setDefault(true);
-    group.setDefaultGroup(true);
-    group.setDescription("Test");
-    group.setId("Test");
-    group.setName("Test");
-    group.setOnapPdps(new HashSet<>());
-    group.setOperation("Test");
-    group.setPipConfigs(new HashSet<>());
-    HashSet<PDPPolicy> policies = new HashSet<>();
-    policy = new StdPDPPolicy();
-    policy.setName("Config_test.1.xml");
-    policy.setId("Config_test");
-    policy.setVersion("1.0");
-    policy.setDescription("testDescription");
-    policies.add(policy);
-    group.setPolicies(policies);
-    group.setSelectedPolicies(new HashSet<>());
-    container = new PDPPolicyContainer(group);
-  }
-
-  @Test
-  public void testPDPPolicyContainer() {
-    container.nextItemId(policy);
-    container.prevItemId(policy);
-    container.firstItemId();
-    container.lastItemId();
-    container.isFirstId(policy);
-    container.isLastId(policy);
-    container.addItemAfter(policy);
-    container.getContainerPropertyIds();
-    container.getItemIds();
-    container.getType("Id");
-    assertTrue(String.class.equals(String.class));
-    container.getType("Name");
-    assertTrue(String.class.equals(String.class));
-    container.getType("Version");
-    assertTrue(String.class.equals(String.class));
-    container.getType("Description");
-    assertTrue(String.class.equals(String.class));
-    container.getType("Root");
-    assertTrue(Boolean.class.equals(Boolean.class));
-    assertTrue(container.size() == 1);
-    container.containsId(policy);
-    container.removeItem(policy);
-    container.addContainerProperty(null, null, null);
-    container.removeContainerProperty(policy);
-    container.removeAllItems();
-    container.addItemAt(0);
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testConstructor() {
-    // Test PDP based constructor
-    PDP pdp = new StdPDP();
-    PDPPolicyContainer container1 = new PDPPolicyContainer(pdp);
-    assertNotNull(container1);
-
-    // Test set based constructor
-    Set<PDPPolicy> set = new HashSet<PDPPolicy>();
-    PDPPolicyContainer container2 = new PDPPolicyContainer(set);
-    assertNotNull(container2);
-
-    // Test object based constructor
-    PDPPolicyContainer container3 = new PDPPolicyContainer("testObject");
-    assertNotNull(container3);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void testAddItem() {
-    container.addItem();
-  }
-
-  @Test
-  public void testGetters() {
-    assertNull(container.nextItemId("testItem"));
-    assertNull(container.prevItemId("testItem"));
-    assertNotNull(container.firstItemId());
-    assertNotNull(container.lastItemId());
-    assertEquals(container.indexOfId("testItem"), -1);
-    assertNotNull(container.getIdByIndex(0));
-    assertNotNull(container.getItemIds(0, 1));
-  }
-
-  @Test
-  public void testPDPPolicyItem() {
-    PDPPolicyItem item = container.new PDPPolicyItem(policy);
-    assertEquals("Config_test", item.getId());
-    assertEquals("Config_test.1.xml", item.getName());
-    assertEquals("1.0", item.getVersion());
-    assertEquals("testDescription", item.getDescription());
-    item.setRoot(true);
-    assertEquals(true, item.getRoot());
-  }
-}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/ParserExceptionTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/ParserExceptionTest.java
new file mode 100644 (file)
index 0000000..92b56a1
--- /dev/null
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ParserExceptionTest {
+
+    @Test
+    public void test() {
+        ParserException pe = new ParserException("A Message");
+        assertEquals("A Message", pe.getMessage());
+    }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PdpPolicyContainerTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PdpPolicyContainerTest.java
new file mode 100644 (file)
index 0000000..32d9e52
--- /dev/null
@@ -0,0 +1,267 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.util;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFLogger.Level;
+import com.att.eelf.configuration.EELFManager;
+import com.att.research.xacml.api.pap.PDP;
+import com.att.research.xacml.api.pap.PDPPolicy;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.eelf.PolicyLogger;
+import org.onap.policy.rest.util.PdpPolicyContainer.PdpPolicyItem;
+import org.onap.policy.xacml.std.pap.StdPDP;
+import org.onap.policy.xacml.std.pap.StdPDPGroup;
+import org.onap.policy.xacml.std.pap.StdPDPPolicy;
+
+public class PdpPolicyContainerTest {
+    StdPDPGroup group;
+    PdpPolicyContainer container;
+    StdPDPPolicy policy;
+
+    /**
+     * Set test up.
+     */
+    @Before
+    public void setUp() {
+        group = new StdPDPGroup();
+        group.setDefault(true);
+        group.setDefaultGroup(true);
+        group.setDescription("Test");
+        group.setId("Test");
+        group.setName("Test");
+        group.setOnapPdps(new HashSet<>());
+        group.setOperation("Test");
+        group.setPipConfigs(new HashSet<>());
+        policy = new StdPDPPolicy();
+        policy.setName("Config_test.1.xml");
+        policy.setId("Config_test");
+        policy.setVersion("1.0");
+        policy.setDescription("testDescription");
+
+        HashSet<PDPPolicy> policies = new HashSet<>();
+        policies.add(policy);
+        group.setPolicies(policies);
+        group.setSelectedPolicies(new HashSet<>());
+        container = new PdpPolicyContainer(group);
+    }
+
+    @Test
+    public void testPdpPolicyContainer() {
+        container.nextItemId(policy);
+        container.prevItemId(policy);
+        container.firstItemId();
+        container.lastItemId();
+        container.isFirstId(policy);
+        container.isLastId(policy);
+        container.addItemAfter(policy);
+        container.getContainerPropertyIds();
+        container.getItemIds();
+        container.getType("Id");
+        assertNull(container.getType("NonExistant"));
+        assertTrue(String.class.equals(String.class));
+        container.getType("Name");
+        assertTrue(String.class.equals(String.class));
+        container.getType("Version");
+        assertTrue(String.class.equals(String.class));
+        container.getType("Description");
+        assertTrue(String.class.equals(String.class));
+        container.getType("Root");
+        assertTrue(Boolean.class.equals(Boolean.class));
+        assertTrue(container.size() == 1);
+        container.containsId(policy);
+        container.removeItem(policy);
+        container.addContainerProperty(null, null, null);
+        container.removeContainerProperty(policy);
+        container.removeAllItems();
+
+        assertFalse(container.isFirstId(policy));
+        assertFalse(container.isLastId(policy));
+        assertNull(container.firstItemId());
+        assertNull(container.lastItemId());
+        assertNull(container.prevItemId(policy));
+
+        assertThatThrownBy(() -> container.getItemIds(0, -1)).isInstanceOf(IllegalArgumentException.class);
+
+        container.addItemAt(0);
+    }
+
+    @Test
+    public void testPdpPolicyContainerWithTrace() {
+        EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger();
+
+        final Level currentLevel = PolicyLogger.getDebugLevel();
+        debugLogger.setLevel(Level.TRACE);
+
+        testPdpPolicyContainer();
+        debugLogger.setLevel(currentLevel);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testConstructor() {
+        // Test PDP based constructor
+        PDP pdp = new StdPDP();
+        PdpPolicyContainer container1 = new PdpPolicyContainer(pdp);
+        assertNotNull(container1);
+
+        // Test set based constructor
+        Set<PDPPolicy> set = new HashSet<PDPPolicy>();
+        PdpPolicyContainer container2 = new PdpPolicyContainer(set);
+        assertNotNull(container2);
+
+        // Test object based constructor
+        PdpPolicyContainer container3 = new PdpPolicyContainer("testObject");
+        assertNotNull(container3);
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testAddItem() {
+        container.addItem();
+    }
+
+    @Test
+    public void testGettersWithTrace() {
+        EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger();
+
+        final Level currentLevel = PolicyLogger.getDebugLevel();
+        debugLogger.setLevel(Level.TRACE);
+
+        testGetters();
+        debugLogger.setLevel(currentLevel);
+    }
+
+    @Test
+    public void testGetters() {
+        assertNull(container.nextItemId("testItem"));
+        assertNull(container.prevItemId("testItem"));
+        assertNotNull(container.firstItemId());
+        assertNotNull(container.lastItemId());
+        assertEquals(container.indexOfId("testItem"), -1);
+        assertNotNull(container.getIdByIndex(0));
+        assertNotNull(container.getItemIds(0, 1));
+    }
+
+    @Test
+    public void testPdpPolicyItemWithTrace() {
+        EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger();
+
+        final Level currentLevel = PolicyLogger.getDebugLevel();
+        debugLogger.setLevel(Level.TRACE);
+
+        testPdpPolicyItem();
+        debugLogger.setLevel(currentLevel);
+    }
+
+    @Test
+    public void testPdpPolicyItem() {
+        PdpPolicyItem item = container.new PdpPolicyItem(policy);
+        assertEquals("Config_test", item.getId());
+        assertEquals("Config_test.1.xml", item.getName());
+        assertEquals("1.0", item.getVersion());
+        assertEquals("testDescription", item.getDescription());
+        item.setRoot(true);
+        assertEquals(true, item.getRoot());
+    }
+
+    @Test
+    public void testContainerListOfPolicies() {
+        StdPDPGroup testGroup = new StdPDPGroup();
+        testGroup.setDefault(true);
+        testGroup.setDefaultGroup(true);
+        testGroup.setDescription("Test");
+        testGroup.setId("Test");
+        testGroup.setName("Test");
+        testGroup.setOnapPdps(new HashSet<>());
+        testGroup.setOperation("Test");
+        testGroup.setPipConfigs(new HashSet<>());
+
+        StdPDPPolicy testPolicy0 = new StdPDPPolicy();
+        testPolicy0.setName("Config_test.0.xml");
+        testPolicy0.setId("Config_test0");
+        testPolicy0.setVersion("1.0");
+        testPolicy0.setDescription("testDescription0");
+
+        StdPDPPolicy testPolicy1 = new StdPDPPolicy();
+        testPolicy1.setName("Config_test.1.xml");
+        testPolicy1.setId("Config_test1");
+        testPolicy1.setVersion("1.0");
+        testPolicy1.setDescription("testDescription1");
+
+        HashSet<PDPPolicy> policies = new HashSet<>();
+        policies.add(testPolicy0);
+        policies.add(testPolicy1);
+
+        testGroup.setPolicies(policies);
+        testGroup.setSelectedPolicies(new HashSet<>());
+        PdpPolicyContainer testContainer = new PdpPolicyContainer(testGroup);
+
+        assertEquals("Config_test0", ((PdpPolicyItem) testContainer.nextItemId(testPolicy1)).getId());
+        assertEquals("Config_test1", ((PdpPolicyItem) testContainer.prevItemId(testPolicy0)).getId());
+
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            mapper.writeValue(System.err, testPolicy0);
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        // @formatter:off
+        assertTrue(testContainer.removeItem("{"
+                        + "\"PDPPolicyType\":\"StdPDPPolicy\","
+                        + "\"id\":\"Config_test0\","
+                        + "\"name\":\"Config_test.0.xml\","
+                        + "\"policyId\":null,"
+                        + "\"description\":\"testDescription0\","
+                        + "\"version\":\"1.0\","
+                        + "\"location\":null,"
+                        + "\"valid\":false,"
+                        + "\"root\":false"
+                        + "}"));
+        assertFalse(testContainer.removeItem("{"
+                        + "\"PDPPolicyType\":\"StdPDPPolicy\","
+                        + "\"id\":\"Config_test99\","
+                        + "\"name\":\"Config_test.0.xml\","
+                        + "\"policyId\":null,"
+                        + "\"description\":\"testDescription0\","
+                        + "\"version\":\"1.0\","
+                        + "\"location\":null,"
+                        + "\"valid\":false,"
+                        + "\"root\":false"
+                        + "}"));
+        // @formatter:on
+    }
+}
index 9e5ff5d..5e42ec6 100644 (file)
@@ -3,13 +3,14 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
 
 package org.onap.policy.rest.util;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeEvent;
 import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeListener;
 
 public class PolicyItemSetChangeNotifierTest {
-  @Test
-  public void testNotifier() {
-    // Setup test data
-    ItemSetChangeListener listener = Mockito.mock(ItemSetChangeListener.class);
-    ItemSetChangeEvent event = Mockito.mock(ItemSetChangeEvent.class);
-
-    // Test constructor
-    PolicyItemSetChangeNotifier notifier = new PolicyItemSetChangeNotifier();
-    assertNotNull(notifier);
-
-    // Test listener methods
-    try {
-      notifier.addItemSetChangeListener(listener);
-      notifier.fireItemSetChange(event);
-      notifier.removeItemSetChangeListener(listener);
-    } catch (Exception ex) {
-      fail("Not expecting any exceptions: " + ex);
+    @Test
+    public void testNotifier() {
+
+        // Test constructor
+        PolicyItemSetChangeNotifier notifier = new PolicyItemSetChangeNotifier();
+        assertNotNull(notifier);
+
+        assertEquals(null, notifier.getItemSetChangeListeners());
+
+        ItemSetChangeListener listener1 = Mockito.mock(ItemSetChangeListener.class);
+        notifier.addItemSetChangeListener(listener1);
+        assertEquals(1, notifier.getItemSetChangeListeners().size());
+        ItemSetChangeListener listener2 = Mockito.mock(ItemSetChangeListener.class);
+        notifier.addItemSetChangeListener(listener2);
+        assertEquals(2, notifier.getItemSetChangeListeners().size());
+
+        notifier.removeItemSetChangeListener(listener1);
+        assertEquals(1, notifier.getItemSetChangeListeners().size());
+        notifier.addItemSetChangeListener(listener1);
+        assertEquals(2, notifier.getItemSetChangeListeners().size());
+
+        ItemSetChangeEvent event = Mockito.mock(ItemSetChangeEvent.class);
+        notifier.fireItemSetChange(event);
+
+        notifier.removeItemSetChangeListener(listener1);
+        assertEquals(1, notifier.getItemSetChangeListeners().size());
+        notifier.removeItemSetChangeListener(listener2);
+        assertEquals(0, notifier.getItemSetChangeListeners().size());
+        notifier.removeItemSetChangeListener(listener2);
+        assertEquals(0, notifier.getItemSetChangeListeners().size());
+
+        notifier.setItemSetChangeListeners(null);
+        notifier.removeItemSetChangeListener(listener2);
+        assertEquals(null, notifier.getItemSetChangeListeners());
+
+        assertThatCode(() -> notifier.fireItemSetChange(event)).doesNotThrowAnyException();
+
+        notifier.setContainer(new DummyPolicyContainer());
+        assertThatCode(() -> notifier.fireItemSetChange()).doesNotThrowAnyException();
+
+        PolicyContainer dummySource = new DummyPolicyContainer();
+        assertEquals(dummySource, new PolicyItemSetChangeNotifier.BaseItemSetChangeEvent(dummySource).getContainer());
     }
-  }
 }
index 6051db4..47b0f49 100644 (file)
@@ -3,13 +3,14 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * 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.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.rest.util;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.UUID;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -41,9 +46,7 @@ public class PolicyValidationTest {
     }
 
     @Test
-    public void microServicePolicyTests() throws Exception{
-        PolicyValidation validation = new PolicyValidation();
-        PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+    public void microServicePolicyTests() throws Exception {
         PolicyParameters policyParameters = new PolicyParameters();
 
         policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
@@ -51,8 +54,20 @@ public class PolicyValidationTest {
         policyParameters.setPolicyDescription("This is a sample Micro Service policy Create example");
         policyParameters.setOnapName("DCAE");
         policyParameters.setPriority("1");
-        String MSjsonString = "{\"service\":\"TOSCA_namingJenny\",\"location\":\"Test  DictMSLoc\",\"uuid\":\"testDict  DCAEUIID\",\"policyName\":\"testModelValidation\",\"description\":\"test\",\"configName\":\"testDict  MSConfName\",\"templateVersion\":\"1607\",\"version\":\"gw12181031\",\"priority\":\"5\",\"policyScope\":\"resource=ResourcetypeVenktest1,service=ServiceName1707,type=Name1707,closedLoopControlName=Retest_retest1\",\"riskType\":\"Test\",\"riskLevel\":\"3\",\"guard\":\"True\",\"content\":{\"police-instance-name\":\"testing\",\"naming-models\":[{\"naming-properties\":[{\"property-value\":\"test\",\"source-endpoint\":\"test\",\"property-name\":\"testPropertyname\",\"increment-sequence\":{\"scope\":\"VNF\",\"start-value\":\"1\",\"length\":\"3\",\"increment\":\"2\"},\"source-system\":\"TOSCA\"}],\"naming-type\":\"testNamingType\",\"naming-recipe\":\"testNamingRecipe\"}]}}";;
-        policyParameters.setConfigBody(MSjsonString);
+        String msJsonString = "{\"service\":\"TOSCA_namingJenny\",\"location\":\"Test  DictMSLoc\","
+                        + "\"uuid\":\"testDict  DCAEUIID\",\"policyName\":\"testModelValidation\","
+                        + "\"description\":\"test\",\"configName\":\"testDict  MSConfName\","
+                        + "\"templateVersion\":\"1607\",\"version\":\"gw12181031\",\"priority\":\"5\","
+                        + "\"policyScope\":\"resource=ResourcetypeVenktest1,service=ServiceName1707,type=Name1707,"
+                        + "closedLoopControlName=Retest_retest1\",\"riskType\":\"Test\",\"riskLevel\":\"3\","
+                        + "\"guard\":\"True\",\"content\":{\"police-instance-name\":\"testing\","
+                        + "\"naming-models\":[{\"naming-properties\":[{\"property-value\":\"test\","
+                        + "\"source-endpoint\":\"test\",\"property-name\":\"testPropertyname\","
+                        + "\"increment-sequence\":{\"scope\":\"VNF\",\"start-value\":\"1\",\"length\":\"3\","
+                        + "\"increment\":\"2\"},\"source-system\":\"TOSCA\"}],\"naming-type\":\"testNamingType\","
+                        + "\"naming-recipe\":\"testNamingRecipe\"}]}}";
+        ;
+        policyParameters.setConfigBody(msJsonString);
         policyParameters.setRequestID(UUID.randomUUID());
         SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
         Date date = dateformat3.parse("15/10/2016");
@@ -62,8 +77,9 @@ public class PolicyValidationTest {
         policyParameters.setRiskType("TEST");
         policyParameters.setRequestID(UUID.randomUUID());
 
-
+        PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
         PolicyRestAdapter policyData = wrapper.populateRequestParameters(policyParameters);
+        PolicyValidation validation = new PolicyValidation();
         StringBuilder responseString = validation.validatePolicy(policyData);
 
         assertNotSame("success", responseString.toString());
index b26709f..e8217b9 100644 (file)
@@ -58,7 +58,7 @@ import org.onap.policy.rest.adapter.AutoPushTabAdapter;
 import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.PolicyEntity;
 import org.onap.policy.rest.jpa.PolicyVersion;
-import org.onap.policy.rest.util.PDPPolicyContainer;
+import org.onap.policy.rest.util.PdpPolicyContainer;
 import org.onap.policy.utils.PolicyUtils;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
@@ -84,7 +84,7 @@ public class AutoPushController extends RestrictedBaseController {
     CommonClassDao commonClassDao;
 
     private PDPGroupContainer container;
-    private PDPPolicyContainer policyContainer;
+    private PdpPolicyContainer policyContainer;
     private PolicyController policyController;
     protected List<OnapPDPGroup> groups = Collections.synchronizedList(new ArrayList<>());
 
@@ -377,7 +377,7 @@ public class AutoPushController extends RestrictedBaseController {
             logger.info(
                     "**********************************************************************************************");
 
-            policyContainer = new PDPPolicyContainer(group);
+            policyContainer = new PdpPolicyContainer(group);
             if (removePolicyData.size() > 0) {
                 IntStream.range(0, removePolicyData.size()).mapToObj(i -> removePolicyData.get(i).toString())
                         .forEach(polData -> this.policyContainer.removeItem(polData));
index 2e7654e..5dee2e6 100644 (file)
@@ -94,9 +94,9 @@ import org.onap.policy.rest.jpa.GroupPolicyScopeList;
 import org.onap.policy.rest.jpa.MicroServiceModels;
 import org.onap.policy.rest.jpa.MicroserviceHeaderdeFaults;
 import org.onap.policy.rest.jpa.PolicyEntity;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
-import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
+import org.onap.policy.rest.util.MsModelUtils.ModelType;
 import org.onap.policy.utils.PolicyUtils;
 import org.onap.portalsdk.core.controller.RestrictedBaseController;
 import org.onap.portalsdk.core.web.support.JsonMessage;
@@ -126,7 +126,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
     private String directory;
     private List<String> modelList = new ArrayList<>();
     private List<String> dirDependencyList = new ArrayList<>();
-    private LinkedHashMap<String, MSAttributeObject> classMap = new LinkedHashMap<>();
+    private LinkedHashMap<String, MsAttributeObject> classMap = new LinkedHashMap<>();
     String referenceAttributes;
     String attributeString;
     Set<String> allManyTrueKeys = null;
@@ -1539,7 +1539,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
         }
 
         List<File> fileList = new ArrayList<>();
-        MSModelUtils msModelUtils = new MSModelUtils(commonClassDao);
+        MsModelUtils msModelUtils = new MsModelUtils(commonClassDao);
         this.directory = "model";
         if (zip) {
             extractFolder(this.newFile);
@@ -1579,7 +1579,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
             modelType = "yml";
             modelList.add(this.newModel.getModelName());
             String className = this.newModel.getModelName();
-            MSAttributeObject msAttributes = new MSAttributeObject();
+            MsAttributeObject msAttributes = new MsAttributeObject();
             msAttributes.setClassName(className);
 
             LinkedHashMap<String, String> returnAttributeList = new LinkedHashMap<>();
@@ -1681,10 +1681,10 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
 
     private void retrieveDependency(String workingFile) {
 
-        MSModelUtils utils = new MSModelUtils(PolicyController.getMsOnapName(), PolicyController.getMsPolicyName());
-        Map<String, MSAttributeObject> tempMap;
+        MsModelUtils utils = new MsModelUtils(PolicyController.getMsOnapName(), PolicyController.getMsPolicyName());
+        Map<String, MsAttributeObject> tempMap;
 
-        tempMap = utils.processEpackage(workingFile, MODEL_TYPE.XMI);
+        tempMap = utils.processEpackage(workingFile, ModelType.XMI);
 
         classMap.putAll(tempMap);
         LOGGER.info(tempMap);
@@ -1734,7 +1734,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
 
     private List<String> createList() {
         List<String> list = new ArrayList<>();
-        for (Entry<String, MSAttributeObject> entrySet : classMap.entrySet()) {
+        for (Entry<String, MsAttributeObject> entrySet : classMap.entrySet()) {
             if (entrySet.getValue().isPolicyTempalate()) {
                 list.add(entrySet.getKey());
             }
index 0e42c78..37f543f 100644 (file)
@@ -75,9 +75,9 @@ import org.onap.policy.rest.dao.CommonClassDao;
 import org.onap.policy.rest.jpa.MicroserviceHeaderdeFaults;
 import org.onap.policy.rest.jpa.OptimizationModels;
 import org.onap.policy.rest.jpa.PolicyEntity;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
-import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
+import org.onap.policy.rest.util.MsModelUtils.ModelType;
 import org.onap.policy.utils.PolicyUtils;
 import org.onap.portalsdk.core.controller.RestrictedBaseController;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -103,7 +103,7 @@ public class CreateOptimizationController extends RestrictedBaseController {
     private String directory;
     private List<String> modelList = new ArrayList<>();
     private List<String> dirDependencyList = new ArrayList<>();
-    private LinkedHashMap<String, MSAttributeObject> classMap = new LinkedHashMap<>();
+    private LinkedHashMap<String, MsAttributeObject> classMap = new LinkedHashMap<>();
     String referenceAttributes;
     String attributeString;
     Set<String> allManyTrueKeys = new HashSet<>();
@@