diff options
Diffstat (limited to 'main/src/test')
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/rest/depundep/TestPdpGroupDeployProvider.java | 33 | ||||
-rw-r--r-- | main/src/test/resources/simpleDeploy/upgradeGroupDao_DiffVers.json | 72 |
2 files changed, 105 insertions, 0 deletions
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 6d193fef..7590c645 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 @@ -522,6 +522,25 @@ public class TestPdpGroupDeployProvider extends ProviderSuper { } @Test + public void testUpdateSubGroup_PolicyVersionMismatch() throws Exception { + PdpGroups groups = loadPdpGroups("createGroups.json"); + PdpGroup newgrp = groups.getGroups().get(0); + PdpGroup dbgroup = new PdpGroup(newgrp); + when(dao.getPdpGroups(dbgroup.getName())).thenReturn(Arrays.asList(dbgroup)); + + // arrange for DB policy version to be different + PdpSubGroup dbsubgrp = dbgroup.getPdpSubgroups().get(0); + dbsubgrp.getPolicies().get(0).setVersion("9.9.9"); + + when(dao.getFilteredPolicyList(any())).thenReturn(loadPolicies("daoPolicyList.json")); + + assertThatThrownBy(() -> prov.createOrUpdateGroups(groups)).isInstanceOf(PfModelException.class) + .hasMessageContaining("different version already deployed"); + + assertNoGroupAction(); + } + + @Test public void testValidateSubGroup_PropertiesMismatch() throws Exception { PdpGroups groups = loadPdpGroups("createGroups.json"); PdpGroup newgrp = groups.getGroups().get(0); @@ -604,6 +623,20 @@ public class TestPdpGroupDeployProvider extends ProviderSuper { } @Test + public void testMakeUpdater_PolicyVersionMismatch() throws Exception { + + // subgroup has a different version of the Policy + when(dao.getFilteredPdpGroups(any())).thenReturn(loadGroups("upgradeGroupDao_DiffVers.json")); + + assertThatThrownBy(() -> prov.deployPolicies(loadRequest())).isInstanceOf(PfModelRuntimeException.class) + .hasMessageContaining("pdpTypeC").hasMessageContaining("different version already deployed"); + + verify(dao, never()).createPdpGroups(any()); + verify(dao, never()).updatePdpGroups(any()); + verify(reqmap, never()).addRequest(any(PdpUpdate.class)); + } + + @Test public void testMakeUpdater_NoPdps() throws Exception { // subgroup has no PDPs diff --git a/main/src/test/resources/simpleDeploy/upgradeGroupDao_DiffVers.json b/main/src/test/resources/simpleDeploy/upgradeGroupDao_DiffVers.json new file mode 100644 index 00000000..3697389e --- /dev/null +++ b/main/src/test/resources/simpleDeploy/upgradeGroupDao_DiffVers.json @@ -0,0 +1,72 @@ +{ + "groups": [ + { + "name": "groupA", + "version": "200.2.3", + "pdpSubgroups": [ + { + "pdpType": "pdpTypeA", + "supportedPolicyTypes": [], + "pdpInstances": [ + { + "instanceId": "pdpA" + } + ], + "policies": [] + }, + { + "pdpType": "pdpTypeB", + "supportedPolicyTypes": [ + { + "name": "typeA", + "version": "100.2.3" + } + ], + "pdpInstances": [ + { + "instanceId": "pdpB" + } + ], + "policies": [] + }, + { + "pdpType": "pdpTypeC", + "supportedPolicyTypes": [ + { + "name": "typeA", + "version": "100.2.3" + } + ], + "pdpInstances": [ + { + "instanceId": "pdpC" + } + ], + "policies": [ + { + "name": "policyA", + "version": "9.9.9", + "type": "typeA", + "type_version": "100.2.3" + } + ] + }, + { + "pdpType": "pdpTypeD", + "supportedPolicyTypes": [ + { + "name": "typeA", + "version": "100.2.3" + } + ], + "pdpInstances": [ + { + "instanceId": "pdpD" + } + ], + "policies": [] + } + ] + } + ] +} |