summaryrefslogtreecommitdiffstats
path: root/controlloop/common/feature-controlloop-trans/src
diff options
context:
space:
mode:
authormmis <michael.morris@ericsson.com>2018-07-23 12:22:07 +0100
committermmis <michael.morris@ericsson.com>2018-07-30 23:00:38 +0100
commite87b2f7632dedf0067ea2417fb1157a8638df101 (patch)
treea79b8b16fd48c328cd9deedbebfbcc8ea84b9f0d /controlloop/common/feature-controlloop-trans/src
parentf892e8b13ea87c1d7fb1c890f64ff00fc6e2de5f (diff)
Copy policy-endpoints from drools-pdp to common
Replaced references to classes deleted from drools-pdp with references to the corresponding in policy-common Issue-ID: POLICY-967 Change-Id: Ia9d2ac704e6b7c434e5a9e7aee6d7dcf9198e4f2 Signed-off-by: mmis <michael.morris@ericsson.com>
Diffstat (limited to 'controlloop/common/feature-controlloop-trans/src')
-rw-r--r--controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java8
-rw-r--r--controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java35
2 files changed, 24 insertions, 19 deletions
diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java
index 29630e33c..b15fb1479 100644
--- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java
+++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java
@@ -20,8 +20,8 @@
package org.onap.policy.drools.apps.controlloop.feature.trans;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
-import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.features.PolicyControllerFeatureAPI;
import org.onap.policy.drools.system.PolicyController;
import org.slf4j.Logger;
@@ -51,7 +51,8 @@ public class ControlLoopMetricsFeature implements PolicyControllerFeatureAPI {
/**
* transaction timeout in minutes
*/
- public static final String CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY = "controllop.cache.transactions.timeout.seconds";
+ public static final String CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY =
+ "controllop.cache.transactions.timeout.seconds";
public static final long CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT = 1L * 60 * 60;
@Override
@@ -75,8 +76,9 @@ public class ControlLoopMetricsFeature implements PolicyControllerFeatureAPI {
*/
@Override
public boolean beforeDeliver(PolicyController controller, CommInfrastructure protocol, String topic, Object event) {
- if (event instanceof VirtualControlLoopNotification)
+ if (event instanceof VirtualControlLoopNotification) {
ControlLoopMetrics.manager.transactionEvent(controller, (VirtualControlLoopNotification) event);
+ }
/* do not take ownership */
return false;
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 4c113aca7..df93c7a5e 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
@@ -20,23 +20,24 @@
package org.onap.policy.drools.apps.controlloop.feature.trans;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.nio.file.Path;
import java.util.UUID;
+
import org.junit.AfterClass;
import org.junit.BeforeClass;
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.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.persistence.SystemPersistence;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyEngine;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* ControlLoopMetrics Tests
*/
@@ -48,9 +49,8 @@ public class ControlLoopMetricsFeatureTest {
@BeforeClass
public static void setUp() {
SystemPersistence.manager.setConfigurationDir("src/test/resources");
- testController =
- PolicyEngine.manager.createPolicyController
- ("metrics", SystemPersistence.manager.getControllerProperties("metrics"));
+ testController = PolicyEngine.manager.createPolicyController("metrics",
+ SystemPersistence.manager.getControllerProperties("metrics"));
}
@AfterClass
@@ -96,7 +96,7 @@ public class ControlLoopMetricsFeatureTest {
/* let the entries expire */
try {
- Thread.sleep((ControlLoopMetrics.manager.getTransactionTimeout()+5)*1000L);
+ Thread.sleep((ControlLoopMetrics.manager.getTransactionTimeout() + 5) * 1000L);
} catch (InterruptedException e) {
/* nothing to do */
}
@@ -108,11 +108,13 @@ public class ControlLoopMetricsFeatureTest {
@Test
public void reset() {
VirtualControlLoopNotification notification = this.generateNotification();
- new ControlLoopMetricsFeature().beforeDeliver(testController, CommInfrastructure.DMAAP, "POLICY-CL-MGT", notification);
+ new ControlLoopMetricsFeature().beforeDeliver(testController, CommInfrastructure.DMAAP, "POLICY-CL-MGT",
+ notification);
assertNotNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
- ControlLoopMetrics.manager.resetCache(ControlLoopMetrics.manager.getCacheSize(), ControlLoopMetrics.manager.getTransactionTimeout());
+ ControlLoopMetrics.manager.resetCache(ControlLoopMetrics.manager.getCacheSize(),
+ ControlLoopMetrics.manager.getTransactionTimeout());
assertNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
this.cacheDefaults();
}
@@ -132,7 +134,7 @@ public class ControlLoopMetricsFeatureTest {
@Test
public void eviction() {
ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
- for (int i=0; i < ControlLoopMetrics.manager.getCacheSize(); i++) {
+ for (int i = 0; i < ControlLoopMetrics.manager.getCacheSize(); i++) {
VirtualControlLoopNotification notification = generateNotification();
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, "POLICY-CL-MGT", notification);
assertNotNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
@@ -151,13 +153,14 @@ public class ControlLoopMetricsFeatureTest {
/* let the entries expire */
try {
- Thread.sleep((ControlLoopMetrics.manager.getTransactionTimeout()+5)*1000L);
+ Thread.sleep((ControlLoopMetrics.manager.getTransactionTimeout() + 5) * 1000L);
} catch (InterruptedException e) {
/* nothing to do */
}
ControlLoopMetrics.manager.refresh();
- assertTrue(ControlLoopMetrics.manager.getTransactionIds().size() == ControlLoopMetrics.manager.getCacheOccupancy());
+ assertTrue(ControlLoopMetrics.manager.getTransactionIds().size() == ControlLoopMetrics.manager
+ .getCacheOccupancy());
assertFalse(ControlLoopMetrics.manager.getCacheOccupancy() == ControlLoopMetrics.manager.getCacheSize());
assertTrue(ControlLoopMetrics.manager.getTransactionIds().isEmpty());
assertTrue(ControlLoopMetrics.manager.getTransactions().isEmpty());
@@ -178,4 +181,4 @@ public class ControlLoopMetricsFeatureTest {
ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
assertTrue(feature.getSequenceNumber() == ControlLoopMetricsFeature.FEATURE_SEQUENCE_PRIORITY);
}
-} \ No newline at end of file
+}