Add changes to support application/yaml in api
[policy/api.git] / main / src / test / java / org / onap / policy / api / main / rest / provider / TestLegacyGuardPolicyProvider.java
index bfd126e..f83acce 100644 (file)
@@ -39,10 +39,10 @@ import java.util.Map;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onap.policy.api.main.ApiTestSupportUtilities;
 import org.onap.policy.api.main.parameters.ApiParameterGroup;
 import org.onap.policy.common.parameters.ParameterService;
 import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.StandardYamlCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.pdp.concepts.Pdp;
@@ -72,6 +72,7 @@ public class TestLegacyGuardPolicyProvider {
     private static PolicyModelsProviderParameters providerParams;
     private static ApiParameterGroup apiParamGroup;
     private static StandardCoder standardCoder;
+    private static StandardYamlCoder standardYamlCoder;
 
     private static final String POLICY_RESOURCE = "policies/vDNS.policy.guard.frequency.input.json";
     private static final String POLICY_RESOURCE_VER1 = "policies/vDNS.policy.guard.frequency.input.ver1.json";
@@ -95,6 +96,7 @@ public class TestLegacyGuardPolicyProvider {
     public void setupParameters() throws PfModelException {
 
         standardCoder = new StandardCoder();
+        standardYamlCoder = new StandardYamlCoder();
         providerParams = new PolicyModelsProviderParameters();
         providerParams.setDatabaseDriver("org.h2.Driver");
         providerParams.setDatabaseUrl("jdbc:h2:mem:testdb");
@@ -133,10 +135,8 @@ public class TestLegacyGuardPolicyProvider {
         }).hasMessage("legacy policy version is not an integer");
 
         assertThatCode(() -> {
-            String policyTypeString =
-                    ApiTestSupportUtilities.yaml2Json(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE));
-            ToscaServiceTemplate policyTypeServiceTemplate =
-                    standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+            ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
+                    ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
             policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
             String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_VER1);
@@ -225,10 +225,8 @@ public class TestLegacyGuardPolicyProvider {
 
             // Create Policy Type
             assertThatCode(() -> {
-                String policyTypeString =
-                        ApiTestSupportUtilities.yaml2Json(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE));
-                ToscaServiceTemplate policyTypeServiceTemplate =
-                        standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+                ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
+                        ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
                 policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
             }).doesNotThrowAnyException();
 
@@ -281,10 +279,8 @@ public class TestLegacyGuardPolicyProvider {
         }).hasMessage("policy type " + POLICY_TYPE_ID + " for policy " + POLICY_ID + " does not exist");
 
         assertThatCode(() -> {
-            String policyTypeString =
-                    ApiTestSupportUtilities.yaml2Json(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE));
-            ToscaServiceTemplate policyTypeServiceTemplate =
-                    standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+            ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
+                    ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
             policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
             String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
@@ -345,10 +341,8 @@ public class TestLegacyGuardPolicyProvider {
 
             // Create Policy Type
             assertThatCode(() -> {
-                String policyTypeString =
-                        ApiTestSupportUtilities.yaml2Json(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE));
-                ToscaServiceTemplate policyTypeServiceTemplate =
-                        standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+                ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
+                        ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
                 policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
             }).doesNotThrowAnyException();
 
@@ -387,10 +381,8 @@ public class TestLegacyGuardPolicyProvider {
         }).hasMessage("legacy policy version is not an integer");
 
         assertThatCode(() -> {
-            String policyTypeString =
-                    ApiTestSupportUtilities.yaml2Json(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE));
-            ToscaServiceTemplate policyTypeServiceTemplate =
-                    standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+            ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
+                    ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
             policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
             String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);