summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java4
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java11
2 files changed, 15 insertions, 0 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java
index 18ae5af6..74d7ad8a 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateReq.java
@@ -122,6 +122,10 @@ public class UpdateReq extends RequestImpl {
PdpUpdate update = (PdpUpdate) newMessage;
+ // ensure lists are never null
+ update.setPoliciesToBeDeployed(alwaysList(update.getPoliciesToBeDeployed()));
+ update.setPoliciesToBeUndeployed(alwaysList(update.getPoliciesToBeUndeployed()));
+
if (isSameContent(update)) {
// content hasn't changed - nothing more to do
return true;
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
index d85bf737..d636f8b8 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.pap.main.comm.msgdata;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
@@ -196,6 +197,16 @@ public class UpdateReqTest extends CommonRequestBase {
msg2.setPdpGroup(DIFFERENT);
assertTrue(data.reconfigure(msg2));
assertSame(msg2, data.getMessage());
+
+ // both lists in the update are null - should not throw an exception
+ PdpUpdate msg3 = new PdpUpdate(update);
+ msg3.setPdpGroup(DIFFERENT);
+ msg3.setPoliciesToBeDeployed(null);
+ msg3.setPoliciesToBeUndeployed(null);
+ assertThatCode(() -> data.reconfigure(msg3)).doesNotThrowAnyException();
+
+ // both lists in the current msg (i.e., msg3) are null - should not throw an exception
+ assertThatCode(() -> data.reconfigure(update)).doesNotThrowAnyException();
}
@Test