From 770e374bc2e4ba814bb0e59eadf0f9fe2d5291e5 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 27 May 2020 10:49:39 -0400 Subject: Include response in OperationOutcome Added the response field and modified the actors to populate it. Issue-ID: POLICY-2592 Change-Id: I24487b6fbc23b69bde4a95acd470864d8231c49d Signed-off-by: Jim Hahn --- .../onap/policy/controlloop/actor/guard/GuardOperation.java | 2 ++ .../policy/controlloop/actor/guard/GuardOperationTest.java | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'models-interactions/model-actors/actor.guard/src') diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java index 3a7821ec2..da1f95603 100644 --- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java +++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java @@ -142,6 +142,8 @@ public class GuardOperation extends HttpOperation { protected CompletableFuture postProcessResponse(OperationOutcome outcome, String url, Response rawResponse, DecisionResponse response) { + outcome.setResponse(response); + // determine the result String status = response.getStatus(); if (status == null) { diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java index 58d54a5ed..daf4dff6e 100644 --- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java +++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java @@ -24,6 +24,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -119,6 +121,7 @@ public class GuardOperationTest extends BasicHttpOperation { outcome = oper.start().get(); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof DecisionResponse); } /** @@ -135,6 +138,7 @@ public class GuardOperationTest extends BasicHttpOperation { outcome = oper.start().get(); assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof DecisionResponse); } @Test @@ -159,7 +163,9 @@ public class GuardOperationTest extends BasicHttpOperation { executor.runAll(100); assertTrue(future2.isDone()); - assertEquals(PolicyResult.SUCCESS, future2.get().getResult()); + outcome = future2.get(); + assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(resp, outcome.getResponse()); assertNotNull(oper.getSubRequestId()); assertEquals(oper.getSubRequestId(), future2.get().getSubRequestId()); @@ -181,7 +187,9 @@ public class GuardOperationTest extends BasicHttpOperation { // should already be done assertTrue(future2.isDone()); - assertEquals(PolicyResult.SUCCESS, future2.get().getResult()); + outcome = future2.get(); + assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertNull(outcome.getResponse()); // ensure callbacks were invoked verify(started).accept(any()); @@ -246,6 +254,7 @@ public class GuardOperationTest extends BasicHttpOperation { oper.postProcessResponse(outcome, BASE_URI, rawResponse, response); assertEquals(expectedResult, outcome.getResult()); assertEquals(expectedMessage, outcome.getMessage()); + assertSame(response, outcome.getResponse()); } @Override -- cgit 1.2.3-korg