diff options
author | Chenfei Gao <cgao@research.att.com> | 2019-04-15 15:56:31 -0400 |
---|---|---|
committer | Chenfei Gao <cgao@research.att.com> | 2019-04-16 10:12:30 -0400 |
commit | cd8e3fb51ec888e69378fd43ba43a09cc51a0fd3 (patch) | |
tree | d49361b231a6062f16340bd0505da40637ccc3a4 /main/src/test/java/org | |
parent | e696cd9f5bafd0830017ad38355c2e8fe64f980b (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/java/org')
-rw-r--r-- | main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java | 16 | ||||
-rw-r--r-- | main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java | 8 |
2 files changed, 24 insertions, 0 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); |