summaryrefslogtreecommitdiffstats
path: root/applications/common/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-09-12 16:05:18 -0400
committerJim Hahn <jrh3@att.com>2019-09-12 16:20:30 -0400
commit1df1c6aeb21b50ab5c4f7c4a7e6da7bc8abed62e (patch)
treed17b9209b4f26ba6f3a04600b514e90bbdd4cbb8 /applications/common/src
parent88a247ef93ac0f0e2ff00345e0408a2af232b3c9 (diff)
Add yaml support to xacml-pdp rest server
Also modified code to use StandardYamlCoder. Change-Id: I0596c8b054339ac68ef8c4250cd25b9ff88d47e4 Issue-ID: POLICY-2085 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'applications/common/src')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java10
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java1
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java15
3 files changed, 7 insertions, 19 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
index f720fec4..3aa23eee 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
@@ -27,18 +27,17 @@ import java.util.List;
import java.util.Map;
import org.onap.policy.common.utils.coder.CoderException;
-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.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
public class TestUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(TestUtils.class);
- private static final StandardCoder standardCoder = new StandardCoder();
+ private static final StandardYamlCoder yamlCoder = new StandardYamlCoder();
private TestUtils() {
super();
@@ -62,13 +61,10 @@ public class TestUtils {
// Decode it
//
String policyYaml = ResourceUtils.getResourceAsString(resourceFile);
- Yaml yaml = new Yaml();
- Object yamlObject = yaml.load(policyYaml);
- String yamlAsJsonString = standardCoder.encode(yamlObject);
//
// Serialize it into a class
//
- ToscaServiceTemplate serviceTemplate = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class);
//
// Make sure all the fields are setup properly
//
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
index 1c69c7a6..0575ef1b 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
@@ -32,7 +32,6 @@ import com.att.research.xacml.api.Response;
import com.att.research.xacml.api.Result;
import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.std.annotations.RequestParser;
import com.att.research.xacml.util.XACMLPolicyWriter;
import com.google.gson.Gson;
import java.io.ByteArrayOutputStream;
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
index 3e690882..3323040f 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
@@ -49,7 +49,7 @@ import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -59,13 +59,12 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
public class StdMatchableTranslatorTest {
private static final Logger logger = LoggerFactory.getLogger(StdMatchableTranslatorTest.class);
private static final String CLIENT_NAME = "policy-api";
- private static final StandardCoder standardCoder = new StandardCoder();
+ private static final StandardYamlCoder yamlCoder = new StandardYamlCoder();
private static int port;
private static RestServerParameters clientParams;
private static ToscaPolicyType testPolicyType;
@@ -116,13 +115,10 @@ public class StdMatchableTranslatorTest {
// Load our test policy type
//
String policyYaml = ResourceUtils.getResourceAsString("matchable/onap.policies.Test-1.0.0.yaml");
- Yaml yaml = new Yaml();
- Object yamlObject = yaml.load(policyYaml);
- String yamlAsJsonString = standardCoder.encode(yamlObject);
//
// Serialize it into a class
//
- ToscaServiceTemplate serviceTemplate = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class);
//
// Make sure all the fields are setup properly
//
@@ -160,13 +156,10 @@ public class StdMatchableTranslatorTest {
//
String policyYaml = ResourceUtils.getResourceAsString(
"src/test/resources/matchable/test.policies.input.tosca.yaml");
- Yaml yaml = new Yaml();
- Object yamlObject = yaml.load(policyYaml);
- String yamlAsJsonString = standardCoder.encode(yamlObject);
//
// Serialize it into a class
//
- ToscaServiceTemplate serviceTemplate = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class);
//
// Make sure all the fields are setup properly
//