Populate policies, even if empty 85/86285/1
authorJim Hahn <jrh3@att.com>
Thu, 25 Apr 2019 12:55:05 +0000 (08:55 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 25 Apr 2019 12:55:05 +0000 (08:55 -0400)
Modified PdpUpdate to create an empty policy list, by default,
rather than leaving it null.

Change-Id: I81906410bcc7da21d6471d496713ec9b375632a2
Issue-ID: POLICY-1692
Signed-off-by: Jim Hahn <jrh3@att.com>
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java

index 5d0e225..c42f1db 100644 (file)
@@ -21,6 +21,7 @@
 
 package org.onap.policy.models.pdp.concepts;
 
+import java.util.LinkedList;
 import java.util.List;
 import java.util.stream.Collectors;
 import lombok.Getter;
@@ -54,7 +55,7 @@ public class PdpUpdate extends PdpMessage {
      * listed. Note: this list may be empty, as a PDP may remain attached to a subgroup
      * even if all of the policies are removed from the subgroup.
      */
-    private List<ToscaPolicy> policies;
+    private List<ToscaPolicy> policies = new LinkedList<>();
 
     /**
      * Constructor for instantiating PdpUpdate class with message name.
index 8889e48..2dfcb30 100644 (file)
@@ -41,6 +41,7 @@ public class PdpUpdateTest {
         assertThatThrownBy(() -> new PdpUpdate(null)).isInstanceOf(NullPointerException.class);
 
         PdpUpdate orig = new PdpUpdate();
+        orig.setPolicies(null);
 
         // verify with null values
         assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new PdpUpdate(orig).toString()));