aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actorServiceProvider/src/test
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/actorServiceProvider/src/test
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/actorServiceProvider/src/test')
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java3
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java14
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java8
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java4
4 files changed, 27 insertions, 2 deletions
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);