Updates to pulling Drools into own yaml 96/101696/3
authorPamela Dragosh <pdragosh@research.att.com>
Thu, 13 Feb 2020 17:09:13 +0000 (12:09 -0500)
committerPamela Dragosh <pdragosh@research.att.com>
Mon, 17 Feb 2020 15:54:36 +0000 (10:54 -0500)
Also renamed legacy types and constants to ensure folks
know legacy vs tosca compliant.

Fixes recommended by Liam.

Issue-ID: POLICY-2146
Change-Id: I744f589c0154138f8526e583d0f2b480f172c0c4
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
main/src/test/resources/parameters/ApiConfigParameters_Https.json

index 0cca2ff..291bddd 100644 (file)
@@ -190,6 +190,7 @@ public class TestApiRestServer {
         "policytypes/onap.policies.Optimization.yaml",
         LEGACY_POLICYTYPE_OP_RESOURCE,
         TOSCA_POLICYTYPE_OP_RESOURCE,
+        "policytypes/onap.policies.controlloop.operational.common.Drools.yaml",
         "policytypes/onap.policies.controlloop.guard.Blacklist.yaml",
         "policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml",
         "policytypes/onap.policies.controlloop.guard.MinMax.yaml",
@@ -217,9 +218,9 @@ public class TestApiRestServer {
     };
 
     private static final String[] LEGACY_OPERATIONAL_POLICY_RESOURCE_NAMES = {
-        "policies/vCPE.policy.operational.input.json",
-        "policies/vDNS.policy.operational.input.json",
-        "policies/vFirewall.policy.operational.input.json"
+        "policies/vCPE.policy.operational.legacy.input.json",
+        "policies/vDNS.policy.operational.legacy.input.json",
+        "policies/vFirewall.policy.operational.legacy.input.json"
     };
 
     private static PolicyModelsProviderParameters providerParams;
@@ -405,6 +406,11 @@ public class TestApiRestServer {
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
 
         rawResponse = readResource(POLICYTYPES_DROOLS_VERSION, APP_JSON);
+        //
+        // PLD not sure how to fix this? How do I merge 2 policy types?
+        //
+        ErrorResponse errorResponse = rawResponse.readEntity(ErrorResponse.class);
+        System.err.println(errorResponse.getErrorMessage());
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
 
         rawResponse = createResource(POLICIES, TOSCA_POLICY_OP_DROOLS_VCPE_RESOURSE_JSON);
index d812d4e..f9fc666 100644 (file)
@@ -73,7 +73,7 @@ public class TestLegacyOperationalPolicyProvider {
     private static StandardCoder standardCoder;
     private static StandardYamlCoder standardYamlCoder;
 
-    private static final String POLICY_RESOURCE = "policies/vCPE.policy.operational.input.json";
+    private static final String POLICY_RESOURCE = "policies/vCPE.policy.operational.legacy.input.json";
     private static final String POLICY_RESOURCE_WITH_NO_VERSION =
             "policies/vDNS.policy.operational.no.policyversion.json";
     private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policies.controlloop.Operational.yaml";
index 51cd4d3..31be84a 100644 (file)
@@ -83,7 +83,11 @@ public class TestPolicyProvider {
     private static final String MULTIPLE_POLICIES_RESOURCE = "policies/vCPE.policies.optimization.input.tosca.json";
 
     public static final String POLICY_TYPE_RESOURCE_OPERATIONAL =
+            "policytypes/onap.policies.controlloop.Operational.yaml";
+    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON =
             "policytypes/onap.policies.controlloop.operational.Common.yaml";
+    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS =
+            "policytypes/onap.policies.controlloop.operational.common.Drools.yaml";
     private static final String POLICY_RESOURCE_OPERATIONAL = "policies/vCPE.policy.operational.input.tosca.json";
     public static final String POLICY_TYPE_OPERATIONAL_DROOLS = "onap.policies.controlloop.operational.common.Drools";
 
@@ -297,6 +301,15 @@ public class TestPolicyProvider {
     public void testCreateOperationalDroolsPolicy() throws CoderException, PfModelException {
         ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
                 ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL), ToscaServiceTemplate.class);
+
+        policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+        policyTypeServiceTemplate = standardYamlCoder.decode(
+                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
+
+        policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+
+        policyTypeServiceTemplate = standardYamlCoder.decode(
+                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS), ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_OPERATIONAL);
index 8f5657b..3c64e64 100644 (file)
@@ -66,8 +66,10 @@ public class TestPolicyTypeProvider {
             "policytypes/onap.policies.optimization.Resource.no.version.yaml";
     private static final String POLICY_TYPE_NAME_MONITORING = "onap.policies.monitoring.cdap.tca.hi.lo.app";
 
-    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL =
+    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON =
             "policytypes/onap.policies.controlloop.operational.Common.yaml";
+    public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS =
+            "policytypes/onap.policies.controlloop.operational.common.Drools.yaml";
     public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_APEX =
             "policytypes/onap.policies.controlloop.operational.common.Apex.yaml";
     public static final String POLICY_TYPE_OPERATIONAL_COMMON = "onap.policies.controlloop.operational.Common";
@@ -164,10 +166,14 @@ public class TestPolicyTypeProvider {
     @Test
     public void testCreateOperationalPolicyTypes() throws CoderException, PfModelException {
         ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL), ToscaServiceTemplate.class);
+                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
         ToscaServiceTemplate serviceTemplate = policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         assertNotNull(serviceTemplate.getPolicyTypes().get(POLICY_TYPE_OPERATIONAL_COMMON));
+
+        policyTypeServiceTemplate = standardYamlCoder.decode(
+                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS), ToscaServiceTemplate.class);
+        serviceTemplate = policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
         assertNotNull(serviceTemplate.getPolicyTypes().get(POLICY_TYPE_OPERATIONAL_DROOLS));
 
         policyTypeProvider.deletePolicyType(POLICY_TYPE_OPERATIONAL_DROOLS, POLICY_TYPE_VERSION);
@@ -177,7 +183,7 @@ public class TestPolicyTypeProvider {
     @Test
     public void testCreateApexOperationalPolicyTypes() throws CoderException, PfModelException {
         ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL), ToscaServiceTemplate.class);
+                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
         ToscaServiceTemplate serviceTemplate = policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
         policyTypeServiceTemplate = standardYamlCoder.decode(
                 ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_APEX), ToscaServiceTemplate.class);
index a48847c..29745fb 100644 (file)
@@ -42,6 +42,7 @@
         "policytypes/onap.policies.native.Xacml.yaml",
         "policytypes/onap.policies.native.Apex.yaml",
         "policytypes/onap.policies.controlloop.operational.Common.yaml",
-        "policytypes/onap.policies.controlloop.operational.common.Apex.yaml"
+        "policytypes/onap.policies.controlloop.operational.common.Apex.yaml",
+        "policytypes/onap.policies.controlloop.operational.common.Drools.yaml"
     ]
 }