diff options
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider/src')
7 files changed, 36 insertions, 2 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java index e2d94b3b3..0fd2c0bfd 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java @@ -43,6 +43,7 @@ public class OperationOutcome { private PolicyResult result = PolicyResult.SUCCESS; private String message; private boolean finalOutcome; + private Object response; private ControlLoopResponse controlLoopResponse; /** @@ -60,6 +61,7 @@ public class OperationOutcome { this.result = source.result; this.message = source.message; this.finalOutcome = source.finalOutcome; + this.response = source.response; this.controlLoopResponse = source.controlLoopResponse; } @@ -85,6 +87,11 @@ public class OperationOutcome { return clo; } + @SuppressWarnings("unchecked") + public <T> T getResponse() { + return (T) response; + } + /** * Determines if this outcome is for the given actor and operation. * diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java index 9decd8a61..8285a5635 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java @@ -250,6 +250,7 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial * @return the updated operation */ public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, S response) { + outcome.setResponse(response); return setOutcome(outcome, result); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java index e83fe8c94..1acc1ff65 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java @@ -217,6 +217,7 @@ public abstract class HttpOperation<T> extends OperationPartial { public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, Response rawResponse, T response) { + outcome.setResponse(response); return setOutcome(outcome, result); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java index 77d2253e1..c60a0f00c 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java @@ -42,6 +42,7 @@ public class OperationOutcomeTest { private static final String SUB_REQ_ID = "my-sub-request-id"; private static final PolicyResult RESULT = PolicyResult.FAILURE_GUARD; private static final String MESSAGE = "my-message"; + private static final String RESPONSE = "my-response"; private ControlLoopResponse response; private OperationOutcome outcome; @@ -70,6 +71,7 @@ public class OperationOutcomeTest { assertEquals(SUB_REQ_ID, outcome2.getSubRequestId()); assertEquals(RESULT, outcome2.getResult()); assertEquals(MESSAGE, outcome2.getMessage()); + assertSame(RESPONSE, outcome2.getResponse()); assertSame(response, outcome2.getControlLoopResponse()); } @@ -142,6 +144,7 @@ public class OperationOutcomeTest { outcome.setStart(START); outcome.setSubRequestId(SUB_REQ_ID); outcome.setTarget(TARGET); + outcome.setResponse(RESPONSE); outcome.setControlLoopResponse(response); } } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java index 55782a34d..84a4d5d29 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java @@ -38,6 +38,7 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.junit.Before; @@ -85,6 +86,7 @@ public class BidirectionalTopicOperationTest { private ControlLoopOperationParams params; private OperationOutcome outcome; private StandardCoderObject stdResponse; + private MyResponse response; private String responseText; private PseudoExecutor executor; private int ntimes; @@ -109,7 +111,9 @@ public class BidirectionalTopicOperationTest { params = ControlLoopOperationParams.builder().actor(ACTOR).operation(OPERATION).executor(executor).build(); outcome = params.makeOutcome(); - responseText = coder.encode(new MyResponse()); + response = new MyResponse(); + response.setRequestId(REQ_ID); + responseText = coder.encode(response); stdResponse = coder.decode(responseText, StandardCoderObject.class); ntimes = 1; @@ -159,6 +163,7 @@ public class BidirectionalTopicOperationTest { assertSame(outcome, future.get()); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(response, outcome.getResponse()); verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue())); } @@ -258,6 +263,7 @@ public class BidirectionalTopicOperationTest { assertSame(outcome, oper2.processResponse(outcome, TEXT, null)); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(TEXT, outcome.getResponse()); } /** @@ -270,6 +276,7 @@ public class BidirectionalTopicOperationTest { assertSame(outcome, oper2.processResponse(outcome, responseText, stdResponse)); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(stdResponse, outcome.getResponse()); } /** @@ -286,6 +293,7 @@ public class BidirectionalTopicOperationTest { assertSame(outcome, oper.processResponse(outcome, responseText, stdResponse)); assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(resp, outcome.getResponse()); } /** @@ -295,6 +303,7 @@ public class BidirectionalTopicOperationTest { public void testProcessResponseDecodeOk() throws CoderException { assertSame(outcome, oper.processResponse(outcome, responseText, stdResponse)); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(response, outcome.getResponse()); } /** @@ -344,8 +353,9 @@ public class BidirectionalTopicOperationTest { @Getter @Setter + @EqualsAndHashCode public static class MyResponse { - private String requestId = REQ_ID; + private String requestId; private String output; } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java index 81238defa..eb1aa880f 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java @@ -256,6 +256,7 @@ public class HttpOperationTest { callback.get().completed(response); assertSame(outcome, future2.get(5, TimeUnit.SECONDS)); + assertSame(TEXT, outcome.getResponse()); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); } @@ -290,6 +291,7 @@ public class HttpOperationTest { assertTrue(result.isDone()); assertSame(outcome, result.get()); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertSame(TEXT, outcome.getResponse()); } /** @@ -302,6 +304,7 @@ public class HttpOperationTest { assertTrue(result.isDone()); assertSame(outcome, result.get()); assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertSame(TEXT, outcome.getResponse()); } /** @@ -317,6 +320,7 @@ public class HttpOperationTest { assertTrue(result.isDone()); assertSame(outcome, result.get()); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(Integer.valueOf(10), outcome.getResponse()); } /** @@ -357,6 +361,7 @@ public class HttpOperationTest { assertNotNull(outcome); assertEquals(1, nget); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof MyResponse); } /** @@ -373,6 +378,7 @@ public class HttpOperationTest { assertNotNull(outcome); assertEquals(1, ndelete); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof String); } /** @@ -388,6 +394,7 @@ public class HttpOperationTest { assertNotNull(outcome); assertEquals(1, npost); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof MyResponse); } /** @@ -404,6 +411,7 @@ public class HttpOperationTest { assertNotNull(outcome); assertEquals(1, nput); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof MyResponse); } @Test diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java index 75463b9d7..f5fd9fb75 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java @@ -1027,6 +1027,10 @@ public class OperationPartialTest { assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage()); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + oper.setOutcome(outcome, PolicyResult.SUCCESS); + assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage()); + assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + for (PolicyResult result : FAILURE_RESULTS) { outcome = new OperationOutcome(); oper.setOutcome(outcome, result); |