From c19f81387f4efc666cfa45b000275f3ee7c1d9d1 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Mon, 16 Sep 2019 13:09:46 -0400 Subject: Sonar xacml-pdp issues Either log or re-throw exception Refactor to not nest more than 3 statements Refactor to throw at most one exception Move variable to comply with Java Code conventions String literal on LHS Issue-ID: POLICY-2079 Change-Id: Iac33623ef4694cf38c4a69c8f0b9040d8439998e Signed-off-by: Pamela Dragosh --- .../java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'xacml-test/src/main/java') diff --git a/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java b/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java index fa7459dc..16bea1d1 100644 --- a/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java +++ b/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java @@ -50,11 +50,10 @@ public class TestUtils { * * @param resourceFile resource file * @param service XacmlApplicationServiceProvider - * @throws CoderException exception if it cannot be decoded * @throws XacmlApplicationException If the application cannot load the policy */ public static List loadPolicies(String resourceFile, XacmlApplicationServiceProvider service) - throws CoderException, XacmlApplicationException { + throws XacmlApplicationException { // // Our return object // @@ -66,7 +65,13 @@ public class TestUtils { // // Serialize it into a class // - ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class); + ToscaServiceTemplate serviceTemplate; + try { + serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class); + } catch (CoderException e) { + throw new XacmlApplicationException("Failed to decode policy from resource file " + + e.getLocalizedMessage()); + } // // Make sure all the fields are setup properly // -- cgit 1.2.3-korg