summaryrefslogtreecommitdiffstats
path: root/controlloop/common/guard/src
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/guard/src')
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java2
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java9
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java13
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java28
4 files changed, 25 insertions, 27 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
index 22fce1999..611dd2d8b 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
@@ -66,7 +66,7 @@ public class CallGuardTask implements Runnable {
private PolicyGuardResponse guardResponse;
/**
- * Guard url is grabbed from PolicyEngine.manager properties
+ * Guard url is grabbed from PolicyEngine manager properties.
*/
public CallGuardTask(WorkingMemory wm, String cl, String act,
String rec, String tar, String reqId, Supplier<Integer> vfcnt) {
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
index 53f1cea4b..ed6cd6c5f 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
@@ -24,13 +24,12 @@ package org.onap.policy.guard;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.rest.RestManager;
@@ -50,9 +49,9 @@ public class PolicyGuardXacmlHelper {
* Constructor.
*/
public PolicyGuardXacmlHelper() {
- this.url = PolicyEngine.manager.getEnvironmentProperty("guard.url");
- this.user = PolicyEngine.manager.getEnvironmentProperty("pdpx.username");
- this.pwd = PolicyEngine.manager.getEnvironmentProperty("pdpx.password");
+ this.url = PolicyEngineConstants.getManager().getEnvironmentProperty("guard.url");
+ this.user = PolicyEngineConstants.getManager().getEnvironmentProperty("pdpx.username");
+ this.pwd = PolicyEngineConstants.getManager().getEnvironmentProperty("pdpx.password");
}
/**
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
index d859fbe09..717ca3f45 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
@@ -25,11 +25,10 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-
import org.apache.commons.io.IOUtils;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
@@ -135,16 +134,16 @@ public final class Util {
* <p>see /guard/src/test/java/org/onap/policy/guard/UtilTest.java for setting test properties
*/
public static void setGuardEnvProps(String url, String username, String password) {
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_URL, url);
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, username);
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, password);
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_URL, url);
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, username);
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, password);
}
public static void setGuardEnvProp(String key, String value) {
- PolicyEngine.manager.setEnvironmentProperty(key, value);
+ PolicyEngineConstants.getManager().setEnvironmentProperty(key, value);
}
public static String getGuardProp(String propName) {
- return PolicyEngine.manager.getEnvironmentProperty(propName);
+ return PolicyEngineConstants.getManager().getEnvironmentProperty(propName);
}
}
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java
index 9d252b9f1..d0194da38 100644
--- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java
+++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardXacmlHelperTest.java
@@ -28,7 +28,7 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.drools.utils.logging.LoggerUtil;
public class PolicyGuardXacmlHelperTest {
@@ -106,45 +106,45 @@ public class PolicyGuardXacmlHelperTest {
@Test
public void testInit() {
- final Properties savedEnvironment = (Properties) PolicyEngine.manager.getEnvironment().clone();
+ final Properties savedEnvironment = (Properties) PolicyEngineConstants.getManager().getEnvironment().clone();
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().setProperty(GUARD_URL,
+ PolicyEngineConstants.getManager().getEnvironment().setProperty(GUARD_URL,
"http://localhost:6669/pdp/api/getDecision,Dorothy");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().setProperty(GUARD_URL,
+ PolicyEngineConstants.getManager().getEnvironment().setProperty(GUARD_URL,
"http://localhost:6669/pdp/api/getDecision,Dorothy,Toto");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().setProperty(GUARD_URL,
+ PolicyEngineConstants.getManager().getEnvironment().setProperty(GUARD_URL,
"http://localhost:6969/policy/pdpx/v1/decision");
- PolicyEngine.manager.getEnvironment().setProperty("pdpx.timeout", "thisIsNotANumber");
+ PolicyEngineConstants.getManager().getEnvironment().setProperty("pdpx.timeout", "thisIsNotANumber");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().setProperty("pdpx.timeout", "1000");
+ PolicyEngineConstants.getManager().getEnvironment().setProperty("pdpx.timeout", "1000");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().remove("pdpx.password");
+ PolicyEngineConstants.getManager().getEnvironment().remove("pdpx.password");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().setProperty("pdpx.username", "python");
+ PolicyEngineConstants.getManager().getEnvironment().setProperty("pdpx.username", "python");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().setProperty(GUARD_URL, "///");
+ PolicyEngineConstants.getManager().getEnvironment().setProperty(GUARD_URL, "///");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().setProperty("guard.disabled", "");
+ PolicyEngineConstants.getManager().getEnvironment().setProperty("guard.disabled", "");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().setProperty("guard.disabled", "true");
+ PolicyEngineConstants.getManager().getEnvironment().setProperty("guard.disabled", "true");
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.getEnvironment().clear();
+ PolicyEngineConstants.getManager().getEnvironment().clear();
assertNotNull(new PolicyGuardXacmlHelper());
- PolicyEngine.manager.setEnvironment(savedEnvironment);
+ PolicyEngineConstants.getManager().setEnvironment(savedEnvironment);
}
}