diff options
author | Jim Hahn <jrh3@att.com> | 2019-05-10 10:19:43 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-05-10 10:45:00 -0400 |
commit | f9b1e7a0cd418738375505a9269f50f903d459ad (patch) | |
tree | 1aed0143bdefd7d31ab1d631e43c811469581500 /main/src/test | |
parent | 2de7e5642b9a61566e7e6ad52ccdcb5798f0924f (diff) |
Return 200 when policy successfully undeployed
The PAP Undeploy CSIT was failing, because it was returning 400.
The code was counting PDP UPDATE requests to determine whether or
not the policy had been found. However, if a subgroup currently
has no PDPs assigned (as is the case with the CSIT), then there
will be no PDP UPDATEs, thus it will think that the policy was
not found and return 400. Modified the code to count updates to
the DB instead.
Change-Id: I80cdcc738e07c418e0a7184284e7a228e3a6014d
Issue-ID: POLICY-1758
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/test')
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestGroupData.java | 6 | ||||
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestSessionData.java | 15 |
2 files changed, 17 insertions, 4 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestGroupData.java b/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestGroupData.java index 0c14aa2f..92b30b2e 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestGroupData.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestGroupData.java @@ -54,10 +54,12 @@ public class TestGroupData { data = new GroupData(oldGroup, true); assertSame(oldGroup, data.getGroup()); + assertFalse(data.isUnchanged()); assertTrue(data.isNew()); assertFalse(data.isUpdated()); data.update(newGroup); + assertFalse(data.isUnchanged()); assertTrue(data.isNew()); assertFalse(data.isUpdated()); assertSame(newGroup, data.getGroup()); @@ -65,6 +67,7 @@ public class TestGroupData { // repeat with a new group newGroup = new PdpGroup(oldGroup); data.update(newGroup); + assertFalse(data.isUnchanged()); assertTrue(data.isNew()); assertFalse(data.isUpdated()); assertSame(newGroup, data.getGroup()); @@ -72,11 +75,13 @@ public class TestGroupData { @Test public void testUpdateOnly() { + assertTrue(data.isUnchanged()); assertFalse(data.isUpdated()); assertSame(oldGroup, data.getGroup()); data.update(newGroup); + assertFalse(data.isUnchanged()); assertTrue(data.isUpdated()); assertFalse(data.isNew()); assertSame(newGroup, data.getGroup()); @@ -84,6 +89,7 @@ public class TestGroupData { // repeat newGroup = new PdpGroup(oldGroup); data.update(newGroup); + assertFalse(data.isUnchanged()); assertTrue(data.isUpdated()); assertFalse(data.isNew()); assertSame(newGroup, data.getGroup()); diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestSessionData.java b/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestSessionData.java index e7027c51..180c0320 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestSessionData.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestSessionData.java @@ -189,9 +189,7 @@ public class TestSessionData extends ProviderSuper { } @Test - public void testIsUnchanged_testAddRequests_testGetPdpStateChanges_testGetPdpUpdates() { - assertTrue(session.isUnchanged()); - + public void testAddRequests_testGetPdpStateChanges_testGetPdpUpdates() { // pre-load with a update and state-change for other PDPs PdpUpdate update2 = makeUpdate(PDP2); session.addUpdate(update2); @@ -203,7 +201,6 @@ public class TestSessionData extends ProviderSuper { PdpUpdate update = makeUpdate(PDP1); PdpStateChange change = makeStateChange(PDP1); session.addRequests(update, change); - assertFalse(session.isUnchanged()); verifyRequests(update, update2, change, change3); /* @@ -322,13 +319,17 @@ public class TestSessionData extends ProviderSuper { @Test public void testCreate() throws Exception { + assertTrue(session.isUnchanged()); + session.create(group1); assertSame(group1, session.getGroup(group1.getName())); + assertFalse(session.isUnchanged()); // can add another session.create(group2); assertSame(group1, session.getGroup(group1.getName())); assertSame(group2, session.getGroup(group2.getName())); + assertFalse(session.isUnchanged()); // cannot overwrite assertThatIllegalStateException().isThrownBy(() -> session.create(group1)) @@ -337,6 +338,8 @@ public class TestSessionData extends ProviderSuper { @Test public void testUpdate() throws Exception { + assertTrue(session.isUnchanged()); + // force the groups into the cache when(dao.getFilteredPdpGroups(any())).thenReturn(Arrays.asList(group1, group2)); session.getActivePdpGroupsByPolicyType(type); @@ -347,10 +350,12 @@ public class TestSessionData extends ProviderSuper { when(dao.getFilteredPdpGroups(any())).thenReturn(Arrays.asList(group1)); PdpGroup newgrp = new PdpGroup(group1); session.update(newgrp); + assertFalse(session.isUnchanged()); // repeat newgrp = new PdpGroup(group1); session.update(newgrp); + assertFalse(session.isUnchanged()); /* * try group 2 @@ -358,10 +363,12 @@ public class TestSessionData extends ProviderSuper { when(dao.getFilteredPdpGroups(any())).thenReturn(Arrays.asList(group2)); newgrp = new PdpGroup(group2); session.update(newgrp); + assertFalse(session.isUnchanged()); // repeat newgrp = new PdpGroup(group2); session.update(newgrp); + assertFalse(session.isUnchanged()); } @Test |