summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actorServiceProvider
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-03-06 18:22:28 -0500
committerJim Hahn <jrh3@att.com>2020-03-06 19:04:13 -0500
commit2440b81428fa4bfa28a51f87c58e12c78ced744b (patch)
tree61ca5668446ed47301ee3b2cca520cc7a83d46aa /models-interactions/model-actors/actorServiceProvider
parent3c1fb89886d7ebf2efe1183e92b4ed8191f506b4 (diff)
Add subrequest ID to OperationOutcome
Rule notifications need the subrequest ID to be populated in the OperationOutcome object, where possible. Issue-ID: POLICY-2385 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ic44320f67ad8df7bcb3000cfa667f95427818e71
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider')
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java11
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java17
2 files changed, 19 insertions, 9 deletions
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 b38ddb08a..ec522a405 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
@@ -25,6 +25,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.BiConsumer;
import lombok.Getter;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoderObject;
@@ -105,7 +106,10 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
@Override
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
- final Q request = makeRequest(attempt);
+ final Pair<String,Q> pair = makeRequest(attempt);
+ final Q request = pair.getRight();
+ outcome.setSubRequestId(pair.getLeft());
+
final List<String> expectedKeyValues = getExpectedKeyValues(attempt, request);
final PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>();
@@ -142,9 +146,10 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
* Makes the request.
*
* @param attempt operation attempt
- * @return a new request
+ * @return a pair containing sub request ID, which may be {@code null} and the new
+ * request
*/
- protected abstract Q makeRequest(int attempt);
+ protected abstract Pair<String, Q> makeRequest(int attempt);
/**
* Gets values, expected in the response, that should match the selector keys.
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 5725a6d61..587564a2e 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
@@ -40,6 +40,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
import lombok.Getter;
import lombok.Setter;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -66,6 +67,7 @@ public class BidirectionalTopicOperationTest {
private static final String OPERATION = "my-operation";
private static final String REQ_ID = "my-request-id";
private static final String TEXT = "some text";
+ private static final String SUB_REQID = "my-sub-request-id";
private static final int TIMEOUT_SEC = 10;
private static final long TIMEOUT_MS = 1000 * TIMEOUT_SEC;
private static final int MAX_REQUESTS = 100;
@@ -136,6 +138,8 @@ public class BidirectionalTopicOperationTest {
CompletableFuture<OperationOutcome> future = oper.startOperationAsync(1, outcome);
assertFalse(future.isDone());
+ assertEquals(SUB_REQID, outcome.getSubRequestId());
+
verify(forwarder).register(eq(Arrays.asList(REQ_ID)), listenerCaptor.capture());
verify(forwarder, never()).unregister(any(), any());
@@ -323,13 +327,14 @@ public class BidirectionalTopicOperationTest {
private class MyStringOperation extends BidirectionalTopicOperation<String, String> {
+
public MyStringOperation() {
super(BidirectionalTopicOperationTest.this.params, config, String.class);
}
@Override
- protected String makeRequest(int attempt) {
- return TEXT;
+ protected Pair<String, String> makeRequest(int attempt) {
+ return Pair.of(SUB_REQID, TEXT);
}
@Override
@@ -350,8 +355,8 @@ public class BidirectionalTopicOperationTest {
}
@Override
- protected MyRequest makeRequest(int attempt) {
- return new MyRequest();
+ protected Pair<String, MyRequest> makeRequest(int attempt) {
+ return Pair.of(SUB_REQID, new MyRequest());
}
@Override
@@ -372,8 +377,8 @@ public class BidirectionalTopicOperationTest {
}
@Override
- protected MyRequest makeRequest(int attempt) {
- return new MyRequest();
+ protected Pair<String, MyRequest> makeRequest(int attempt) {
+ return Pair.of(SUB_REQID, new MyRequest());
}
@Override