summaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorChenfei Gao <cgao@research.att.com>2019-04-15 15:56:31 -0400
committerChenfei Gao <cgao@research.att.com>2019-04-16 10:12:30 -0400
commitcd8e3fb51ec888e69378fd43ba43a09cc51a0fd3 (patch)
treed49361b231a6062f16340bd0505da40637ccc3a4 /main/src/test
parente696cd9f5bafd0830017ad38355c2e8fe64f980b (diff)
Preload policy types when api starts up
Includes: a) Preload monitoring and optimization policy types when api component starts up b) Fix the failure unit testing delete policy type c) Enhance several junit test cases to be irrespective of running orders Issue-ID: POLICY-1441 Change-Id: Ia1ba17d58dfbc9a8ee12e789e3867b20111e9cd2 Signed-off-by: Chenfei Gao <cgao@research.att.com>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java16
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java8
-rw-r--r--main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json2
-rw-r--r--main/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json1
4 files changed, 26 insertions, 1 deletions
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
index 653f467e..0ae718d1 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
@@ -171,6 +171,22 @@ public class TestPolicyProvider {
}).hasMessage("policy with ID dummy:dummy and type dummy:dummy does not exist");
assertThatCode(() -> {
+ String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+ ToscaServiceTemplate policyTypeServiceTemplate =
+ standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+ }).doesNotThrowAnyException();
+
+ assertThatCode(() -> {
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ ToscaServiceTemplate policyServiceTemplate =
+ standardCoder.decode(policyString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyProvider
+ .createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+ assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
+ }).doesNotThrowAnyException();
+
+ assertThatCode(() -> {
ToscaServiceTemplate serviceTemplate = policyProvider.deletePolicy(
"onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0");
assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
index 9dc77267..03d49332 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
@@ -129,6 +129,14 @@ public class TestPolicyTypeProvider {
public void testDeletePolicyType() {
assertThatCode(() -> {
+ String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+ ToscaServiceTemplate policyTypeServiceTemplate =
+ standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+ assertFalse(serviceTemplate.getPolicyTypes().get(0).isEmpty());
+ }).doesNotThrowAnyException();
+
+ assertThatCode(() -> {
String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
ToscaServiceTemplate policyServiceTemplate =
standardCoder.decode(policyString, ToscaServiceTemplate.class);
diff --git a/main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json b/main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json
index 638a4e1d..23195a97 100644
--- a/main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json
+++ b/main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json
@@ -6,7 +6,7 @@
"onap.restart.tca": {
"type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
"version": "1.0.0",
- "typeVersion": "2.0.0",
+ "type_version": "2.0.0",
"metadata": {
"policy-id": "onap.restart.tca"
},
diff --git a/main/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json b/main/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json
index 0eabb573..7a63f658 100644
--- a/main/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json
+++ b/main/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json
@@ -6,6 +6,7 @@
"onap.restart.tca": {
"type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
"version": "1.0.0",
+ "type_version": "1.0.0",
"metadata": {
"policy-id": "onap.restart.tca"
},