summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-04-25 08:55:05 -0400
committerJim Hahn <jrh3@att.com>2019-04-25 08:55:05 -0400
commitbc23e7cbb04f79daf15798ae472041788bb28046 (patch)
treec3ee1d889c99e92ed4ab846890835d94d0f14168
parentcb7e20da2abffea03d67ca6891549ad9bde66de8 (diff)
Populate policies, even if empty
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>
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java3
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java1
2 files changed, 3 insertions, 1 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
index 5d0e225c3..c42f1db09 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
@@ -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.
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java
index 8889e483f..2dfcb30fe 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java
@@ -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()));