Handling supported policy type during PdpGroup Update 80/100680/1
authora.sreekumar <ajith.sreekumar@est.tech>
Thu, 23 Jan 2020 13:35:07 +0000 (13:35 +0000)
committera.sreekumar <ajith.sreekumar@est.tech>
Thu, 23 Jan 2020 13:35:12 +0000 (13:35 +0000)
Change-Id: I62fbfeb80b81f4cc6dc0049bbd4ab9dcc5065773
Issue-ID: POLICY-2023
Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroups.java

index 269130b..6729d7e 100644 (file)
@@ -85,9 +85,14 @@ public class PdpGroups {
      * @return the validation result
      */
     public ValidationResult checkForDuplicateGroups(ValidationResult result) {
-        List<String> names = groups.stream().map(PdpGroup::getName).collect(Collectors.toList());
-        if (groups.size() != new HashSet<>(names).size()) {
-            result = new ObjectValidationResult(GROUPS_FIELD, names, ValidationStatus.INVALID, "duplicate group names");
+        if (null == groups) {
+            result.setResult(ValidationStatus.INVALID, "is null");
+        } else {
+            List<String> names = groups.stream().map(PdpGroup::getName).collect(Collectors.toList());
+            if (groups.size() != new HashSet<>(names).size()) {
+                result =
+                    new ObjectValidationResult(GROUPS_FIELD, names, ValidationStatus.INVALID, "duplicate group names");
+            }
         }
         return result;
     }