diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-09-16 13:09:46 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-09 12:08:59 -0400 |
commit | c19f81387f4efc666cfa45b000275f3ee7c1d9d1 (patch) | |
tree | 0c6ffe39a15e95f01d40e5a7214bc0d5a9bfa232 /xacml-test/src | |
parent | 6f145256b9d9ac6c0e0b6073afb5d1fa178a84a4 (diff) |
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 <pdragosh@research.att.com>
Diffstat (limited to 'xacml-test/src')
-rw-r--r-- | xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java | 11 |
1 files changed, 8 insertions, 3 deletions
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<ToscaPolicy> 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 // |