From 5bc83b197ad010bbdf5916493d078818c2c10bcb Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 22 Oct 2019 13:06:56 -0400 Subject: Consolidate common translatable code some sonar There is duplicate code for some common translation of policy decision responses and for scanning obligations. Removed some TODO items (left others because I want to look at them more closely). Stored System.lineSeparator into a static var so that I can remove some unnecessary ifs. There's still one left that I am not worried about. Gson as a static variable. Issue-ID: POLICY-2066 Change-Id: I9c8162d5ad1c5f884be347dd94631fa74ca76f85 Signed-off-by: Pamela Dragosh --- .../policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java | 4 ++-- .../pdp/xacml/application/common/std/StdMatchableTranslatorTest.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'applications/common/src/test/java/org') diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java index 318d9f9f..1e13d529 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java @@ -222,7 +222,7 @@ public class XacmlPolicyUtilsTest { // try (OutputStream os = new ByteArrayOutputStream()) { XACMLPolicyWriter.writePolicyFile(os, rootPolicy); - LOGGER.debug("New Root Policy:{}{}", System.lineSeparator(), os.toString()); + LOGGER.debug("New Root Policy:{}{}", XacmlPolicyUtils.LINE_SEPARATOR, os); } // // Just update root and PolicySet @@ -230,7 +230,7 @@ public class XacmlPolicyUtilsTest { XacmlPolicyUtils.addPolicySetsToXacmlRootPolicy(rootPolicy, policySet5); try (OutputStream os = new ByteArrayOutputStream()) { XACMLPolicyWriter.writePolicyFile(os, rootPolicy); - LOGGER.debug("New Root Policy:{}{}", System.lineSeparator(), os.toString()); + LOGGER.debug("New Root Policy:{}{}", XacmlPolicyUtils.LINE_SEPARATOR, os); } }).doesNotThrowAnyException(); } 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 3323040f..07317c0a 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 @@ -57,6 +57,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException; +import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -131,7 +132,7 @@ public class StdMatchableTranslatorTest { assertEquals(1, completedJtst.getPolicyTypes().size()); testPolicyType = completedJtst.getPolicyTypes().get("onap.policies.Test"); assertNotNull(testPolicyType); - logger.info("Test Policy Type {}{}", System.lineSeparator(), testPolicyType); + logger.info("Test Policy Type {}{}", XacmlPolicyUtils.LINE_SEPARATOR, testPolicyType); } @AfterClass @@ -173,7 +174,7 @@ public class StdMatchableTranslatorTest { for (ToscaPolicy policy : policies.values()) { PolicyType translatedPolicy = translator.convertPolicy(policy); assertNotNull(translatedPolicy); - logger.info("Translated policy {} {}", System.lineSeparator(), translatedPolicy); + logger.info("Translated policy {} {}", XacmlPolicyUtils.LINE_SEPARATOR, translatedPolicy); } } } -- cgit 1.2.3-korg