From a156cf3cbad6512510ae9a02a13c0408f901c734 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 5 Aug 2019 15:27:16 -0400 Subject: Fix sonar issues in drools-pdp Address sonar issue, "Move constants to a class or enum", by moving them from interfaces to classes: ActiveStandbyFeatureApi StateManagementFeatureApi PolicyResourceLockFeatureApi PolicySessionFeatureApi DroolsController DroolsControllerFeatureApi PolicyControllerFeatureApi PolicyEngineFeatureApi HealthCheck SystemPersistence EventProtocolCoder PolicyController PolicyEngine TestTransaction MdcTransaction Address sonar issue, "Move constants to a class or enum", by change the interface to a class: DroolsProperties Address sonar issue, "Override the "equals" method in this class", by adding equals & hashCode to: DroolsPdpEntity DroolsPdpImpl Use lombok for a number of getters & setters. Address sonar issue, "Define a constant instead of duplicating this literal" in: DroolsPdpsElectionHandler JpaDroolsPdpsConnector MavenDroolsController GenericEventProtocolCoder GsonProtocolCoderToolset RestManager Address sonar issue, "Remove the parentheses around the parameter" in: MavenDroolsController Address sonar issue, "Replace this lambda with a method reference" in: LifecycleFsm Address sonar issue, "Move this constructor to comply with Java Code Conventions" in: LifecycleStateRunning Address sonar issue, "Replace this 'switch' statement by 'if' statements to increase readability", as specified in: PolicyEngineManager Address sonar issue, "Rename field to prevent any misunderstanding/clash with field" in: MdcTransactionImpl Address sonar issue, "Either log or rethrow this exception", in: RestManager Address sonar issue, "Rename this constant name to" uppercase, by replacing enums with static lists in: RestManager Addressed review comments: Fixed license dates. Renamed getSiteName/setSiteName methods to getSite/setSite in the interface to match the field names in the implementation classes. Renamed *Instance classes to *Constants. Next round of review comments. Change-Id: I1c26af9f194833dd773f2b25dc5f60cde163201c Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn --- .../drools/healthcheck/HealthCheckFeatureTest.java | 26 ++++++++++++---------- .../policy/drools/healthcheck/HealthCheckTest.java | 10 ++++----- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'feature-healthcheck/src/test/java/org/onap') diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java index 42d77f26..4d93af23 100644 --- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java +++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-healthcheck * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,8 +42,8 @@ import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.drools.healthcheck.HealthCheck.Report; import org.onap.policy.drools.healthcheck.HealthCheck.Reports; -import org.onap.policy.drools.persistence.SystemPersistence; -import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.drools.persistence.SystemPersistenceConstants; +import org.onap.policy.drools.system.PolicyEngineConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,11 +54,13 @@ public class HealthCheckFeatureTest { */ private static final String HEALTH_CHECK_PROPERTIES_FILE = "feature-healthcheck.properties"; - private static final Path healthCheckPropsPath = Paths - .get(SystemPersistence.manager.getConfigurationPath().toString(), HEALTH_CHECK_PROPERTIES_FILE); + private static final Path healthCheckPropsPath = + Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), + HEALTH_CHECK_PROPERTIES_FILE); - private static final Path healthCheckPropsBackupPath = Paths.get( - SystemPersistence.manager.getConfigurationPath().toString(), HEALTH_CHECK_PROPERTIES_FILE + ".bak"); + private static final Path healthCheckPropsBackupPath = + Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), + HEALTH_CHECK_PROPERTIES_FILE + ".bak"); private static final String EXPECTED = "expected exception"; @@ -131,13 +133,13 @@ public class HealthCheckFeatureTest { public void test() throws IOException, InterruptedException { HealthCheckFeature feature = new HealthCheckFeature(); - feature.afterStart(PolicyEngine.manager); + feature.afterStart(PolicyEngineConstants.getManager()); if (!NetworkUtil.isTcpPortOpen("localhost", 7777, 5, 10000L)) { throw new IllegalStateException("cannot connect to port " + 7777); } - Reports reports = HealthCheck.monitor.healthCheck(); + Reports reports = HealthCheckConstants.getManager().healthCheck(); assertTrue(reports.getDetails().size() > 0); @@ -150,7 +152,7 @@ public class HealthCheckFeatureTest { } } - feature.afterShutdown(PolicyEngine.manager); + feature.afterShutdown(PolicyEngineConstants.getManager()); } @@ -197,7 +199,7 @@ public class HealthCheckFeatureTest { File origPropsFile = new File(healthCheckPropsPath.toString()); File backupPropsFile = new File(healthCheckPropsBackupPath.toString()); - Path configDir = Paths.get(SystemPersistence.DEFAULT_CONFIGURATION_DIR); + Path configDir = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR); try { @@ -243,7 +245,7 @@ public class HealthCheckFeatureTest { } @Override - public HealthCheck getMonitor() { + public HealthCheck getManager() { return checker; } diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java index 2bf1cca5..62c6c951 100644 --- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java +++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java @@ -70,7 +70,7 @@ public class HealthCheckTest { private List servers; private List clients; private PolicyEngine engineMgr; - private HealthCheckMonitor monitor; + private HealthCheckManager monitor; /** * Initializes the object to be tested. @@ -310,23 +310,23 @@ public class HealthCheckTest { @Test public void testHealthCheckMonitor_GetEngineManager() { - assertNotNull(new HealthCheckMonitor().getEngineManager()); + assertNotNull(new HealthCheckManager().getEngineManager()); } @Test public void testHealthCheckMonitor_GetServerFactory() { - assertNotNull(new HealthCheckMonitor().getServerFactory()); + assertNotNull(new HealthCheckManager().getServerFactory()); } @Test public void testHealthCheckMonitor_GetClientFactory() { - assertNotNull(new HealthCheckMonitor().getClientFactory()); + assertNotNull(new HealthCheckManager().getClientFactory()); } /** * Monitor with overrides. */ - private class HealthCheckMonitorImpl extends HealthCheckMonitor { + private class HealthCheckMonitorImpl extends HealthCheckManager { @Override protected PolicyEngine getEngineManager() { -- cgit 1.2.3-korg