summaryrefslogtreecommitdiffstats
path: root/controlloop/common/controller-usecases
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2022-02-09 21:09:30 -0600
committerjhh <jorge.hernandez-herrero@att.com>2022-02-09 21:18:44 -0600
commit1ce041490b2b4aafb700c905b23d17037e42f153 (patch)
tree8c4e333b31933e16efe7b8c7ca7061430a09c52f /controlloop/common/controller-usecases
parentda7e9bded7185b6713b7c6a19ed17ae953864138 (diff)
transaction records cleanup
Issue-ID: POLICY-3761 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Id842d8ca5773d0c1104ae387519375fb914bdf4f Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'controlloop/common/controller-usecases')
-rw-r--r--controlloop/common/controller-usecases/src/main/resources/usecases.drl44
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java20
2 files changed, 45 insertions, 19 deletions
diff --git a/controlloop/common/controller-usecases/src/main/resources/usecases.drl b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
index 932b08cf6..0e1f7de66 100644
--- a/controlloop/common/controller-usecases/src/main/resources/usecases.drl
+++ b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2022 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.
@@ -160,7 +160,8 @@ rule "EVENT"
notification.setNotification(ControlLoopNotificationType.REJECTED);
notification.setFrom("policy");
notification.setMessage("Missing requestId");
- notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($params.getPolicyName());
notification.setPolicyVersion($params.getPolicyVersion());
} else {
@@ -179,7 +180,9 @@ rule "EVENT"
notification = manager.makeNotification();
notification.setNotification(ControlLoopNotificationType.ACTIVE);
- notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($params.getPolicyName());
+ notification.setPolicyVersion($params.getPolicyVersion());
} else {
// Note: the notification will be generated lazily
@@ -197,7 +200,8 @@ rule "EVENT"
notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.REJECTED);
notification.setMessage("Exception occurred: " + e.getMessage());
- notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($params.getPolicyName());
notification.setPolicyVersion($params.getPolicyVersion());
}
//
@@ -374,7 +378,9 @@ rule "EVENT.MANAGER.ACCEPT"
VirtualControlLoopNotification notification = $manager.makeNotification();
notification.setNotification(ControlLoopNotificationType.ACTIVE);
- notification.setPolicyName($manager.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($manager.getPolicyName());
+ notification.setPolicyVersion($manager.getPolicyVersion());
$manager.deliver("POLICY-CL-MGT", notification, "notification", drools.getRule().getName());
} catch(RuntimeException e) {
@@ -508,7 +514,9 @@ rule "EVENT.MANAGER.PROCESS.GUARD.OUTCOME"
try {
VirtualControlLoopNotification notification = $manager.makeNotification();
notification.setNotification(ControlLoopNotificationType.OPERATION);
- notification.setPolicyName($manager.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($manager.getPolicyName());
+ notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory(Collections.emptyList());
// get actor/operation name from the policy step, not from the guard step
@@ -570,7 +578,9 @@ rule "EVENT.MANAGER.PROCESS.POLICY.STARTED"
VirtualControlLoopNotification notification = $manager.makeNotification();
notification.setNotification(ControlLoopNotificationType.OPERATION);
- notification.setPolicyName($manager.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($manager.getPolicyName());
+ notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory(Collections.emptyList());
notification.setMessage($manager.getOperationMessage());
@@ -662,7 +672,9 @@ rule "EVENT.MANAGER.PROCESS.POLICY.SUCCESS"
VirtualControlLoopNotification notification = $manager.makeNotification();
notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS);
- notification.setPolicyName($manager.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($manager.getPolicyName());
+ notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory($manager.getPartialHistory().stream().map(OperationOutcome2::getClOperation)
.collect(Collectors.toList()));
@@ -724,7 +736,9 @@ rule "EVENT.MANAGER.PROCESS.FINAL.FAILURE.ACCEPTED"
VirtualControlLoopNotification notification = $manager.makeNotification();
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
- notification.setPolicyName($manager.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($manager.getPolicyName());
+ notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory($manager.getPartialHistory().stream().map(OperationOutcome2::getClOperation)
.collect(Collectors.toList()));
@@ -781,7 +795,9 @@ rule "EVENT.MANAGER.PROCESS.FINAL.FAILURE.REJECTED"
VirtualControlLoopNotification notification = $manager.makeNotification();
notification.setNotification(ControlLoopNotificationType.REJECTED);
- notification.setPolicyName($manager.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($manager.getPolicyName());
+ notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory($manager.getPartialHistory().stream().map(OperationOutcome2::getClOperation)
.collect(Collectors.toList()));
@@ -835,7 +851,9 @@ rule "EVENT.MANAGER.PROCESS.POLICY.FAILURE"
VirtualControlLoopNotification notification = $manager.makeNotification();
notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
- notification.setPolicyName($manager.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($manager.getPolicyName());
+ notification.setPolicyVersion($manager.getPolicyVersion());
$manager.deliver("POLICY-CL-MGT", notification, "notification", drools.getRule().getName());
@@ -981,7 +999,9 @@ rule "EVENT.MANAGER.FINAL"
try {
VirtualControlLoopNotification notification = $manager.makeNotification();
- notification.setPolicyName($manager.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope(drools.getRule().getName());
+ notification.setPolicyName($manager.getPolicyName());
+ notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory($manager.getFullHistory().stream().map(OperationOutcome2::getClOperation)
.collect(Collectors.toList()));
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java
index ef40d302e..5077f8fb8 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2022 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.
@@ -90,18 +90,23 @@ public class UsecasesTest extends DroolsRuleTest {
String policyName = policy.getIdentifier().getName();
policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.ACTIVE
- && (policyName + ".EVENT.MANAGER.ACCEPT").equals(notif.getPolicyName()));
+ && "EVENT.MANAGER.ACCEPT".equals(notif.getPolicyScope())
+ && policyName.equals(notif.getPolicyName()));
policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.OPERATION
- && (policyName + ".EVENT.MANAGER.PROCESS.GUARD.OUTCOME").equals(notif.getPolicyName())
+ && "EVENT.MANAGER.PROCESS.GUARD.OUTCOME".equals(notif.getPolicyScope())
+ && policyName.equals(notif.getPolicyName())
&& notif.getMessage().startsWith("Sending guard query"));
policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.OPERATION
- && (policyName + ".EVENT.MANAGER.PROCESS.GUARD.OUTCOME").equals(notif.getPolicyName())
- && notif.getMessage().startsWith("Guard result") && notif.getMessage().endsWith("Permit"));
+ && "EVENT.MANAGER.PROCESS.GUARD.OUTCOME".equals(notif.getPolicyScope())
+ && policyName.equals(notif.getPolicyName())
+ && notif.getMessage().startsWith("Guard result")
+ && notif.getMessage().endsWith("Permit"));
policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.OPERATION
- && (policyName + ".EVENT.MANAGER.PROCESS.POLICY.STARTED").equals(notif.getPolicyName())
+ && "EVENT.MANAGER.PROCESS.POLICY.STARTED".equals(notif.getPolicyScope())
+ && policyName.equals(notif.getPolicyName())
&& notif.getMessage().startsWith("actor="));
}
@@ -110,7 +115,8 @@ public class UsecasesTest extends DroolsRuleTest {
Listener<VirtualControlLoopNotification> policyClMgt, ControlLoopNotificationType finalType) {
return policyClMgt.await(notif -> notif.getNotification() == finalType
- && (policy.getIdentifier().getName() + ".EVENT.MANAGER.FINAL").equals(notif.getPolicyName()));
+ && "EVENT.MANAGER.FINAL".equals(notif.getPolicyScope())
+ && (policy.getIdentifier().getName()).equals(notif.getPolicyName()));
}
@Override