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 --- .../policy/controlloop/actor/vfc/VfcOperation.java | 2 ++ .../onap/policy/controlloop/actor/vfc/RestartTest.java | 3 +++ .../policy/controlloop/actor/vfc/VfcOperationTest.java | 18 +++++++++--------- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'models-interactions/model-actors/actor.vfc/src') diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java index 827109d10..573ee2698 100644 --- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java +++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java @@ -119,6 +119,7 @@ public abstract class VfcOperation extends HttpOperation { if (getCount++ >= getMaxGets()) { logger.warn("{}: execeeded 'get' limit {} for {}", getFullName(), getMaxGets(), params.getRequestId()); setOutcome(outcome, PolicyResult.FAILURE_TIMEOUT); + outcome.setResponse(response); outcome.setMessage(VFC_RESPONSE_CODE + " " + outcome.getMessage()); return CompletableFuture.completedFuture(outcome); } @@ -179,6 +180,7 @@ public abstract class VfcOperation extends HttpOperation { // set default result and message setOutcome(outcome, result); + outcome.setResponse(response); outcome.setMessage(rawResponse.getStatus() + " " + outcome.getMessage()); return outcome; } diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java index 5fe4973ce..d8ba7e4e8 100644 --- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java +++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java @@ -22,6 +22,7 @@ package org.onap.policy.controlloop.actor.vfc; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.util.concurrent.CompletableFuture; import org.apache.commons.lang3.tuple.Pair; @@ -33,6 +34,7 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.vfc.VfcRequest; +import org.onap.policy.vfc.VfcResponse; public class RestartTest extends BasicVfcOperation { private Restart restartOper; @@ -72,6 +74,7 @@ public class RestartTest extends BasicVfcOperation { outcome = restartOper.start().get(); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof VfcResponse); } @Test diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java index 4d98b97c9..0b58fd4a3 100644 --- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java +++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java @@ -82,30 +82,30 @@ public class VfcOperationTest extends BasicVfcOperation { response.setResponseDescriptor(new VfcResponseDescriptor()); response.setJobId("sampleJobId"); + + // null status CompletableFuture future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response); assertFalse(future2.isDone()); - // assertSame(outcome, future2.get()); TODO Hanging - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); response.getResponseDescriptor().setStatus("FinisHeD"); future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response); assertTrue(future2.isDone()); assertSame(outcome, future2.get()); assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertSame(response, outcome.getResponse()); + // failed response.getResponseDescriptor().setStatus("eRRor"); future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response); assertTrue(future2.isDone()); assertSame(outcome, future2.get()); assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertSame(response, outcome.getResponse()); - // failed - /* - * response.getResponseDescriptor().setStatus("anything but finished"); future2 = - * oper.postProcessResponse(outcome, PATH, rawResponse, response); - * assertTrue(future2.isDone()); assertSame(outcome, future2.get()); - * assertEquals(PolicyResult.FAILURE, outcome.getResult()); - */ + // unfinished + response.getResponseDescriptor().setStatus("anything but finished"); + future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response); + assertFalse(future2.isDone()); } @Test -- cgit 1.2.3-korg