From 9727c320342dfaffeb13c4b5894fb4a9047943d7 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 19 Mar 2019 16:29:56 +0000 Subject: Move examples into separate module Issue-ID: POLICY-1195 Change-Id: Id2dc5b5b490134648ca267e27b795f3f4c03bc7b Signed-off-by: liamfallon --- .../LegacyOperationalPolicySerializationTest.java | 8 ++++---- .../serialization/MonitoringPolicySerializationTest.java | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'models-tosca/src/test/java') diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java index 76721046e..3c9deb7df 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java @@ -31,7 +31,7 @@ import java.io.IOException; import org.junit.Before; import org.junit.Test; -import org.onap.policy.common.utils.resources.TextFileUtils; +import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.base.PfValidationResult; import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy; import org.onap.policy.models.tosca.legacy.mapping.LegacyOperationalPolicyMapper; @@ -57,9 +57,9 @@ public class LegacyOperationalPolicySerializationTest { @Test public void testJsonDeserialization() throws JsonSyntaxException, IOException { - LegacyOperationalPolicy legacyOperationalPolicy = gson.fromJson( - TextFileUtils.getTextFileAsString("src/test/resources/policies/vCPE.policy.operational.input.json"), - LegacyOperationalPolicy.class); + String vcpePolicyJson = ResourceUtils.getResourceAsString("policies/vCPE.policy.operational.input.json"); + + LegacyOperationalPolicy legacyOperationalPolicy = gson.fromJson(vcpePolicyJson, LegacyOperationalPolicy.class); ToscaServiceTemplate serviceTemplate = new LegacyOperationalPolicyMapper().toToscaServiceTemplate(legacyOperationalPolicy); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java index 4c3cbc85a..565fd6cb4 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java @@ -31,7 +31,7 @@ import java.io.IOException; import org.junit.Before; import org.junit.Test; -import org.onap.policy.common.utils.resources.TextFileUtils; +import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.base.PfValidationResult; import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.simple.serialization.ToscaServiceTemplateMessageBodyHandler; @@ -57,11 +57,9 @@ public class MonitoringPolicySerializationTest { @Test public void testJsonDeserialization() throws JsonSyntaxException, IOException { - ToscaServiceTemplate serviceTemplate = gson.fromJson( - TextFileUtils - .getTextFileAsString("src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json"), - ToscaServiceTemplate.class); + String vcpePolicyJson = ResourceUtils.getResourceAsString("policies/vCPE.policy.monitoring.input.tosca.json"); + ToscaServiceTemplate serviceTemplate = gson.fromJson(vcpePolicyJson, ToscaServiceTemplate.class); assertNotNull(serviceTemplate); LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString()); assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid()); @@ -73,8 +71,9 @@ public class MonitoringPolicySerializationTest { @Test public void testYamlDeserialization() throws JsonSyntaxException, IOException { Yaml yaml = new Yaml(); - Object yamlObject = yaml.load(TextFileUtils - .getTextFileAsString("src/test/resources/policies/vCPE.policy.monitoring.input.tosca.yaml")); + + String vcpePolicyYaml = ResourceUtils.getResourceAsString("policies/vCPE.policy.monitoring.input.tosca.yaml"); + Object yamlObject = yaml.load(vcpePolicyYaml); String yamlAsJsonString = new Gson().toJson(yamlObject); -- cgit 1.2.3-korg