aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java22
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java40
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java14
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java32
-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
-rw-r--r--controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java8
-rw-r--r--controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java14
-rw-r--r--controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java4
-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
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl66
-rw-r--r--controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl68
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java156
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java156
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopBase.java229
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java26
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java164
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java36
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java165
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java156
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java157
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java167
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java171
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java171
28 files changed, 543 insertions, 1603 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index 298513619..aaccef60b 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -58,7 +58,7 @@ import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.FinalResult;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.processor.ControlLoopProcessor;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.guard.GuardResult;
import org.onap.policy.guard.LockCallback;
import org.onap.policy.guard.PolicyGuard;
@@ -888,9 +888,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
try {
if (vserverName != null) {
- String aaiHostUrl = PolicyEngine.manager.getEnvironmentProperty(AAI_URL);
- String aaiUser = PolicyEngine.manager.getEnvironmentProperty(AAI_USERNAME_PROPERTY);
- String aaiPassword = PolicyEngine.manager.getEnvironmentProperty(AAI_PASS_PROPERTY);
+ String aaiHostUrl = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_URL);
+ String aaiUser = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_USERNAME_PROPERTY);
+ String aaiPassword = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_PASS_PROPERTY);
String aaiGetQueryByVserver = "/aai/v11/nodes/vservers?vserver-name=";
String url = aaiHostUrl + aaiGetQueryByVserver;
logger.info("AAI Host URL by VServer: {}", url);
@@ -918,9 +918,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
String vnfName = event.getAai().get(GENERIC_VNF_VNF_NAME);
String vnfId = event.getAai().get(GENERIC_VNF_VNF_ID);
- String aaiHostUrl = PolicyEngine.manager.getEnvironmentProperty(AAI_URL);
- String aaiUser = PolicyEngine.manager.getEnvironmentProperty(AAI_USERNAME_PROPERTY);
- String aaiPassword = PolicyEngine.manager.getEnvironmentProperty(AAI_PASS_PROPERTY);
+ String aaiHostUrl = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_URL);
+ String aaiUser = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_USERNAME_PROPERTY);
+ String aaiPassword = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_PASS_PROPERTY);
try {
if (vnfName != null) {
@@ -1024,7 +1024,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
* @return the property value
*/
private static String getPeManagerEnvProperty(String enginePropertyName) {
- String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName);
+ String enginePropertyValue = PolicyEngineConstants.getManager().getEnvironmentProperty(enginePropertyName);
if (enginePropertyValue == null) {
throw new IllegalArgumentException("The value of policy engine manager environment property \""
+ enginePropertyName + "\" may not be null");
@@ -1082,9 +1082,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
AaiCqResponse response = null;
String vserverId = event.getAai().get(VSERVER_VSERVER_NAME);
- String aaiHostUrl = PolicyEngine.manager.getEnvironmentProperty(AAI_URL);
- String aaiUser = PolicyEngine.manager.getEnvironmentProperty(AAI_USERNAME_PROPERTY);
- String aaiPassword = PolicyEngine.manager.getEnvironmentProperty(AAI_PASS_PROPERTY);
+ String aaiHostUrl = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_URL);
+ String aaiUser = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_USERNAME_PROPERTY);
+ String aaiPassword = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_PASS_PROPERTY);
response = new AaiManager(new RestManager()).getCustomQueryResponse(aaiHostUrl, aaiUser, aaiPassword, reqId,
vserverId);
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index cac1b8ee3..293fa43aa 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -52,7 +52,7 @@ import org.onap.policy.controlloop.actor.vfc.VfcActorServiceProvider;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.database.operationshistory.Dbao;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.guard.Util;
import org.onap.policy.sdnc.SdncResponse;
import org.onap.policy.sdnr.PciResponseWrapper;
@@ -141,7 +141,7 @@ public class ControlLoopOperationManager implements Serializable {
* The target vnf-id may not be the same as the source vnf-id specified in the yaml, the target
* vnf-id is retrieved by a named query to A&AI.
*/
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
GenericVnf genvnf = this.eventManager.getCqResponse((VirtualControlLoopEvent) onset)
.getGenericVnfByModelInvariantId(policy.getTarget().getResourceID());
if (genvnf == null) {
@@ -153,9 +153,9 @@ public class ControlLoopOperationManager implements Serializable {
} else {
this.targetEntity =
AppcLcmActorServiceProvider.vnfNamedQuery(policy.getTarget().getResourceID(),
- this.targetEntity, PolicyEngine.manager.getEnvironmentProperty("aai.url"),
- PolicyEngine.manager.getEnvironmentProperty("aai.username"),
- PolicyEngine.manager.getEnvironmentProperty("aai.password"));
+ this.targetEntity, PolicyEngineConstants.getManager().getEnvironmentProperty("aai.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("aai.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("aai.password"));
}
}
}
@@ -260,7 +260,7 @@ public class ControlLoopOperationManager implements Serializable {
*/
try {
String vnfId;
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
vnfId = this.eventManager.getCqResponse((VirtualControlLoopEvent) onset).getDefaultGenericVnf()
.getVnfId();
} else {
@@ -347,7 +347,7 @@ public class ControlLoopOperationManager implements Serializable {
private Object startSoOperation(ControlLoopEvent onset, Operation operation) throws AaiException {
SoActorServiceProvider soActorSp = new SoActorServiceProvider();
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
this.operationRequest =
soActorSp.constructRequestCq((VirtualControlLoopEvent) onset, operation.clOperation,
this.policy, eventManager.getCqResponse((VirtualControlLoopEvent) onset));
@@ -368,16 +368,16 @@ public class ControlLoopOperationManager implements Serializable {
private Object startVfcOperation(ControlLoopEvent onset, Operation operation) throws AaiException {
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
this.operationRequest = VfcActorServiceProvider.constructRequestCq((VirtualControlLoopEvent) onset,
operation.clOperation, this.policy,
eventManager.getCqResponse((VirtualControlLoopEvent) onset));
} else {
this.operationRequest = VfcActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset,
operation.clOperation, this.policy, this.eventManager.getVnfResponse(),
- PolicyEngine.manager.getEnvironmentProperty("vfc.url"),
- PolicyEngine.manager.getEnvironmentProperty("vfc.username"),
- PolicyEngine.manager.getEnvironmentProperty("vfc.password"));
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.password"));
}
this.currentOperation = operation;
if (this.operationRequest == null) {
@@ -951,7 +951,8 @@ public class ControlLoopOperationManager implements Serializable {
private void storeOperationInDataBase() {
// Only store in DB if enabled
- boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngine.manager.getEnvironmentProperty("guard.disabled"));
+ boolean guardEnabled = "false"
+ .equalsIgnoreCase(PolicyEngineConstants.getManager().getEnvironmentProperty("guard.disabled"));
if (!guardEnabled) {
return;
}
@@ -959,12 +960,15 @@ public class ControlLoopOperationManager implements Serializable {
// DB Properties
Properties props = new Properties();
- if (PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL) != null
- && PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER) != null
- && PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS) != null) {
- props.put(Util.ECLIPSE_LINK_KEY_URL, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL));
- props.put(Util.ECLIPSE_LINK_KEY_USER, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER));
- props.put(Util.ECLIPSE_LINK_KEY_PASS, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS));
+ if (PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_URL) != null
+ && PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_USER) != null
+ && PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_PASS) != null) {
+ props.put(Util.ECLIPSE_LINK_KEY_URL,
+ PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_URL));
+ props.put(Util.ECLIPSE_LINK_KEY_USER,
+ PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_USER));
+ props.put(Util.ECLIPSE_LINK_KEY_PASS,
+ PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_PASS));
props.put(PersistenceUnitProperties.CLASSLOADER, ControlLoopOperationManager.class.getClassLoader());
}
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
index b7dc1f0d9..0b27ffa49 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
@@ -65,7 +65,7 @@ import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NewEventStatus;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.PolicyResult;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.guard.GuardResult;
import org.onap.policy.guard.PolicyGuard;
import org.onap.policy.guard.PolicyGuard.LockResult;
@@ -115,9 +115,9 @@ public class ControlLoopEventManagerTest {
public static void setUpSimulator() throws Exception {
org.onap.policy.simulators.Util.buildAaiSim();
- PolicyEngine.manager.setEnvironmentProperty(AAI_USERNAME, "AAI");
- PolicyEngine.manager.setEnvironmentProperty(AAI_PASS, "AAI");
- PolicyEngine.manager.setEnvironmentProperty(AAI_URL, "http://localhost:6666");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_USERNAME, "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_PASS, "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_URL, "http://localhost:6666");
}
@AfterClass
@@ -141,7 +141,7 @@ public class ControlLoopEventManagerTest {
onset.getAai().put(VNF_ID, VNF_UUID);
onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- PolicyEngine.manager.setEnvironmentProperty(AAI_URL, "http://localhost:6666");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_URL, "http://localhost:6666");
}
@Test
@@ -1008,7 +1008,7 @@ public class ControlLoopEventManagerTest {
@Test(expected = AaiException.class)
public void testQueryAai_QueryException() throws AaiException {
// Force AAI errors
- PolicyEngine.manager.setEnvironmentProperty(AAI_URL, INVALID_URL);
+ PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_URL, INVALID_URL);
makeManager(onset).queryAai(onset);
}
@@ -1231,7 +1231,7 @@ public class ControlLoopEventManagerTest {
// Force AAI error
- PolicyEngine.manager.setEnvironmentProperty(AAI_URL, INVALID_URL);
+ PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_URL, INVALID_URL);
// re-create manager
manager = makeManager(onset);
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
index 13fe72517..9b1633521 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
@@ -68,7 +68,7 @@ import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.controlloop.policy.Target;
import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.controlloop.processor.ControlLoopProcessor;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.so.SoResponse;
import org.onap.policy.so.SoResponseWrapper;
import org.onap.policy.vfc.VfcResponse;
@@ -108,9 +108,9 @@ public class ControlLoopOperationManagerTest {
onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
/* Set environment properties */
- PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
- PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI");
- PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.url", "http://localhost:6666");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.username", "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.password", "AAI");
}
private static EntityManagerFactory emf;
@@ -138,9 +138,9 @@ public class ControlLoopOperationManagerTest {
System.setProperty(OPERATIONS_HISTORY_PU, OPERATIONS_HISTORY_PU_TEST);
// Enter dummy props to avoid nullPointerException
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_URL, "a");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_USER, "b");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_PASS, "c");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_URL, "a");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_USER, "b");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_PASS, "c");
// Connect to in-mem db
emf = Persistence.createEntityManagerFactory(OPERATIONS_HISTORY_PU_TEST);
@@ -443,7 +443,7 @@ public class ControlLoopOperationManagerTest {
onsetEvent.getAai().remove(VNF_ID);
manager.getVnfResponse();
- if (!Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty("aai.customQuery"))) {
+ if (!Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty("aai.customQuery"))) {
clom.getEventManager().getVnfResponse().setVnfId(VNF_ID);
assertEquals(VNF_ID, clom.getTarget(policy));
}
@@ -733,11 +733,11 @@ public class ControlLoopOperationManagerTest {
SoResponse soResponse = new SoResponse();
final SoResponseWrapper soRw = new SoResponseWrapper(soResponse, null);
- PolicyEngine.manager.setEnvironmentProperty("guard.disabled", "false");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_URL,
+ PolicyEngineConstants.getManager().setEnvironmentProperty("guard.disabled", "false");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_URL,
"http://somewhere.over.the.rainbow");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_USER, DOROTHY);
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_PASS, "Toto");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_USER, DOROTHY);
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_PASS, "Toto");
assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw));
@@ -822,11 +822,11 @@ public class ControlLoopOperationManagerTest {
SoResponse soResponse = new SoResponse();
final SoResponseWrapper soRw = new SoResponseWrapper(soResponse, null);
- PolicyEngine.manager.setEnvironmentProperty("guard.disabled", "false");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_URL,
+ PolicyEngineConstants.getManager().setEnvironmentProperty("guard.disabled", "false");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_URL,
"http://somewhere.over.the.rainbow");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_USER, DOROTHY);
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_PASS, "Toto");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_USER, DOROTHY);
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.ONAP_KEY_PASS, "Toto");
assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw));
assertFalse(clom.isOperationRunning());
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();
}
}
diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
index b2a82a29e..9dc4c5ad3 100644
--- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
+++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
@@ -24,7 +24,6 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalListener;
-
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.ArrayList;
@@ -32,10 +31,9 @@ import java.util.List;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
-import org.onap.policy.drools.persistence.SystemPersistence;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.utils.logging.MdcTransaction;
import org.slf4j.Logger;
@@ -57,8 +55,8 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
public CacheBasedControlLoopMetricsManager() {
- Properties properties =
- SystemPersistence.manager.getProperties(ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME);
+ Properties properties = SystemPersistenceConstants.getManager()
+ .getProperties(ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME);
/* cache size */
diff --git a/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java b/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
index bbbcc132f..b416736ab 100644
--- a/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
+++ b/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
@@ -36,9 +36,9 @@ import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
-import org.onap.policy.drools.persistence.SystemPersistence;
+import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
/**
* ControlLoopMetrics Tests.
@@ -46,7 +46,7 @@ import org.onap.policy.drools.system.PolicyEngine;
public class ControlLoopMetricsFeatureTest {
private static final String POLICY_CL_MGT = "POLICY-CL-MGT";
- private static final Path configPath = SystemPersistence.manager.getConfigurationPath();
+ private static final Path configPath = SystemPersistenceConstants.getManager().getConfigurationPath();
private static PolicyController testController;
/**
@@ -54,14 +54,14 @@ public class ControlLoopMetricsFeatureTest {
*/
@BeforeClass
public static void setUp() {
- SystemPersistence.manager.setConfigurationDir("src/test/resources");
- testController = PolicyEngine.manager.createPolicyController("metrics",
- SystemPersistence.manager.getControllerProperties("metrics"));
+ SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
+ testController = PolicyEngineConstants.getManager().createPolicyController("metrics",
+ SystemPersistenceConstants.getManager().getControllerProperties("metrics"));
}
@AfterClass
public static void tearDown() {
- SystemPersistence.manager.setConfigurationDir(configPath.toString());
+ SystemPersistenceConstants.getManager().setConfigurationDir(configPath.toString());
}
@Test
diff --git a/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java
index 899b7ce8e..3999797a9 100644
--- a/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java
+++ b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNotNull;
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;
import org.onap.policy.simulators.Util;
@@ -38,7 +38,7 @@ public class ControlLoopUtilsFeatureTest {
LoggerUtil.setLevel("ROOT", "INFO");
LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
final ControlLoopUtilsFeature feature = new ControlLoopUtilsFeature();
- feature.afterStart(PolicyEngine.manager);
+ feature.afterStart(PolicyEngineConstants.getManager());
assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.AAISIM_SERVER_PORT));
assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.SOSIM_SERVER_PORT));
assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.SOSIM_SERVER_PORT));
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);
}
}
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index f28ee173f..049bd9a23 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -73,7 +73,7 @@ import java.time.Instant;
import java.util.LinkedList;
import java.util.Iterator;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
/*
* This structure mimics the Params structure.
@@ -191,7 +191,7 @@ rule "${policyName}.EVENT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Retract it from memory
@@ -225,7 +225,7 @@ rule "${policyName}.EVENT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Setup the Overall Control Loop timer
//
@@ -242,7 +242,7 @@ rule "${policyName}.EVENT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Retract it from memory
//
@@ -267,7 +267,7 @@ rule "${policyName}.EVENT"
//
//
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Retract the event
//
@@ -364,7 +364,7 @@ rule "${policyName}.EVENT.MANAGER"
//
// In this case, we are done
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Unlock the target
//
@@ -409,7 +409,7 @@ rule "${policyName}.EVENT.MANAGER"
//
// In this case, we are done
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Unlock the target
//
@@ -475,7 +475,7 @@ rule "${policyName}.EVENT.MANAGER"
notification.setPolicyScope("${policyScope}");
notification.setPolicyVersion("${policyVersion}");
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
retract($event);
@@ -509,7 +509,7 @@ rule "${policyName}.EVENT.MANAGER"
notification.setPolicyScope("${policyScope}");
notification.setPolicyVersion("${policyVersion}");
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
retract($event);
@@ -562,16 +562,16 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
notification.setPolicyScope("${policyScope}");
notification.setPolicyVersion("${policyVersion}");
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
switch ($operation.policy.getActor()){
case "APPC":
if (request instanceof Request) {
- PolicyEngine.manager.deliver("APPC-CL", request);
+ PolicyEngineConstants.getManager().deliver("APPC-CL", request);
}
else if (request instanceof LcmRequestWrapper) {
- PolicyEngine.manager.deliver("APPC-LCM-READ", request);
+ PolicyEngineConstants.getManager().deliver("APPC-LCM-READ", request);
}
break;
case "SO":
@@ -589,9 +589,9 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
SoActorServiceProvider.sendRequest($event.getRequestId().toString(),
new mySoCallback(),
request,
- PolicyEngine.manager.getEnvironmentProperty("so.url"),
- PolicyEngine.manager.getEnvironmentProperty("so.username"),
- PolicyEngine.manager.getEnvironmentProperty("so.password"));
+ PolicyEngineConstants.getManager().getEnvironmentProperty("so.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("so.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("so.password"));
}
break;
case "VFC":
@@ -606,9 +606,9 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
// Start VFC thread
Thread t = new Thread(new VfcManager(new myVfcCallback(),
(VfcRequest)request,
- PolicyEngine.manager.getEnvironmentProperty("vfc.url"),
- PolicyEngine.manager.getEnvironmentProperty("vfc.username"),
- PolicyEngine.manager.getEnvironmentProperty("vfc.password")));
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.password")));
t.start();
}
break;
@@ -624,15 +624,15 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
// Start SDNC thread
Thread t = new Thread(new SdncManager(new mySdncCallback(),
(SdncRequest)request,
- PolicyEngine.manager.getEnvironmentProperty("sdnc.url"),
- PolicyEngine.manager.getEnvironmentProperty("sdnc.username"),
- PolicyEngine.manager.getEnvironmentProperty("sdnc.password")));
+ PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.password")));
t.start();
}
break;
case "SDNR":
if (request instanceof PciRequestWrapper) {
- PolicyEngine.manager.deliver("SDNR-CL", request);
+ PolicyEngineConstants.getManager().deliver("SDNR-CL", request);
}
break;
}
@@ -680,7 +680,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
notification.setMessage($operation.getOperationHistory());
notification.setHistory($operation.getHistory());
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
}
retract($opTimer);
@@ -730,7 +730,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
notification.setPolicyScope("${policyScope}");
notification.setPolicyVersion("${policyVersion}");
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Now send Guard Request to XACML Guard. In order to bypass the call to Guard,
@@ -742,7 +742,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
//
// NOTE: The environment properties uses "guard.disabled" but the boolean is guardEnabled
- boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngine.manager.getEnvironmentProperty("guard.disabled"));
+ boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngineConstants.getManager().getEnvironmentProperty("guard.disabled"));
if(guardEnabled){
@@ -808,7 +808,7 @@ rule "${policyName}.GUARD.RESPONSE"
notification.setPolicyScope("${policyScope}");
notification.setPolicyVersion("${policyVersion}");
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
if("Permit".equalsIgnoreCase($guardResponse.getResult())){
@@ -881,13 +881,13 @@ rule "${policyName}.APPC.RESPONSE"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
} else {
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
}
//
// Ensure the operation is complete
@@ -1001,7 +1001,7 @@ rule "${policyName}.APPC.LCM.RESPONSE"
} else {
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
}
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Ensure the operation is complete
//
@@ -1110,7 +1110,7 @@ rule "${policyName}.SDNR.RESPONSE"
} else {
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
}
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Ensure the operation is complete
//
@@ -1219,7 +1219,7 @@ rule "${policyName}.SO.RESPONSE"
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
}
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Ensure the operation is complete
//
@@ -1468,7 +1468,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.TIMEOUT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Get rid of the timer
//
@@ -1526,7 +1526,7 @@ rule "${policyName}.EVENT.MANAGER.TIMEOUT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
}
//
// Retract the event
diff --git a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index a9e17c3c4..37d7b6936 100644
--- a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -77,7 +77,7 @@ import java.time.Instant;
import java.util.LinkedList;
import java.util.Iterator;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
/*
* This object is to provide support for timeouts
@@ -180,7 +180,7 @@ rule "EVENT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Retract it from memory
@@ -213,7 +213,7 @@ rule "EVENT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Setup the Overall Control Loop timer
//
@@ -230,7 +230,7 @@ rule "EVENT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Retract it from memory
//
@@ -255,7 +255,7 @@ rule "EVENT"
//
//
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Retract the event
//
@@ -348,7 +348,7 @@ rule "EVENT.MANAGER"
//
// In this case, we are done
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Unlock the target
//
@@ -393,7 +393,7 @@ rule "EVENT.MANAGER"
//
// In this case, we are done
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Unlock the target
//
@@ -461,7 +461,7 @@ rule "EVENT.MANAGER"
notification.setPolicyScope($params.getPolicyScope());
notification.setPolicyVersion($params.getPolicyVersion());
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
retract($event);
@@ -495,7 +495,7 @@ rule "EVENT.MANAGER"
notification.setPolicyScope($params.getPolicyScope());
notification.setPolicyVersion($params.getPolicyVersion());
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
retract($event);
@@ -549,17 +549,17 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
notification.setPolicyScope($params.getPolicyScope());
notification.setPolicyVersion($params.getPolicyVersion());
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
switch ($operation.policy.getActor()){
case "APPC":
if (request instanceof Request) {
- PolicyEngine.manager.deliver("APPC-CL", request);
+ PolicyEngineConstants.getManager().deliver("APPC-CL", request);
}
else if (request instanceof LcmRequestWrapper) {
- PolicyEngine.manager.deliver("APPC-LCM-READ", request);
+ PolicyEngineConstants.getManager().deliver("APPC-LCM-READ", request);
}
break;
case "SO":
@@ -576,9 +576,9 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
SoActorServiceProvider.sendRequest($event.getRequestId().toString(),
new mySoCallback(),
request,
- PolicyEngine.manager.getEnvironmentProperty("so.url"),
- PolicyEngine.manager.getEnvironmentProperty("so.username"),
- PolicyEngine.manager.getEnvironmentProperty("so.password"));
+ PolicyEngineConstants.getManager().getEnvironmentProperty("so.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("so.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("so.password"));
}
break;
case "VFC":
@@ -592,15 +592,15 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
// Start VFC thread
Thread t = new Thread(new VfcManager(new myVfcCallback(),
(VfcRequest)request,
- PolicyEngine.manager.getEnvironmentProperty("vfc.url"),
- PolicyEngine.manager.getEnvironmentProperty("vfc.username"),
- PolicyEngine.manager.getEnvironmentProperty("vfc.password")));
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.password")));
t.start();
}
break;
case "SDNR":
if (request instanceof PciRequestWrapper) {
- PolicyEngine.manager.deliver("SDNR-CL", request);
+ PolicyEngineConstants.getManager().deliver("SDNR-CL", request);
}
break;
@@ -614,9 +614,9 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
// Start SDNC thread
Thread t = new Thread(new SdncManager(new mySdncCallback(),
(SdncRequest)request,
- PolicyEngine.manager.getEnvironmentProperty("sdnc.url"),
- PolicyEngine.manager.getEnvironmentProperty("sdnc.username"),
- PolicyEngine.manager.getEnvironmentProperty("sdnc.password")));
+ PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.password")));
t.start();
}
break;
@@ -666,7 +666,7 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
notification.setMessage($operation.getOperationHistory());
notification.setHistory($operation.getHistory());
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
}
retract($opTimer);
@@ -716,7 +716,7 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
notification.setPolicyScope($params.getPolicyScope());
notification.setPolicyVersion($params.getPolicyVersion());
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Now send Guard Request to XACML Guard. In order to bypass the call to Guard,
@@ -728,7 +728,7 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
//
// NOTE: The environment properties uses "guard.disabled" but the boolean is guardEnabled
- boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngine.manager.getEnvironmentProperty("guard.disabled"));
+ boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngineConstants.getManager().getEnvironmentProperty("guard.disabled"));
if(guardEnabled){
@@ -794,7 +794,7 @@ rule "GUARD.RESPONSE"
notification.setPolicyScope($params.getPolicyScope());
notification.setPolicyVersion($params.getPolicyVersion());
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
if("Permit".equalsIgnoreCase($guardResponse.getResult())){
@@ -867,13 +867,13 @@ rule "APPC.RESPONSE"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
} else {
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
}
//
// Ensure the operation is complete
@@ -987,7 +987,7 @@ rule "APPC.LCM.RESPONSE"
} else {
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
}
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Ensure the operation is complete
//
@@ -1096,7 +1096,7 @@ rule "SO.RESPONSE"
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
}
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Ensure the operation is complete
//
@@ -1341,7 +1341,7 @@ rule "EVENT.MANAGER.OPERATION.TIMEOUT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
//
// Get rid of the timer
//
@@ -1399,7 +1399,7 @@ rule "EVENT.MANAGER.TIMEOUT"
//
// Let interested parties know
//
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
}
//
// Retract the event
@@ -1525,10 +1525,10 @@ rule "SDNR.RESPONSE"
} else {
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
}
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification);
ControlLoopResponse clResponse = $operation.getControlLoopResponse($response, $event);
- PolicyEngine.manager.deliver("DCAE_CL_RSP", clResponse);
+ PolicyEngineConstants.getManager().deliver("DCAE_CL_RSP", clResponse);
//
// Ensure the operation is complete
//
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java
index 42742b261..bf81c2d19 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java
@@ -25,120 +25,35 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.sdnc.SdncRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class CcvpnBwControlLoopTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(CcvpnBwControlLoopTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setSdncProps();
- SupportUtil.setGuardProps();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- }
+public class CcvpnBwControlLoopTest extends ControlLoopBase implements TopicListener {
/**
* Setup the simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
-
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildSdncSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- /*
- *
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources/"
- + "src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_CCVPN_BW.yaml", "type=operational",
- "BandwidthOnDemand", "2.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down the simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
-
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/"
+ + "src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_CCVPN_BW.yaml",
+ "type=operational",
+ "BandwidthOnDemand", "2.0.0");
}
@Test
@@ -221,49 +136,6 @@ public class CcvpnBwControlLoopTest implements TopicListener {
dumpFacts(kieSession);
}
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate the DRL rules file
- * @param yamlFile the yaml file containing the policies
- * @param policyScope scope for policy
- * @param policyName name of the policy
- * @param policyVersion version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException IO Exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(),
- policyScope, policyName, policyVersion, URLEncoder.encode(pair.second,
- StandardCharsets.UTF_8.name()));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("============");
- logger.debug(URLEncoder.encode(pair.second, StandardCharsets.UTF_8.name()));
- logger.debug("============");
-
- return kieSession;
- }
-
/*
* (non-Javadoc)
*
@@ -359,16 +231,4 @@ public class CcvpnBwControlLoopTest implements TopicListener {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
kieSession.insert(event);
}
-
- /**
- * Dumps the kie session facts.
- *
- * @param kieSession input session
- */
- public static void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: " + kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: " + handle);
- }
- }
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java
index 2c2b5d8fb..8fda5b4df 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java
@@ -25,119 +25,36 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
-import java.net.URLEncoder;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.sdnc.SdncRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class CcvpnControlLoopTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(CcvpnControlLoopTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setSdncProps();
- SupportUtil.setGuardProps();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- }
+public class CcvpnControlLoopTest extends ControlLoopBase implements TopicListener {
/**
* Setup the simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
-
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildSdncSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- /*
- *
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources/"
- + "src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_CCVPN.yaml", "type=operational", "Connectivity Reroute",
- "2.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down the simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
-
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/"
+ + "src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_CCVPN.yaml",
+ "type=operational",
+ "Connectivity Reroute",
+ "2.0.0");
}
@Test
@@ -220,48 +137,6 @@ public class CcvpnControlLoopTest implements TopicListener {
dumpFacts(kieSession);
}
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate the DRL rules file
- * @param yamlFile the yaml file containing the policies
- * @param policyScope scope for policy
- * @param policyName name of the policy
- * @param policyVersion version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException IO Exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(),
- policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("============");
- logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
- }
-
/*
* (non-Javadoc)
*
@@ -353,17 +228,4 @@ public class CcvpnControlLoopTest implements TopicListener {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
kieSession.insert(event);
}
-
- /**
- * Dumps the kie session facts.
- *
- * @param kieSession input session
- */
- public static void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: " + kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: " + handle);
- }
- }
}
-
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopBase.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopBase.java
new file mode 100644
index 000000000..ab6ec5a3a
--- /dev/null
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopBase.java
@@ -0,0 +1,229 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * demo
+ * ================================================================================
+ * Copyright (C) 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.template.demo;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+import org.junit.AfterClass;
+import org.kie.api.runtime.KieSession;
+import org.kie.api.runtime.rule.FactHandle;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
+import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.protocol.coders.EventProtocolCoderConstants;
+import org.onap.policy.drools.protocol.coders.EventProtocolParams;
+import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
+import org.onap.policy.drools.system.PolicyControllerConstants;
+import org.onap.policy.drools.system.PolicyEngineConstants;
+import org.onap.policy.drools.utils.logging.LoggerUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Common super class used by various Control Loop test classes. It manages the simulators
+ * and the kie session.
+ */
+public class ControlLoopBase {
+
+ private static final String JUNIT_ARTIFACT_ID = "junit.artifactId";
+
+ private static final String JUNIT_GROUP_ID = "junit.groupId";
+
+ protected static final Logger logger = LoggerFactory.getLogger(ControlLoopBase.class);
+
+ protected static List<? extends TopicSink> noopTopics;
+
+ protected static KieSession kieSession;
+ protected static SupportUtil.Pair<ControlLoopPolicy, String> pair;
+
+ protected UUID requestId;
+
+ /**
+ * Starts the simulator and the kie session.
+ *
+ * @param droolsTemplate the DRL rules file
+ * @param yamlFile the yaml file containing the policies
+ * @param policyScope scope for policy
+ * @param policyName name of the policy
+ * @param policyVersion version of the policy
+ */
+ public static void setUpBeforeClass(String droolsTemplate, String yamlFile, String policyScope,
+ String policyName, String policyVersion) {
+
+ /* Set environment properties */
+ SupportUtil.setAaiProps();
+ SupportUtil.setGuardProps();
+ SupportUtil.setSdncProps();
+ SupportUtil.setSoProps();
+ SupportUtil.setVfcProps();
+ SupportUtil.setPuProp();
+
+ LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
+
+ PolicyEngineConstants.getManager().configure(new Properties());
+ assertTrue(PolicyEngineConstants.getManager().start());
+ Properties noopSinkProperties = new Properties();
+ noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS,
+ "APPC-LCM-READ,APPC-CL,SDNR-CL,POLICY-CL-MGT");
+ noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.LcmRequestWrapper");
+ noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson",
+ "org.onap.policy.appclcm.util.Serialization,gson");
+ noopSinkProperties.put("noop.sink.topics.APPC-CL.events", "org.onap.policy.appc.Response");
+ noopSinkProperties.put("noop.sink.topics.APPC-CL.events.custom.gson",
+ "org.onap.policy.appc.util.Serialization,gsonPretty");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
+ "org.onap.policy.controlloop.util.Serialization,gsonPretty");
+ noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
+
+ EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder()
+ .groupId(JUNIT_GROUP_ID)
+ .artifactId(JUNIT_ARTIFACT_ID)
+ .topic("POLICY-CL-MGT")
+ .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
+ .protocolFilter(new JsonProtocolFilter())
+ .modelClassLoaderHash(1111));
+ EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder()
+ .groupId(JUNIT_GROUP_ID)
+ .artifactId(JUNIT_ARTIFACT_ID)
+ .topic("APPC-LCM-READ")
+ .eventClass("org.onap.policy.appclcm.LcmRequestWrapper")
+ .protocolFilter(new JsonProtocolFilter())
+ .modelClassLoaderHash(1111));
+ EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder()
+ .groupId(JUNIT_GROUP_ID)
+ .artifactId(JUNIT_ARTIFACT_ID)
+ .topic("APPC-CL")
+ .eventClass("org.onap.policy.appc.Request")
+ .protocolFilter(new JsonProtocolFilter())
+ .modelClassLoaderHash(1111));
+ EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder()
+ .groupId(JUNIT_GROUP_ID)
+ .artifactId(JUNIT_ARTIFACT_ID)
+ .topic("SDNR-CL")
+ .eventClass("org.onap.policy.sdnr.PciRequestWrapper")
+ .protocolFilter(new JsonProtocolFilter())
+ .modelClassLoaderHash(1111));
+ try {
+ SupportUtil.buildAaiSim();
+ SupportUtil.buildSdncSim();
+ SupportUtil.buildSoSim();
+ SupportUtil.buildVfcSim();
+ SupportUtil.buildGuardSim();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+
+ /*
+ * Start the kie session
+ */
+ try {
+ kieSession = startSession(droolsTemplate, yamlFile, policyScope,
+ policyName, policyVersion);
+ } catch (IOException e) {
+ e.printStackTrace();
+ logger.debug("Could not create kieSession");
+ fail("Could not create kieSession");
+ }
+ }
+
+ /**
+ * Stops the simulators and the kie session.
+ */
+ @AfterClass
+ public static void tearDownAfterClass() {
+ /*
+ * Gracefully shut down the kie session
+ */
+ kieSession.dispose();
+
+ PolicyEngineConstants.getManager().stop();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ PolicyControllerConstants.getFactory().shutdown();
+ TopicEndpointManager.getManager().shutdown();
+ }
+
+ /**
+ * This method will start a kie session and instantiate the Policy Engine.
+ *
+ * @param droolsTemplate the DRL rules file
+ * @param yamlFile the yaml file containing the policies
+ * @param policyScope scope for policy
+ * @param policyName name of the policy
+ * @param policyVersion version of the policy
+ * @return the kieSession to be used to insert facts
+ * @throws IOException IO exception
+ */
+ private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
+ String policyName, String policyVersion) throws IOException {
+
+ /*
+ * Load policies from yaml
+ */
+ pair = SupportUtil.loadYaml(yamlFile);
+ assertNotNull(pair);
+ assertNotNull(pair.first);
+ assertNotNull(pair.first.getControlLoop());
+ assertNotNull(pair.first.getControlLoop().getControlLoopName());
+ assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
+
+ /*
+ * Construct a kie session
+ */
+ final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
+ pair.first.getControlLoop().getControlLoopName(),
+ policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8"));
+
+ /*
+ * Retrieve the Policy Engine
+ */
+
+ logger.debug("============");
+ logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
+ logger.debug("============");
+
+ return kieSession;
+ }
+
+ /**
+ * This method will dump all the facts in the working memory.
+ *
+ * @param kieSession the session containing the facts
+ */
+ public void dumpFacts(KieSession kieSession) {
+ logger.debug("Fact Count: {}", kieSession.getFactCount());
+ for (FactHandle handle : kieSession.getFactHandles()) {
+ logger.debug("FACT: {}", handle);
+ }
+ }
+
+}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java
index 928bcb80c..08215e958 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java
@@ -46,11 +46,11 @@ import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
+import org.onap.policy.drools.protocol.coders.EventProtocolCoderConstants;
import org.onap.policy.drools.protocol.coders.EventProtocolParams;
import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-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.drools.utils.logging.LoggerUtil;
import org.onap.policy.template.demo.SupportUtil.Pair;
import org.slf4j.Logger;
@@ -107,13 +107,13 @@ public class ControlLoopEventCleanupTest {
public static void setUpSimulator() {
LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- saveGuardFlag = PolicyEngine.manager.getEnvironmentProperty(GUARD_DISABLED);
- PolicyEngine.manager.getEnvironment().setProperty(GUARD_DISABLED, "true");
+ saveGuardFlag = PolicyEngineConstants.getManager().getEnvironmentProperty(GUARD_DISABLED);
+ PolicyEngineConstants.getManager().getEnvironment().setProperty(GUARD_DISABLED, "true");
SupportUtil.setAaiProps();
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
+ PolicyEngineConstants.getManager().configure(new Properties());
+ assertTrue(PolicyEngineConstants.getManager().start());
Properties noopSinkProperties = new Properties();
noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL,POLICY-CL-MGT");
noopSinkProperties.put("noop.sink.topics.APPC-CL.events", "org.onap.policy.appc.Response");
@@ -125,14 +125,14 @@ public class ControlLoopEventCleanupTest {
"org.onap.policy.controlloop.util.Serialization,gsonPretty");
final List<TopicSink> noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
+ EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder()
.groupId("junit.groupId")
.artifactId("junit.artifactId")
.topic("POLICY-CL-MGT")
.eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
.protocolFilter(new JsonProtocolFilter())
.modelClassLoaderHash(1111));
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
+ EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder()
.groupId("junit.groupId")
.artifactId("junit.artifactId")
.topic("APPC-CL")
@@ -176,16 +176,16 @@ public class ControlLoopEventCleanupTest {
public static void tearDown() {
kieSession.dispose();
- PolicyEngine.manager.stop();
+ PolicyEngineConstants.getManager().stop();
HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
+ PolicyControllerConstants.getFactory().shutdown();
TopicEndpointManager.getManager().shutdown();
if (saveGuardFlag == null) {
- PolicyEngine.manager.getEnvironment().remove(GUARD_DISABLED);
+ PolicyEngineConstants.getManager().getEnvironment().remove(GUARD_DISABLED);
} else {
- PolicyEngine.manager.getEnvironment().setProperty(GUARD_DISABLED, saveGuardFlag);
+ PolicyEngineConstants.getManager().getEnvironment().setProperty(GUARD_DISABLED, saveGuardFlag);
}
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
index 6dbe17ee2..bc5a9828b 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
@@ -25,131 +25,42 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.IOException;
-import java.net.URLEncoder;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.appclcm.LcmRequest;
import org.onap.policy.appclcm.LcmRequestWrapper;
import org.onap.policy.appclcm.LcmResponse;
import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class ControlLoopFailureTest implements TopicListener {
+public class ControlLoopFailureTest extends ControlLoopBase implements TopicListener {
- private static final Logger logger = LoggerFactory.getLogger(ControlLoopFailureTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
- private UUID requestId;
private UUID requestId2;
private UUID requestId3;
private int eventCount;
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setGuardProps();
- SupportUtil.setPuProp();
- }
-
/**
* Setup simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-LCM-READ,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.LcmRequestWrapper");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson",
- "org.onap.policy.appclcm.util.Serialization,gson");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("APPC-LCM-READ")
- .eventClass("org.onap.policy.appclcm.LcmRequestWrapper")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- /*
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources"
- + "/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational", "CL_vCPE",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources"
+ + "/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
+ "service=ServiceDemo;resource=Res1Demo;type=operational",
+ "CL_vCPE",
+ "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
}
/**
@@ -217,49 +128,6 @@ public class ControlLoopFailureTest implements TopicListener {
* Print what's left in memory
*/
dumpFacts(kieSession);
-
- }
-
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate the DRL rules file
- * @param yamlFile the yaml file containing the policies
- * @param policyScope scope for policy
- * @param policyName name of the policy
- * @param policyVersion version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException throws IO exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(),
- policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("============");
- logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
}
/*
@@ -387,18 +255,4 @@ public class ControlLoopFailureTest implements TopicListener {
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
- /**
- * This method will dump all the facts in the working memory.
- *
- * @param kieSession the session containing the facts
- */
- public void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: {}", kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: {}", handle);
- }
- }
-
}
-
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java
index 493ab9b2c..a4e8bef65 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java
@@ -46,7 +46,7 @@ import org.kie.api.runtime.KieSession;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
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.onap.policy.guard.PolicyGuardYamlToXacml;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -289,27 +289,27 @@ public final class SupportUtil {
* Set the A&AI properties.
*/
public static void setAaiProps() {
- PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
- PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI");
- PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.url", "http://localhost:6666");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.username", "AAI");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.password", "AAI");
}
/**
* Set the SO properties.
*/
public static void setSoProps() {
- PolicyEngine.manager.setEnvironmentProperty("so.url", "http://localhost:6667");
- PolicyEngine.manager.setEnvironmentProperty("so.username", "SO");
- PolicyEngine.manager.setEnvironmentProperty("so.password", "SO");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("so.url", "http://localhost:6667");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("so.username", "SO");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("so.password", "SO");
}
/**
* Set the SDNC properties.
*/
public static void setSdncProps() {
- PolicyEngine.manager.setEnvironmentProperty("sdnc.url", "http://localhost:6670/restconf/operations");
- PolicyEngine.manager.setEnvironmentProperty("sdnc.username", "sdnc");
- PolicyEngine.manager.setEnvironmentProperty("sdnc.password", "sdnc");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("sdnc.url", "http://localhost:6670/restconf/operations");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("sdnc.username", "sdnc");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("sdnc.password", "sdnc");
}
/**
@@ -319,19 +319,21 @@ public final class SupportUtil {
/*
* Guard PDP-x connection Properties
*/
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_URL, "http://localhost:6669/policy/pdpx/v1/decision");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, "python");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, "test");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_DISABLED, "false");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_URL,
+ "http://localhost:6669/policy/pdpx/v1/decision");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, "python");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, "test");
+ PolicyEngineConstants.getManager().setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_DISABLED,
+ "false");
}
/**
* Set the VFC properties.
*/
public static void setVfcProps() {
- PolicyEngine.manager.setEnvironmentProperty("vfc.url", "http://localhost:6668/api/nslcm/v1");
- PolicyEngine.manager.setEnvironmentProperty("vfc.username", "VFC");
- PolicyEngine.manager.setEnvironmentProperty("vfc.password", "VFC");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("vfc.url", "http://localhost:6668/api/nslcm/v1");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("vfc.username", "VFC");
+ PolicyEngineConstants.getManager().setEnvironmentProperty("vfc.password", "VFC");
}
/**
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java
index 28706fd66..1cd431f50 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java
@@ -25,130 +25,39 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.IOException;
-import java.net.URLEncoder;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.appclcm.LcmRequest;
import org.onap.policy.appclcm.LcmRequestWrapper;
import org.onap.policy.appclcm.LcmResponse;
import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class VcpeControlLoopTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(VcpeControlLoopTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
- private UUID requestId;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setGuardProps();
- SupportUtil.setPuProp();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- }
+public class VcpeControlLoopTest extends ControlLoopBase implements TopicListener {
/**
* Setup the simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-LCM-READ,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.LcmRequestWrapper");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson",
- "org.onap.policy.appclcm.util.Serialization,gson");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("APPC-LCM-READ")
- .eventClass("org.onap.policy.appclcm.LcmRequestWrapper")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- /*
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources"
- + "/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational", "CL_vCPE",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down the simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources"
+ + "/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
+ "service=ServiceDemo;resource=Res1Demo;type=operational",
+ "CL_vCPE",
+ "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
}
@Test
@@ -228,49 +137,6 @@ public class VcpeControlLoopTest implements TopicListener {
* Print what's left in memory
*/
dumpFacts(kieSession);
-
- }
-
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate the DRL rules file
- * @param yamlFile the yaml file containing the policies
- * @param policyScope scope for policy
- * @param policyName name of the policy
- * @param policyVersion version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException IO exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(),
- policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("============");
- logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
}
/*
@@ -406,17 +272,4 @@ public class VcpeControlLoopTest implements TopicListener {
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
- /**
- * This method will dump all the facts in the working memory.
- *
- * @param kieSession the session containing the facts
- */
- public void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: {}", kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: {}", handle);
- }
- }
-
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java
index 3e5825bc1..d1453f7b1 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java
@@ -25,119 +25,35 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.IOException;
-import java.net.URLEncoder;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.so.SoRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class VdnsControlLoopTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(VdnsControlLoopTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
- private UUID requestId;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setSoProps();
- SupportUtil.setGuardProps();
- SupportUtil.setPuProp();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- }
+public class VdnsControlLoopTest extends ControlLoopBase implements TopicListener {
/**
* Setup the simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
-
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildSoSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- /*
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources/"
- + "src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_SO-test.yaml", "type=operational", "CL_vDNS", "v2.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down the simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
-
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/"
+ + "src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_SO-test.yaml",
+ "type=operational",
+ "CL_vDNS",
+ "v2.0");
}
@Test
@@ -265,48 +181,6 @@ public class VdnsControlLoopTest implements TopicListener {
dumpFacts(kieSession);
}
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate the DRL rules file
- * @param yamlFile the yaml file containing the policies
- * @param policyScope scope for policy
- * @param policyName name of the policy
- * @param policyVersion version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException IO Exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(),
- policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("============");
- logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
- }
-
/*
* (non-Javadoc)
*
@@ -410,16 +284,4 @@ public class VdnsControlLoopTest implements TopicListener {
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
- /**
- * This method will dump all the facts in the working memory.
- *
- * @param kieSession the session containing the facts
- */
- public void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: {}", kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: {}", handle);
- }
- }
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java
index fdf27490c..4f47bd0a9 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java
@@ -27,120 +27,37 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
-import java.net.URLEncoder;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.vfc.VfcRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class VfcControlLoopTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(VfcControlLoopTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
- private UUID requestId;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setVfcProps();
- SupportUtil.setGuardProps();
- SupportUtil.setPuProp();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- }
+public class VfcControlLoopTest extends ControlLoopBase implements TopicListener {
/**
* Setup the simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
-
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildVfcSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- /*
- *
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources/"
- + "src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_VFC.yaml", "type=operational", "CL_VoLTE", "v2.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down the simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
-
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/"
+ + "src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_VFC.yaml",
+ "type=operational",
+ "CL_VoLTE",
+ "v2.0");
}
@Test
@@ -233,48 +150,6 @@ public class VfcControlLoopTest implements TopicListener {
dumpFacts(kieSession);
}
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate the DRL rules file
- * @param yamlFile the yaml file containing the policies
- * @param policyScope scope for policy
- * @param policyName name of the policy
- * @param policyVersion version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException IO Exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(),
- policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("============");
- logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
- }
-
/*
* (non-Javadoc)
*
@@ -369,18 +244,4 @@ public class VfcControlLoopTest implements TopicListener {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
kieSession.insert(event);
}
-
- /**
- * Dumps the kie session facts.
- *
- * @param kieSession input session
- */
- public static void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: " + kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: " + handle);
- }
- }
-
}
-
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java
index 327a1b4dc..221ef5e6b 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java
@@ -25,130 +25,37 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.IOException;
-import java.net.URLEncoder;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
import org.onap.policy.appc.ResponseCode;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VfwControlLoopTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(VfwControlLoopTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
- private UUID requestId;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setGuardProps();
- SupportUtil.setPuProp();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- }
+
+public class VfwControlLoopTest extends ControlLoopBase implements TopicListener {
/**
* Setup the simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.APPC-CL.events", "org.onap.policy.appc.Response");
- noopSinkProperties.put("noop.sink.topics.APPC-CL.events.custom.gson",
- "org.onap.policy.appc.util.Serialization,gsonPretty");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("APPC-CL")
- .eventClass("org.onap.policy.appc.Request")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
-
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- /*
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/"
- + "main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vFW.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational", "CL_vFW",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down the simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/"
+ + "main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vFW.yaml",
+ "service=ServiceDemo;resource=Res1Demo;type=operational",
+ "CL_vFW",
+ "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
}
@Test
@@ -277,48 +184,6 @@ public class VfwControlLoopTest implements TopicListener {
dumpFacts(kieSession);
}
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate the DRL rules file
- * @param yamlFile the yaml file containing the policies
- * @param policyScope scope for policy
- * @param policyName name of the policy
- * @param policyVersion version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException IO Exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(),
- policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("============");
- logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
- }
-
/*
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
@@ -441,16 +306,4 @@ public class VfwControlLoopTest implements TopicListener {
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
- /**
- * This method will dump all the facts in the working memory.
- *
- * @param kieSession the session containing the facts
- */
- public void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: {}", kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: {}", handle);
- }
- }
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java
index 3278d4396..9d3486f5b 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java
@@ -26,128 +26,39 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.IOException;
-import java.net.URLEncoder;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.sdnr.PciRequest;
import org.onap.policy.sdnr.PciRequestWrapper;
import org.onap.policy.sdnr.PciResponse;
import org.onap.policy.sdnr.PciResponseWrapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class VpciControlLoopTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(VpciControlLoopTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
- private UUID requestId;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setGuardProps();
- SupportUtil.setPuProp();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "DEBUG");
- }
+public class VpciControlLoopTest extends ControlLoopBase implements TopicListener {
/**
* Setup the simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "SDNR-CL,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.SDNR-CL.events", "org.onap.policy.sdnr.PciRequestWrapper");
- noopSinkProperties.put("noop.sink.topics.SDNR-CL.events.custom.gson",
- "org.onap.policy.sdnr.util.Serialization,gson");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("SDNR-CL")
- .eventClass("org.onap.policy.sdnr.PciRequestWrapper")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- /*
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources"
- + "/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vPCI.yaml", "type=operational", "CL_vPCI", "v3.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down the simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources"
+ + "/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vPCI.yaml",
+ "type=operational",
+ "CL_vPCI",
+ "v3.0.0");
}
@Test
@@ -230,56 +141,6 @@ public class VpciControlLoopTest implements TopicListener {
}
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate
- * the DRL rules file
- * @param yamlFile
- * the yaml file containing the policies
- * @param policyScope
- * scope for policy
- * @param policyName
- * name of the policy
- * @param policyVersion
- * version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException
- * IO exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(), policyScope, policyName, policyVersion,
- URLEncoder.encode(pair.second, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("======controlloop======");
- logger.debug(((ControlLoopPolicy) pair.first).toString());
- logger.debug("======policies======");
- logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
- }
-
/*
* (non-Javadoc)
*
@@ -419,18 +280,4 @@ public class VpciControlLoopTest implements TopicListener {
logger.debug("\n============ event ===========\n {}", event);
kieSession.insert(event);
}
-
- /**
- * This method will dump all the facts in the working memory.
- *
- * @param kieSession
- * the session containing the facts
- */
- public void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: {}", kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: {}", handle);
- }
- }
-
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java
index 3859b7405..d0427e47f 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java
@@ -26,128 +26,39 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.IOException;
-import java.net.URLEncoder;
import java.time.Instant;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.UUID;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.sdnr.PciRequest;
import org.onap.policy.sdnr.PciRequestWrapper;
import org.onap.policy.sdnr.PciResponse;
import org.onap.policy.sdnr.PciResponseWrapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class VsonhControlLoopTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(VsonhControlLoopTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static SupportUtil.Pair<ControlLoopPolicy, String> pair;
- private UUID requestId;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setGuardProps();
- SupportUtil.setPuProp();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "DEBUG");
- }
+public class VsonhControlLoopTest extends ControlLoopBase implements TopicListener {
/**
* Setup the simulator.
*/
@BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "SDNR-CL,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.SDNR-CL.events", "org.onap.policy.sdnr.PciRequestWrapper");
- noopSinkProperties.put("noop.sink.topics.SDNR-CL.events.custom.gson",
- "org.onap.policy.sdnr.util.Serialization,gson");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("SDNR-CL")
- .eventClass("org.onap.policy.sdnr.PciRequestWrapper")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- try {
- SupportUtil.buildAaiSim();
- SupportUtil.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- /*
- * Start the kie session
- */
- try {
- kieSession = startSession(
- "../archetype-cl-amsterdam/src/main/resources/archetype-resources"
- + "/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vSONH.yaml", "type=operational", "CL_vSONH", "v4.0.0");
- } catch (IOException e) {
- e.printStackTrace();
- logger.debug("Could not create kieSession");
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down the simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
- /*
- * Gracefully shut down the kie session
- */
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- PolicyController.factory.shutdown();
- TopicEndpointManager.getManager().shutdown();
+ public static void setUpBeforeClass() {
+ ControlLoopBase.setUpBeforeClass(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources"
+ + "/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vSONH.yaml",
+ "type=operational",
+ "CL_vSONH",
+ "v4.0.0");
}
@Test
@@ -230,56 +141,6 @@ public class VsonhControlLoopTest implements TopicListener {
}
- /**
- * This method will start a kie session and instantiate the Policy Engine.
- *
- * @param droolsTemplate
- * the DRL rules file
- * @param yamlFile
- * the yaml file containing the policies
- * @param policyScope
- * scope for policy
- * @param policyName
- * name of the policy
- * @param policyVersion
- * version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException
- * IO exception
- */
- private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
- String policyName, String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- pair.first.getControlLoop().getControlLoopName(), policyScope, policyName, policyVersion,
- URLEncoder.encode(pair.second, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("======controlloop======");
- logger.debug(((ControlLoopPolicy) pair.first).toString());
- logger.debug("======policies======");
- logger.debug(URLEncoder.encode(pair.second, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
- }
-
/*
* (non-Javadoc)
*
@@ -426,18 +287,4 @@ public class VsonhControlLoopTest implements TopicListener {
logger.debug("\n============ event ===========\n {}", event);
kieSession.insert(event);
}
-
- /**
- * This method will dump all the facts in the working memory.
- *
- * @param kieSession
- * the session containing the facts
- */
- public void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: {}", kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: {}", handle);
- }
- }
-
}