aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.vfc/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-05-27 10:49:39 -0400
committerJim Hahn <jrh3@att.com>2020-05-27 16:31:35 -0400
commit770e374bc2e4ba814bb0e59eadf0f9fe2d5291e5 (patch)
treed9ad1100fbb13b468865474a3450700b1b5c9f52 /models-interactions/model-actors/actor.vfc/src
parentddd400dc81f6bdabc76924cf904af540aa912ca2 (diff)
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 <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.vfc/src')
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java2
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java3
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java18
3 files changed, 14 insertions, 9 deletions
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<VfcResponse> {
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<VfcResponse> {
// 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<OperationOutcome> 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