From d5c365f60e492e37a361654974eba1719146bdc2 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 31 Aug 2020 08:22:13 -0400 Subject: Fix more sonars in drools-pdp Fixed more sonars in drools-pdp: - remove commented code - don't throw generic Exception - unused field (made it protected instead of private) - log conditionally - cognitive complexity - too many break/continue - return empty list instead of null - Random() is not secure Fixed more eclipse warnings: - parameterize generic types Issue-ID: POLICY-2616-sonars3 Change-Id: Ia5ad769b2ea763568cfae3d81807926d89153b09 Signed-off-by: Jim Hahn --- .../statemanagement/test/StateManagementTest.java | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'feature-state-management/src/test/java') diff --git a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java index 33bfaedc..8d47e1d6 100644 --- a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java +++ b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java @@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.util.Properties; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; @@ -37,6 +36,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.policy.common.im.IntegrityMonitorException; import org.onap.policy.common.im.StateManagement; import org.onap.policy.drools.core.PolicySessionFeatureApi; import org.onap.policy.drools.statemanagement.DbAudit; @@ -196,28 +196,18 @@ public class StateManagementTest { repositoryAudit.invoke(fsmProperties); //Should not throw an IOException in Linux Foundation env - assertTrue(true); - } catch (IOException e) { + + } catch (IntegrityMonitorException e) { //Note: this catch is here because in a local environment mvn will not run in //in the temp directory logger.debug("testSubsytemTest RepositoryAudit IOException", e); - } catch (InterruptedException e) { - assertTrue(false); - logger.debug("testSubsytemTest RepositoryAudit InterruptedException", e); } /* ****************Db Audit Test. ************** */ logger.debug("\n\ntestStateManagementOperation: DB Audit\n\n"); - try { - DbAudit dbAudit = (DbAudit) DbAudit.getInstance(); - dbAudit.invoke(fsmProperties); - - assertTrue(true); - } catch (Exception e) { - assertTrue(false); - logger.debug("testSubsytemTest DbAudit exception", e); - } + DbAudit dbAudit = (DbAudit) DbAudit.getInstance(); + dbAudit.invoke(fsmProperties); /* ************IntegrityMonitorRestManager Test. ************ */ logger.debug("\n\ntestStateManagementOperation: IntegrityMonitorRestManager\n\n"); -- cgit 1.2.3-korg