summaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-04-18 20:24:24 -0400
committerJim Hahn <jrh3@att.com>2019-04-19 09:13:50 -0400
commitd81d38b787fd33cfe221f2ef55fdb913333d479c (patch)
treefc65feba8219e09d6ad53e58ac7e2c11f4d808ab /main/src/test/java/org
parent38a63dbe6ae17e8967a7218e54179733de3579d8 (diff)
Handle null policy lists
UpdateReq throws NPE if the policy list in the request or the response is null. Change-Id: I0d71d6ad4cc9b96315c3b3ba89af8e4d8f3f94e6 Issue-ID: POLICY-1669 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/test/java/org')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java41
1 files changed, 41 insertions, 0 deletions
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 156e9c80..a7987701 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
@@ -73,6 +73,11 @@ public class UpdateReqTest extends CommonRequestBase {
@Test
public void testCheckResponse() {
assertNull(data.checkResponse(response));
+
+ // both policy lists null
+ update.setPolicies(null);
+ response.setPolicies(null);
+ assertNull(data.checkResponse(response));
}
@Test
@@ -114,6 +119,20 @@ public class UpdateReqTest extends CommonRequestBase {
}
@Test
+ public void testUpdateReqCheckResponse_MismatchedPolicies_Null_NotNull() {
+ update.setPolicies(null);
+
+ assertEquals("policies do not match", data.checkResponse(response));
+ }
+
+ @Test
+ public void testUpdateReqCheckResponse_MismatchedPolicies_NotNull_Null() {
+ response.setPolicies(null);
+
+ assertEquals("policies do not match", data.checkResponse(response));
+ }
+
+ @Test
public void isSameContent() {
PdpUpdate msg2 = new PdpUpdate(update);
msg2.setName("world");
@@ -121,6 +140,11 @@ public class UpdateReqTest extends CommonRequestBase {
// different request type
assertFalse(data.isSameContent(new StateChangeReq(reqParams, MY_REQ_NAME, new PdpStateChange())));
+
+ // both policy lists null
+ update.setPolicies(null);
+ msg2.setPolicies(null);
+ assertTrue(data.isSameContent(new UpdateReq(reqParams, MY_REQ_NAME, msg2)));
}
@Test
@@ -177,6 +201,23 @@ public class UpdateReqTest extends CommonRequestBase {
}
@Test
+ public void isSameContent_DiffPolicies_NotNull_Null() {
+ PdpUpdate msg2 = new PdpUpdate(update);
+ msg2.setPolicies(null);
+
+ assertFalse(data.isSameContent(new UpdateReq(reqParams, MY_REQ_NAME, msg2)));
+ }
+
+ @Test
+ public void isSameContent_DiffPolicies_Null_NotNull() {
+ PdpUpdate msg2 = new PdpUpdate(update);
+
+ update.setPolicies(null);
+
+ assertFalse(data.isSameContent(new UpdateReq(reqParams, MY_REQ_NAME, msg2)));
+ }
+
+ @Test
public void testGetPriority() {
assertTrue(data.getPriority() > new StateChangeReq(reqParams, MY_REQ_NAME, new PdpStateChange()).getPriority());
}