From 05506483dff28c491522beeaaea0f6904077e3ed Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 29 Jun 2020 14:13:14 -0400 Subject: Fix issues in xacml-pdp for new sonar rules Addressed issues reported due to updates to the sonar rules: - invoke only one method in a junit lambda - complete the assertion - use assertThat().exists(), canRead(), etc. Issue-ID: POLICY-2681 Change-Id: I2935f4d0295244ab3b11a57a3bc401c64b695fd1 Signed-off-by: Jim Hahn --- .../policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java | 8 ++++---- .../main/rest/serialization/TestXacmlJsonMessageBodyHandler.java | 1 - .../main/rest/serialization/TestXacmlXmlMessageBodyHandler.java | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'main') diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java index 243c9eab..2a85579c 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java @@ -95,7 +95,7 @@ public class XacmlPdpApplicationManagerTest { // We need at least 1 policies // assertThat(completedJtst).isNotNull(); - assertThat(completedJtst.getToscaTopologyTemplate().getPolicies().size()).isGreaterThan(0); + assertThat(completedJtst.getToscaTopologyTemplate().getPolicies().size()).isPositive(); // // Copy test directory over of the application directories // @@ -141,7 +141,7 @@ public class XacmlPdpApplicationManagerTest { // Test the basics from the startup // assertThat(manager).isNotNull(); - assertThat(manager.getPolicyCount()).isEqualTo(0); + assertThat(manager.getPolicyCount()).isZero(); assertThat(manager.getPolicyTypeCount()).isEqualTo(19); assertThat(manager.getToscaPolicies()).isEmpty(); assertThat(manager.getToscaPolicyIdentifiers()).isEmpty(); @@ -172,11 +172,11 @@ public class XacmlPdpApplicationManagerTest { final ToscaPolicy policyFinal = policy; assertThatCode(() -> { manager.removeUndeployedPolicy(policyFinal); - assertThat(manager.getPolicyCount()).isEqualTo(0); + assertThat(manager.getPolicyCount()).isZero(); manager.loadDeployedPolicy(policyFinal); assertThat(manager.getPolicyCount()).isEqualTo(1); manager.removeUndeployedPolicy(policyFinal); - assertThat(manager.getPolicyCount()).isEqualTo(0); + assertThat(manager.getPolicyCount()).isZero(); }).doesNotThrowAnyException(); // // try loading something unsupported diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java index 0b77650c..1dbbff9d 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java @@ -22,7 +22,6 @@ package org.onap.policy.pdpx.main.rest.serialization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import com.att.research.xacml.api.Request; import com.att.research.xacml.api.RequestAttributes; diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java index ba2bd780..f2e4f4f6 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java @@ -22,7 +22,6 @@ package org.onap.policy.pdpx.main.rest.serialization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import com.att.research.xacml.api.Request; import com.att.research.xacml.api.RequestAttributes; -- cgit 1.2.3-korg