summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-08-05 15:27:16 -0400
committerJim Hahn <jrh3@att.com>2019-08-13 15:58:15 -0400
commita156cf3cbad6512510ae9a02a13c0408f901c734 (patch)
tree0a69bffb2a6c9f961bda1408153cf44f360c6a17 /feature-lifecycle/src/test
parent62d1ff054b0ec6348ab6f7415063fdaa3f425215 (diff)
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 <jrh3@att.com>
Diffstat (limited to 'feature-lifecycle/src/test')
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java21
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java8
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java6
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java6
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java4
5 files changed, 23 insertions, 22 deletions
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java
index 3a3434ac..e82eb42b 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java
@@ -27,8 +27,9 @@ import java.util.Properties;
import lombok.Getter;
import lombok.NonNull;
import org.kie.api.builder.ReleaseId;
-import org.onap.policy.drools.properties.DroolsProperties;
+import org.onap.policy.drools.properties.DroolsPropertyConstants;
import org.onap.policy.drools.system.PolicyController;
+import org.onap.policy.drools.system.PolicyControllerConstants;
import org.onap.policy.drools.util.KieUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -75,27 +76,27 @@ public class ControllerSupport {
Properties controllerProps = new Properties();
- controllerProps.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, name);
- controllerProps.put(DroolsProperties.PROPERTY_CONTROLLER_POLICY_TYPES, getPolicyType());
- controllerProps.put(DroolsProperties.RULES_GROUPID, coordinates.getGroupId());
- controllerProps.put(DroolsProperties.RULES_ARTIFACTID, coordinates.getArtifactId());
- controllerProps.put(DroolsProperties.RULES_VERSION, coordinates.getVersion());
+ controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, name);
+ controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_POLICY_TYPES, getPolicyType());
+ controllerProps.put(DroolsPropertyConstants.RULES_GROUPID, coordinates.getGroupId());
+ controllerProps.put(DroolsPropertyConstants.RULES_ARTIFACTID, coordinates.getArtifactId());
+ controllerProps.put(DroolsPropertyConstants.RULES_VERSION, coordinates.getVersion());
- return PolicyController.factory.build(name, controllerProps);
+ return PolicyControllerConstants.getFactory().build(name, controllerProps);
}
/**
* Destroy the echo controller.
*/
public void destroyController() {
- PolicyController.factory.destroy(name);
+ PolicyControllerConstants.getFactory().destroy(name);
}
/**
* Get controller.
*/
public PolicyController getController() {
- return PolicyController.factory.get(name);
+ return PolicyControllerConstants.getFactory().get(name);
}
/**
@@ -109,7 +110,7 @@ public class ControllerSupport {
* Get facts.
*/
public <T> List<T> getFacts(Class<T> clazz) {
- return PolicyController.factory.get(name)
+ return PolicyControllerConstants.getFactory().get(name)
.getDrools()
.facts(SESSION_NAME, clazz);
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
index 25cce3a9..8ac47e55 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
@@ -25,7 +25,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.onap.policy.drools.persistence.SystemPersistence;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.utils.logging.LoggerUtil;
public abstract class LifecycleStateRunningTest {
@@ -42,7 +42,7 @@ public abstract class LifecycleStateRunningTest {
LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
LoggerUtil.setLevel("org.onap.policy.common.endpoints", "WARN");
LoggerUtil.setLevel("org.onap.policy.drools", "INFO");
- SystemPersistence.manager.setConfigurationDir("target/test-classes");
+ SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
controllerSupport.createController();
}
@@ -52,11 +52,11 @@ public abstract class LifecycleStateRunningTest {
@AfterClass
public static void tearDown() {
try {
- Files.deleteIfExists(Paths.get(SystemPersistence.manager.getConfigurationPath().toString(),
+ Files.deleteIfExists(Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
CONTROLLER_NAME + "-controller.properties.bak"));
} catch (IOException e) {
;
}
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistenceConstants.getManager().setConfigurationDir(null);
}
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
index 50c4f1a7..353525d6 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
@@ -33,7 +33,7 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.drools.persistence.SystemPersistence;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -47,13 +47,13 @@ public class LifecycleStateTerminatedTest {
@BeforeClass
public static void setUp() {
- SystemPersistence.manager.setConfigurationDir("src/test/resources");
+ SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
LoggerUtil.setLevel("org.onap.policy.common.endpoints", "WARN");
}
@AfterClass
public static void tearDown() {
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistenceConstants.getManager().setConfigurationDir(null);
}
@Test
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java
index 01efca32..14da6ab0 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java
@@ -26,7 +26,7 @@ import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.drools.persistence.SystemPersistence;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -39,12 +39,12 @@ public abstract class LifecycleStateUnsupportedTest {
@BeforeClass
public static void setUp() {
- SystemPersistence.manager.setConfigurationDir("src/test/resources");
+ SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
}
@AfterClass
public static void tearDown() {
- SystemPersistence.manager.setConfigurationDir(null);
+ SystemPersistenceConstants.getManager().setConfigurationDir(null);
}
public LifecycleStateUnsupportedTest(LifecycleState state) {
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
index 92269167..da7435f3 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
@@ -33,7 +33,7 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.drools.persistence.SystemPersistence;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.models.pdp.enums.PdpState;
/**
@@ -49,7 +49,7 @@ public class RestLifecycleManagerTest {
HttpServletServerFactoryInstance.getServerFactory().destroy();
HttpClientFactoryInstance.getClientFactory().destroy();
- SystemPersistence.manager.setConfigurationDir("target/test-classes");
+ SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
HttpClientFactoryInstance.getClientFactory().build(
BusTopicParams.builder()