Unit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / util / PolicyValidation.java
index 6bab919..70be832 100644 (file)
@@ -47,6 +47,8 @@ import javax.json.JsonObject;
 import javax.json.JsonReader;
 import javax.json.JsonValue;
 
+import lombok.Getter;
+
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
 
@@ -113,6 +115,7 @@ public class PolicyValidation {
     private static Map<String, String> jsonRequestMap = new HashMap<>();
     private static List<String> modelRequiredFieldsList = new ArrayList<>();
 
+    @Getter
     private static CommonClassDao commonClassDao;
 
     private Set<String> allReqTrueKeys = new HashSet<>();
@@ -230,7 +233,7 @@ public class PolicyValidation {
             // Decision Policy Attributes Validation
             if (!"API".equals(policyData.getApiflag()) && policyData.getSettings() != null
                             && !policyData.getSettings().isEmpty()) {
-                for (Object attribute : policyData.getAttributes()) {
+                for (Object attribute : policyData.getSettings()) {
                     if (attribute instanceof LinkedHashMap<?, ?>) {
                         String value = null;
                         if (((LinkedHashMap<?, ?>) attribute).get("key") == null) {
@@ -375,15 +378,11 @@ public class PolicyValidation {
                                     valid = false;
                                 }
                             } else if ("PROPERTIES".equals(configType)) {
-                                if (!PolicyUtils.isPropValid(configBodyData) || "".equals(configBodyData)) {
+                                if (!PolicyUtils.isPropValid(configBodyData)) {
                                     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);
-                                valid = false;
                             }
                         }
                     } else {
@@ -487,7 +486,7 @@ public class PolicyValidation {
                         }
                     } else {
                         responseString.append(
-                                        "<b>D2/Virtualized Services</b>:<i>Select atleast one D2/Virtualized Services"
+                                        "<b>D2/Virtualized Services</b>:<i>Select at least one D2/Virtualized Services"
                                                         + HTML_ITALICS_LNBREAK);
                         valid = false;
                     }
@@ -603,7 +602,7 @@ public class PolicyValidation {
                         }
                     } else {
                         responseString.append(
-                                        "<b>D2/Virtualized Services</b>: <i>Select atleast one D2/Virtualized Services"
+                                        "<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services"
                                                         + HTML_ITALICS_LNBREAK);
                         responseString.append(
                                         "<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
@@ -881,7 +880,7 @@ public class PolicyValidation {
         }
     }
 
-    protected String emailValidation(String email, String response) {
+    private String emailValidation(String email, String response) {
         String res = response;
         if (email != null) {
             String validateEmail = PolicyUtils.validateEmailAddress(email.replace("\"", ""));