summaryrefslogtreecommitdiffstats
path: root/models-pdp/src/test
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@est.tech>2020-01-21 17:07:50 +0000
committera.sreekumar <ajith.sreekumar@est.tech>2020-01-22 15:11:27 +0000
commit2a7cbf33a8b53bb83d43bf1adca7e6a8658cb262 (patch)
tree73d5216fa7a752ace2b26769251eaf7032293e04 /models-pdp/src/test
parentaf4d20eb737dc7670e811d5272416eec06da1960 (diff)
Handling supported policy type during PdpGroup Update
Change-Id: I469125c232af9d78a55c3dfa71cb701cb3864015 Issue-ID: POLICY-2023 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
Diffstat (limited to 'models-pdp/src/test')
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java42
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java39
2 files changed, 75 insertions, 6 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 a282b7dba..4f11079c2 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
@@ -3,7 +3,7 @@
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -121,6 +121,42 @@ public class PdpGroupTest {
}
@Test
+ public void testValidatePapRest_GroupUpdateFlow() {
+ PdpGroup group = new PdpGroup();
+ group.setName(NAME);
+ // with supported policy type and policies
+ PdpSubGroup subgroup1 = new PdpSubGroup();
+ subgroup1.setDesiredInstanceCount(1);
+ subgroup1.setPdpType(PDP_TYPE1);
+ subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaPolicyTypeIdentifier("a-type-name", "3.2.1")));
+ subgroup1.setPolicies(Collections.emptyList());
+ group.setPdpSubgroups(Arrays.asList(subgroup1));
+
+ ValidationResult result = group.validatePapRest(true);
+ assertNotNull(result);
+ assertTrue(result.isValid());
+ assertNull(result.getResult());
+
+ // without supported policy type and policies
+ PdpSubGroup subgroup2 = new PdpSubGroup();
+ subgroup2.setDesiredInstanceCount(1);
+ subgroup2.setPdpType(PDP_TYPE1);
+ group.setPdpSubgroups(Arrays.asList(subgroup2));
+
+ // valid
+ result = group.validatePapRest(true);
+ assertNotNull(result);
+ assertTrue(result.isValid());
+ assertNull(result.getResult());
+
+ // invalid
+ result = group.validatePapRest(false);
+ assertNotNull(result);
+ assertFalse(result.isValid());
+ assertNotNull(result.getResult());
+ }
+
+ @Test
public void testValidatePapRest() {
PdpGroup group = new PdpGroup();
group.setName(NAME);
@@ -140,7 +176,7 @@ public class PdpGroupTest {
group.setPdpSubgroups(Arrays.asList(subgroup1, subgroup2, subgroup3));
// valid
- ValidationResult result = group.validatePapRest();
+ ValidationResult result = group.validatePapRest(false);
assertNotNull(result);
assertTrue(result.isValid());
assertNull(result.getResult());
@@ -179,7 +215,7 @@ public class PdpGroupTest {
}
private void assertInvalid(PdpGroup group) {
- ValidationResult result = group.validatePapRest();
+ ValidationResult result = group.validatePapRest(false);
assertNotNull(result);
assertFalse(result.isValid());
assertNotNull(result.getResult());
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java
index e24e8e2d6..ba55426c7 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java
@@ -3,7 +3,7 @@
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -91,6 +91,39 @@ public class PdpSubGroupTest {
}
@Test
+ public void testValidatePapRest_GroupUpdateFlow() throws Exception {
+ PdpSubGroup subgrp = new PdpSubGroup();
+ // with supported policy type and policies
+ subgrp.setDesiredInstanceCount(1);
+ subgrp.setPdpType("pdp-type");
+ subgrp.setSupportedPolicyTypes(
+ Arrays.asList(makeIdent("type-X", VERSION_300, ToscaPolicyTypeIdentifier.class)));
+ subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaPolicyIdentifier.class)));
+
+ ValidationResult result = subgrp.validatePapRest(false);
+ assertNotNull(result);
+ assertTrue(result.isValid());
+ assertNull(result.getResult());
+
+ // without supported policy type and policies
+ PdpSubGroup subgrp2 = new PdpSubGroup();
+ subgrp2.setDesiredInstanceCount(1);
+ subgrp2.setPdpType("pdp-type");
+
+ // valid
+ result = subgrp2.validatePapRest(true);
+ assertNotNull(result);
+ assertTrue(result.isValid());
+ assertNull(result.getResult());
+
+ // invalid
+ result = subgrp2.validatePapRest(false);
+ assertNotNull(result);
+ assertFalse(result.isValid());
+ assertNotNull(result.getResult());
+ }
+
+ @Test
public void testValidatePapRest() throws Exception {
PdpSubGroup subgrp = new PdpSubGroup();
@@ -101,7 +134,7 @@ public class PdpSubGroupTest {
subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaPolicyIdentifier.class)));
// valid
- ValidationResult result = subgrp.validatePapRest();
+ ValidationResult result = subgrp.validatePapRest(false);
assertNotNull(result);
assertTrue(result.isValid());
assertNull(result.getResult());
@@ -158,7 +191,7 @@ public class PdpSubGroupTest {
}
private void assertInvalid(PdpSubGroup sub2) {
- ValidationResult result = sub2.validatePapRest();
+ ValidationResult result = sub2.validatePapRest(false);
assertNotNull(result);
assertFalse(result.isValid());
assertNotNull(result.getResult());