aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/feature-controlloop-management/src
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/feature-controlloop-management/src')
-rw-r--r--controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java3
-rw-r--r--controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java26
-rw-r--r--controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java43
3 files changed, 41 insertions, 31 deletions
diff --git a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java
index 3b5792a42..ae19b914e 100644
--- a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java
+++ b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java
@@ -24,6 +24,7 @@ import java.util.stream.Stream;
import org.onap.policy.controlloop.params.ControlLoopParams;
import org.onap.policy.drools.features.PolicyEngineFeatureApi;
import org.onap.policy.drools.system.PolicyController;
+import org.onap.policy.drools.system.PolicyControllerConstants;
/**
* Control Loop Management Feature.
@@ -100,7 +101,7 @@ public class ControlLoopManagementFeature implements PolicyEngineFeatureApi {
*/
public static class Factory {
public PolicyController getController(String controllerName) {
- return PolicyController.factory.get(controllerName);
+ return PolicyControllerConstants.getFactory().get(controllerName);
}
}
}
diff --git a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java
index 4b62e489a..08b218dd6 100644
--- a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java
+++ b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java
@@ -47,8 +47,8 @@ import org.onap.policy.controlloop.params.ControlLoopParams;
import org.onap.policy.controlloop.processor.ControlLoopProcessor;
import org.onap.policy.drools.apps.controlloop.feature.management.ControlLoopManagementFeature;
import org.onap.policy.drools.controller.DroolsController;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyControllerConstants;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.rest.RestManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -206,7 +206,7 @@ public class RestControlLoopManager {
.build();
}
- DroolsController controller = PolicyController.factory.get(controllerName).getDrools();
+ DroolsController controller = PolicyControllerConstants.getFactory().get(controllerName).getDrools();
controlLoop = new ControlLoopParams();
controlLoop.setPolicyScope(controller.getGroupId());
@@ -240,9 +240,13 @@ public class RestControlLoopManager {
return Response
.status(Status.OK)
.entity(new AaiManager(new RestManager())
- .getCustomQueryResponse(PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_URL),
- PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_USERNAME_PROPERTY),
- PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_PASS_PROPERTY),
+ .getCustomQueryResponse(
+ PolicyEngineConstants.getManager()
+ .getEnvironmentProperty(ControlLoopEventManager.AAI_URL),
+ PolicyEngineConstants.getManager().getEnvironmentProperty(
+ ControlLoopEventManager.AAI_USERNAME_PROPERTY),
+ PolicyEngineConstants.getManager().getEnvironmentProperty(
+ ControlLoopEventManager.AAI_PASS_PROPERTY),
UUID.randomUUID(),
vserverId))
.build();
@@ -261,9 +265,13 @@ public class RestControlLoopManager {
return Response
.status(Status.OK)
.entity(new AaiManager(new RestManager())
- .postQuery(PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_URL),
- PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_USERNAME_PROPERTY),
- PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_PASS_PROPERTY),
+ .postQuery(
+ PolicyEngineConstants.getManager()
+ .getEnvironmentProperty(ControlLoopEventManager.AAI_URL),
+ PolicyEngineConstants.getManager().getEnvironmentProperty(
+ ControlLoopEventManager.AAI_USERNAME_PROPERTY),
+ PolicyEngineConstants.getManager().getEnvironmentProperty(
+ ControlLoopEventManager.AAI_PASS_PROPERTY),
ControlLoopEventManager.getAaiNqRequest(vserverId),
UUID.randomUUID()))
.build();
diff --git a/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java b/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java
index ae14a64b7..833adfb69 100644
--- a/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java
+++ b/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java
@@ -46,10 +46,10 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
-import org.onap.policy.drools.persistence.SystemPersistence;
-import org.onap.policy.drools.properties.DroolsProperties;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
+import org.onap.policy.drools.properties.DroolsPropertyConstants;
+import org.onap.policy.drools.system.PolicyControllerConstants;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.drools.util.KieUtils;
import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.simulators.Util;
@@ -97,22 +97,23 @@ public class RestControlLoopManagerTest {
System.setProperty("kie.maven.settings.custom", "src/test/resources/settings.xml");
LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "WARN");
- SystemPersistence.manager.setConfigurationDir("src/test/resources");
- PolicyEngine.manager.configure(PolicyEngine.manager.defaultTelemetryConfig());
+ SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
+ PolicyEngineConstants.getManager().configure(PolicyEngineConstants.getManager().defaultTelemetryConfig());
ReleaseId releaseId =
KieUtils.installArtifact(Paths.get(KMODULE_PATH).toFile(), Paths.get(KMODULE_POM_PATH).toFile(),
KJAR_DRL_PATH, Paths.get(KMODULE_DRL_PATH).toFile());
Properties controllerProperties = new Properties();
- controllerProperties.put(DroolsProperties.RULES_GROUPID, releaseId.getGroupId());
- controllerProperties.put(DroolsProperties.RULES_ARTIFACTID, releaseId.getArtifactId());
- controllerProperties.put(DroolsProperties.RULES_VERSION, releaseId.getVersion());
+ controllerProperties.put(DroolsPropertyConstants.RULES_GROUPID, releaseId.getGroupId());
+ controllerProperties.put(DroolsPropertyConstants.RULES_ARTIFACTID, releaseId.getArtifactId());
+ controllerProperties.put(DroolsPropertyConstants.RULES_VERSION, releaseId.getVersion());
- PolicyEngine.manager.createPolicyController(CONTROLLER, controllerProperties);
- PolicyEngine.manager.start();
+ PolicyEngineConstants.getManager().createPolicyController(CONTROLLER, controllerProperties);
+ PolicyEngineConstants.getManager().start();
- HttpClientFactoryInstance.getClientFactory().build(SystemPersistence.manager.getProperties(CLIENT_CONFIG));
+ HttpClientFactoryInstance.getClientFactory()
+ .build(SystemPersistenceConstants.getManager().getProperties(CLIENT_CONFIG));
if (!NetworkUtil.isTcpPortOpen("localhost", 9696, 6, 10000L)) {
throw new IllegalStateException("cannot connect to port 9696");
@@ -120,9 +121,9 @@ public class RestControlLoopManagerTest {
await().atMost(1, TimeUnit.MINUTES).until(isContainerAlive());
- PolicyEngine.manager.setEnvironmentProperty(ControlLoopEventManager.AAI_URL, "http://localhost:6666");
- PolicyEngine.manager.setEnvironmentProperty(ControlLoopEventManager.AAI_USERNAME_PROPERTY, "AAI");
- PolicyEngine.manager.setEnvironmentProperty(ControlLoopEventManager.AAI_PASS_PROPERTY, "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(ControlLoopEventManager.AAI_URL, "http://localhost:6666");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(ControlLoopEventManager.AAI_USERNAME_PROPERTY, "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(ControlLoopEventManager.AAI_PASS_PROPERTY, "AAI");
Util.buildAaiSim();
}
@@ -132,14 +133,14 @@ public class RestControlLoopManagerTest {
*/
@AfterClass
public static void tearDown() {
- PolicyController.factory.get(CONTROLLER).stop();
+ PolicyControllerConstants.getFactory().get(CONTROLLER).stop();
await().atMost(1, TimeUnit.MINUTES).until(isContainerAlive(), equalTo(Boolean.FALSE));
- PolicyEngine.manager.removePolicyController(CONTROLLER);
- PolicyEngine.manager.stop();
+ PolicyEngineConstants.getManager().removePolicyController(CONTROLLER);
+ PolicyEngineConstants.getManager().stop();
final Path controllerPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), CONTROLLER_FILE);
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), CONTROLLER_FILE);
try {
Files.deleteIfExists(controllerPath);
} catch (Exception ignored) {
@@ -147,7 +148,7 @@ public class RestControlLoopManagerTest {
}
Path controllerBakPath =
- Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), CONTROLLER_FILE_BAK);
+ Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), CONTROLLER_FILE_BAK);
try {
Files.deleteIfExists(controllerBakPath);
@@ -230,6 +231,6 @@ public class RestControlLoopManagerTest {
* @return if the container is alive.
*/
private static Callable<Boolean> isContainerAlive() {
- return () -> PolicyController.factory.get(CONTROLLER).getDrools().getContainer().isAlive();
+ return () -> PolicyControllerConstants.getFactory().get(CONTROLLER).getDrools().getContainer().isAlive();
}
}