aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-04-13 20:26:33 -0400
committerJim Hahn <jrh3@att.com>2019-04-13 20:37:25 -0400
commitddd8b56d7bce562a9990199af9bfe36be4c2ca56 (patch)
tree4ee45c06a721f10dc2e1037851f788c6ded9c800 /models-pdp/src/test
parentc38fcf1a16f0d6bfdf2d80efa64a94ae68d80f03 (diff)
Disallow empty subgroup list in group request
Change-Id: I8a00caf1b22363fe3ab90bdf57244af687a2cb6d Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src/test')
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java17
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java12
2 files changed, 21 insertions, 8 deletions
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java
index 0df2d34d9..a717dc2d8 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java
@@ -56,7 +56,7 @@ public class PdpGroupTest {
// verify with null values
assertEquals("PdpGroup(name=null, description=null, pdpGroupState=null, " + "properties=null, pdpSubgroups=[])",
- new PdpGroup(orig).toString());
+ new PdpGroup(orig).toString());
// verify with all values
orig.setDescription("my-descript");
@@ -77,11 +77,11 @@ public class PdpGroupTest {
orig.setProperties(props);
assertEquals("PdpGroup(name=my-name, description=my-description, "
- + "pdpGroupState=SAFE, properties={key-A=value-A, key-B=value-B}, "
- + "pdpSubgroups=[PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], "
- + "currentInstanceCount=10, desiredInstanceCount=0, properties=null, pdpInstances=[]), "
- + "PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], currentInstanceCount=11, "
- + "desiredInstanceCount=0, properties=null, pdpInstances=[])])", new PdpGroup(orig).toString());
+ + "pdpGroupState=SAFE, properties={key-A=value-A, key-B=value-B}, "
+ + "pdpSubgroups=[PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], "
+ + "currentInstanceCount=10, desiredInstanceCount=0, properties=null, pdpInstances=[]), "
+ + "PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], currentInstanceCount=11, "
+ + "desiredInstanceCount=0, properties=null, pdpInstances=[])])", new PdpGroup(orig).toString());
}
@Test
@@ -154,6 +154,11 @@ public class PdpGroupTest {
group2.setPdpSubgroups(null);
assertInvalid(group2);
+ // empty subgroup list
+ group2 = new PdpGroup(group);
+ group2.setPdpSubgroups(Collections.emptyList());
+ assertInvalid(group2);
+
// null subgroup
group2 = new PdpGroup(group);
group2.setPdpSubgroups(Arrays.asList(subgroup1, null));
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java
index e0fafc18d..bd98f18c3 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java
@@ -34,6 +34,7 @@ import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
public class PdpGroupsTest {
@@ -41,11 +42,18 @@ public class PdpGroupsTest {
public void testValidatePapRest_toMapList() {
PdpGroup group1 = new PdpGroup();
group1.setName("group-1");
- group1.setPdpSubgroups(Collections.emptyList());
+
+ PdpSubGroup subgrp = new PdpSubGroup();
+ subgrp.setDesiredInstanceCount(1);
+ subgrp.setPdpType("pdp-type");
+ subgrp.setSupportedPolicyTypes(Arrays.asList(new ToscaPolicyTypeIdentifier("policy-type", "9.8.7")));
+ subgrp.setPolicies(Collections.emptyList());
+
+ group1.setPdpSubgroups(Arrays.asList(subgrp));
PdpGroup group2 = new PdpGroup();
group2.setName("group-2");
- group2.setPdpSubgroups(Collections.emptyList());
+ group2.setPdpSubgroups(Arrays.asList(subgrp));
PdpGroups groups = new PdpGroups();
groups.setGroups(Arrays.asList(group1, group2));