summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-05-27 17:57:51 -0400
committerJim Hahn <jrh3@att.com>2020-05-28 10:31:50 -0400
commitf9bd8844ef8f572cd0db639a9721caa42c17dfe2 (patch)
treeb76001ba365fa04af9225341e427f017d0127e8d /controlloop/common/eventmanager/src/test
parentba13401d2878da975b7decd0cf72f40bda1de7bc (diff)
Generate SDNR notification in drools-apps
Modified drools-apps to generate the SDNR notification using the SDNR-response provided by the actor in the operation outcome, instead of using the controlloop-response provided in the operation outcome, as the latter is deprecated. Issue-ID: POLICY-2593 Change-Id: I70ee4a4b11345a4295d720250a63f407f51cb0bd Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/test')
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java54
1 files changed, 42 insertions, 12 deletions
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java
index 6fda667eb..90fdccabb 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java
@@ -70,6 +70,9 @@ import org.onap.policy.controlloop.policy.Policy;
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.sdnr.PciBody;
+import org.onap.policy.sdnr.PciMessage;
+import org.onap.policy.sdnr.PciResponse;
public class ControlLoopOperationManager2Test {
private static final UUID REQ_ID = UUID.randomUUID();
@@ -345,12 +348,21 @@ public class ControlLoopOperationManager2Test {
@Test
public void testMakeControlLoopResponse() {
- // should always return its input, if non-null
- ControlLoopResponse resp = new ControlLoopResponse();
- assertSame(resp, mgr.makeControlLoopResponse(resp));
+ final OperationOutcome outcome = new OperationOutcome();
+ PciMessage msg = new PciMessage();
+ outcome.setResponse(msg);
+
+ PciBody body = new PciBody();
+ msg.setBody(body);
+
+ PciResponse output = new PciResponse();
+ body.setOutput(output);
+
+ output.setPayload("my-payload");
+
// not an SDNR action - should return null
- assertNull(mgr.makeControlLoopResponse(null));
+ assertNull(mgr.makeControlLoopResponse(outcome));
/*
* now work with SDNR actor
@@ -358,15 +370,26 @@ public class ControlLoopOperationManager2Test {
policy.setActor("SDNR");
mgr = new ControlLoopOperationManager2(mgrctx, context, policy, executor);
- // should still return its input, if non-null
- resp = new ControlLoopResponse();
- assertSame(resp, mgr.makeControlLoopResponse(resp));
+ // should return null for a null input
+ assertNull(mgr.makeControlLoopResponse(null));
- // should generate a response
- resp = mgr.makeControlLoopResponse(null);
- assertNotNull(resp);
- assertEquals(REQ_ID, resp.getRequestId());
- assertNull(resp.getPayload());
+ // should generate a response, with a payload
+ checkResp(outcome, "my-payload");
+
+ /*
+ * these should generate a response, with null payload
+ */
+ output.setPayload(null);
+ checkResp(outcome, null);
+
+ body.setOutput(null);
+ checkResp(outcome, null);
+
+ msg.setBody(null);
+ checkResp(outcome, null);
+
+ outcome.setResponse(null);
+ checkResp(outcome, null);
}
@Test
@@ -977,6 +1000,13 @@ public class ControlLoopOperationManager2Test {
target.setType(TargetType.VNF);
}
+ private void checkResp(OperationOutcome outcome, String expectedPayload) {
+ ControlLoopResponse resp = mgr.makeControlLoopResponse(outcome);
+ assertNotNull(resp);
+ assertEquals(REQ_ID, resp.getRequestId());
+ assertEquals(expectedPayload, resp.getPayload());
+ }
+
private void verifyDb(int nrecords, PolicyResult expectedResult, String expectedMsg) {
ArgumentCaptor<String> entityCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<ControlLoopOperation> opCaptor = ArgumentCaptor.forClass(ControlLoopOperation.class);