aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle
diff options
context:
space:
mode:
Diffstat (limited to 'feature-lifecycle')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java9
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java8
-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
7 files changed, 32 insertions, 30 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 67f5467b..36d2a545 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -45,7 +45,8 @@ import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.drools.controller.DroolsController;
-import org.onap.policy.drools.persistence.SystemPersistence;
+import org.onap.policy.drools.controller.DroolsControllerConstants;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
@@ -116,7 +117,7 @@ public class LifecycleFsm implements Startable {
* Constructor.
*/
public LifecycleFsm() {
- this.properties = SystemPersistence.manager.getProperties(CONFIGURATION_PROPERTIES_NAME);
+ this.properties = SystemPersistenceConstants.getManager().getProperties(CONFIGURATION_PROPERTIES_NAME);
scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
@@ -305,7 +306,7 @@ public class LifecycleFsm implements Startable {
private boolean startTimers() {
statusTask =
- this.scheduler.scheduleAtFixedRate(() -> status(), 0, statusTimerSeconds, TimeUnit.SECONDS);
+ this.scheduler.scheduleAtFixedRate(this::status, 0, statusTimerSeconds, TimeUnit.SECONDS);
return !statusTask.isCancelled() && !statusTask.isDone();
}
@@ -381,7 +382,7 @@ public class LifecycleFsm implements Startable {
private List<ToscaPolicyTypeIdentifier> getCapabilities() {
List<ToscaPolicyTypeIdentifier> capabilities = new ArrayList<>();
- for (DroolsController dc : DroolsController.factory.inventory()) {
+ for (DroolsController dc : DroolsControllerConstants.getFactory().inventory()) {
if (!dc.isBrained()) {
continue;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index d5820d08..c5ea44b2 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -42,6 +42,10 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
private static final Logger logger = LoggerFactory.getLogger(LifecycleStateRunning.class);
+ protected LifecycleStateRunning(LifecycleFsm manager) {
+ super(manager);
+ }
+
protected abstract boolean stateChangeToPassive(@NonNull PdpStateChange change);
protected abstract boolean stateChangeToActive(@NonNull PdpStateChange change);
@@ -50,10 +54,6 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
protected abstract boolean undeployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy);
- protected LifecycleStateRunning(LifecycleFsm manager) {
- super(manager);
- }
-
@Override
public boolean start() {
logger.warn("{}: start", this);
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()