summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/eventmanager/src/test/java')
-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);