summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-11-22 14:57:22 -0500
committerJim Hahn <jrh3@att.com>2019-11-22 14:57:22 -0500
commitb65a0d069b8559e8bc5f1448944df5d1a0823805 (patch)
tree4854e30c3087322d654ac6e9cae12ad5001ea870
parent855fade6ec6e31a80681c692ddfdc21c97e97b08 (diff)
Update Pdp Group state per PAP API
The PAP API can be used to update the state of a Pdp Group. However, the state wasn't being updated - fixed. Issue-ID: POLICY-2269 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I67fa3409424cfdb4b53b17e86f4cf354732d87e8
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/depundep/PdpGroupDeployProvider.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java16
2 files changed, 18 insertions, 0 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/depundep/PdpGroupDeployProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/depundep/PdpGroupDeployProvider.java
index da9e46f4..2f94d39d 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/depundep/PdpGroupDeployProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/depundep/PdpGroupDeployProvider.java
@@ -192,6 +192,8 @@ public class PdpGroupDeployProvider extends ProviderBase {
}
boolean updated = updateField(dbgroup.getDescription(), group.getDescription(), dbgroup::setDescription);
+ updated = updateField(dbgroup.getPdpGroupState(), group.getPdpGroupState(), dbgroup::setPdpGroupState)
+ || updated;
updated = notifyPdpsDelSubGroups(data, dbgroup, group) || updated;
updated = addOrUpdateSubGroups(data, dbgroup, group, result) || updated;
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java
index 899b5695..60f9d2e8 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java
@@ -233,6 +233,22 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
}
@Test
+ public void testUpdateGroup_NewState() throws Exception {
+ PdpGroups groups = loadPdpGroups("createGroups.json");
+ PdpGroup newgrp = groups.getGroups().get(0);
+ PdpGroup group = new PdpGroup(newgrp);
+ group.setPdpGroupState(PdpState.TEST);
+ when(dao.getPdpGroups(group.getName())).thenReturn(Arrays.asList(group));
+
+ prov.createOrUpdateGroups(groups);
+
+ assertGroupUpdateOnly(group);
+
+ assertEquals(PdpState.ACTIVE, group.getPdpGroupState());
+ assertEquals(newgrp.toString(), group.toString());
+ }
+
+ @Test
public void testUpdateGroup_NewSubGroup() throws Exception {
PdpGroups groups = loadPdpGroups("createGroupsNewSub.json");
PdpGroup group = loadPdpGroups("createGroups.json").getGroups().get(0);