From 25c8a555a739b1c80966ed88cc123a6e9ad9318e Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 31 Aug 2020 17:59:44 -0400 Subject: Allow guards to be dynamically enabled/disabled Modified drools-apps so that guards can be dynamically enabled and disabled. Due to the current design, there are two properties that control this: - an actor-level property: when enabled, the DB connection is created, otherwise a stub connection is created. This property is NOT dynamic - an engine-level property: when enabled, the connection created by the actor is used, otherwise a stub connection is used. This property IS dynamic Issue-ID: POLICY-2748 Change-Id: I2a5baf908ce274f2eb46a6a3f01df1b3532038ff Signed-off-by: Jim Hahn --- .../eventmanager/ControlLoopEventManagerTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'controlloop/common/eventmanager/src/test') 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 e4c233281..a8632642a 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 @@ -49,6 +49,7 @@ import org.onap.policy.controlloop.ControlLoopException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.drl.legacy.ControlLoopParams; +import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerStub; import org.onap.policy.drools.core.lock.LockCallback; import org.onap.policy.drools.core.lock.LockImpl; import org.onap.policy.drools.core.lock.LockState; @@ -241,6 +242,22 @@ public class ControlLoopEventManagerTest { assertFalse(mgr.contains(MY_KEY)); } + /** + * Tests getDataManager() when guard.disabled=true. + */ + @Test + public void testGetDataManagerDisabled() throws ControlLoopException { + mgr = new MyManager(params, REQ_ID) { + private static final long serialVersionUID = 1L; + @Override + protected String getEnvironmentProperty(String propName) { + return ("guard.disabled".equals(propName) ? "true" : null); + } + }; + + assertThat(mgr.getDataManager()).isInstanceOf(OperationHistoryDataManagerStub.class); + } + @Test public void testToString() { assertNotNull(mgr.toString()); -- cgit 1.2.3-korg