From 99231bc9fdb6feb62b9ba3e50796159ed8743b60 Mon Sep 17 00:00:00 2001 From: waynedunican Date: Tue, 30 Jun 2020 12:28:33 +0100 Subject: Replace try/catch blocks with assertj - xacml-pdp Replaced try/catch blocks in policy/xacml-pdp with assertj assertions Issue-ID: POLICY-2451 Change-Id: I3e6947a61e0000561c7053a1cdede9ae5825e5ca Signed-off-by: waynedunican --- .../common/matchable/MatchablePolicyTypeTest.java | 11 ++++------- .../optimization/OptimizationPdpApplicationTest.java | 13 ++++--------- 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'applications') diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java index 9b489a67..508b96ea 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +33,6 @@ import com.att.research.xacml.api.XACML3; import com.att.research.xacml.std.IdentifierImpl; import com.att.research.xacml.util.XACMLPolicyWriter; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -230,12 +230,9 @@ public class MatchablePolicyTypeTest implements MatchableCallback { // // Dump it out so we can see what was created // - try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { - XACMLPolicyWriter.writePolicyFile(os, policy); - LOGGER.info("{}", os); - } catch (IOException e) { - LOGGER.error("Failed to create byte array stream", e); - } + ByteArrayOutputStream os = new ByteArrayOutputStream(); + XACMLPolicyWriter.writePolicyFile(os, policy); + LOGGER.info("{}", os); // // Sanity check - the example policy should have each possible match type plus // an extra one for the list and an extra one for the map. diff --git a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java index 631a359c..862f75a6 100644 --- a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java +++ b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - Modifications Copyright (C) 2019 Nordix Foundation. + Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -468,17 +468,12 @@ public class OptimizationPdpApplicationTest { // // Serialize it into a class // - ToscaServiceTemplate serviceTemplate; - try { - serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class); - } catch (CoderException e) { - throw new XacmlApplicationException("Failed to decode policy from resource file", e); - } + JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate(); + ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class); + jtst.fromAuthorative(serviceTemplate); // // Make sure all the fields are setup properly // - JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate(); - jtst.fromAuthorative(serviceTemplate); ToscaServiceTemplate completedJtst = jtst.toAuthorative(); // // Get the policies -- cgit 1.2.3-korg