From b65a0d069b8559e8bc5f1448944df5d1a0823805 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 22 Nov 2019 14:57:22 -0500 Subject: 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 Change-Id: I67fa3409424cfdb4b53b17e86f4cf354732d87e8 --- .../pap/main/rest/depundep/PdpGroupDeployProvider.java | 2 ++ .../main/rest/depundep/TestPdpGroupDeployProvider.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'main/src') 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 @@ -232,6 +232,22 @@ public class TestPdpGroupDeployProvider extends ProviderSuper { assertEquals(newgrp.toString(), group.toString()); } + @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"); -- cgit 1.2.3-korg