summaryrefslogtreecommitdiffstats
path: root/models-interactions
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2020-03-10 09:18:30 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-10 09:18:30 +0000
commit3adc525adc0c288810d9d3a0c2181f9ba46b46c9 (patch)
treeacbb2d5721f57cad75fa24f66b00fdcfb147e8ab /models-interactions
parent55ad41aeaca2bb3c8975355cc026532b01d5d0e7 (diff)
parent2440b81428fa4bfa28a51f87c58e12c78ced744b (diff)
Merge "Add subrequest ID to OperationOutcome"
Diffstat (limited to 'models-interactions')
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java1
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java1
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java2
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java2
-rw-r--r--models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java8
-rw-r--r--models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java3
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java34
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java6
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java5
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java19
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java2
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java2
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java1
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java3
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java9
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperation.java15
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java5
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java6
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java15
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java15
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java4
-rw-r--r--models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java1
-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
24 files changed, 128 insertions, 59 deletions
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
index 5b4aa0527..9f8d30a26 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
@@ -92,6 +92,7 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
@Override
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
+ outcome.setSubRequestId(String.valueOf(attempt));
final Map<String, String> request = makeRequest();
Map<String, Object> headers = makeHeaders();
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
index b527abc36..9ff56d61f 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
@@ -91,6 +91,7 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> {
@Override
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
+ outcome.setSubRequestId(String.valueOf(attempt));
Map<String, Object> headers = makeHeaders();
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
index c24e45db7..dae443593 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
@@ -127,6 +127,8 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
// custom query response should have been cached within the context
AaiCqResponse cqData = context.getProperty(AaiCqResponse.CONTEXT_KEY);
assertNotNull(cqData);
+
+ assertEquals("1", future2.get().getSubRequestId());
}
/**
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
index 8e2633141..b0420456e 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
@@ -91,6 +91,8 @@ public class AaiGetOperationTest extends BasicAaiOperation<Void> {
StandardCoderObject data = context.getProperty(AaiGetOperation.getTenantKey(TARGET_ENTITY));
assertNotNull(data);
assertEquals(TEXT, data.getString(INPUT_FIELD));
+
+ assertEquals("1", future2.get().getSubRequestId());
}
/**
diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
index 43bb81de0..5e84871cc 100644
--- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.appc.CommonHeader;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
@@ -85,13 +86,14 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
* @param targetVnf target VNF
* @return a new request
*/
- protected Request makeRequest(int attempt, String targetVnf) {
+ protected Pair<String, Request> makeRequest(int attempt, String targetVnf) {
Request request = new Request();
request.setCommonHeader(new CommonHeader());
request.getCommonHeader().setRequestId(params.getRequestId());
// TODO ok to use UUID, or does it have to be the "attempt"?
- request.getCommonHeader().setSubRequestId(UUID.randomUUID().toString());
+ final String subreq = UUID.randomUUID().toString();
+ request.getCommonHeader().setSubRequestId(subreq);
request.setAction(getName());
@@ -105,7 +107,7 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
// add/replace specific values
request.getPayload().put(VNF_ID_KEY, targetVnf);
- return request;
+ return Pair.of(subreq, request);
}
/**
diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java
index a318444aa..e4fd51c07 100644
--- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java
@@ -21,6 +21,7 @@
package org.onap.policy.controlloop.actor.appc;
import java.util.concurrent.CompletableFuture;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.aai.AaiConstants;
import org.onap.policy.aai.AaiCqResponse;
@@ -60,7 +61,7 @@ public class ModifyConfigOperation extends AppcOperation {
}
@Override
- protected Request makeRequest(int attempt) {
+ protected Pair<String, Request> makeRequest(int attempt) {
AaiCqResponse cq = params.getContext().getProperty(AaiCqResponse.CONTEXT_KEY);
GenericVnf genvnf = cq.getGenericVnfByModelInvariantId(params.getTarget().getResourceID());
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
index 8b71b614d..204d95aa1 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
@@ -29,6 +29,7 @@ import static org.junit.Assert.assertSame;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.appc.CommonHeader;
@@ -50,7 +51,7 @@ public class AppcOperationTest extends BasicAppcOperation {
oper = new AppcOperation(params, config) {
@Override
- protected Request makeRequest(int attempt) {
+ protected Pair<String, Request> makeRequest(int attempt) {
return oper.makeRequest(attempt, MY_VNF);
}
};
@@ -69,7 +70,11 @@ public class AppcOperationTest extends BasicAppcOperation {
@Test
public void testMakeRequest() {
- Request request = oper.makeRequest(2, MY_VNF);
+ Pair<String, Request> result = oper.makeRequest(2, MY_VNF);
+ String subreq = result.getLeft();
+ assertNotNull(subreq);
+
+ Request request = result.getRight();
assertEquals(DEFAULT_OPERATION, request.getAction());
assertNotNull(request.getPayload());
@@ -78,26 +83,29 @@ public class AppcOperationTest extends BasicAppcOperation {
assertNotNull(header);
assertEquals(params.getRequestId(), header.getRequestId());
- String subreq = header.getSubRequestId();
- assertNotNull(subreq);
+ assertEquals(subreq, header.getSubRequestId());
// a subsequent request should have a different sub-request id
- assertNotEquals(subreq, oper.makeRequest(2, MY_VNF).getCommonHeader().getSubRequestId());
+ result = oper.makeRequest(2, MY_VNF);
+ assertNotEquals(subreq, result.getLeft());
+
+ assertNotNull(result.getLeft());
+ assertEquals(result.getLeft(), result.getRight().getCommonHeader().getSubRequestId());
// repeat using a null payload
params = params.toBuilder().payload(null).build();
oper = new AppcOperation(params, config) {
@Override
- protected Request makeRequest(int attempt) {
+ protected Pair<String, Request> makeRequest(int attempt) {
return oper.makeRequest(attempt, MY_VNF);
}
};
- assertEquals(Map.of(AppcOperation.VNF_ID_KEY, MY_VNF), oper.makeRequest(2, MY_VNF).getPayload());
+ assertEquals(Map.of(AppcOperation.VNF_ID_KEY, MY_VNF), oper.makeRequest(2, MY_VNF).getRight().getPayload());
}
@Test
public void testConvertPayload() {
- Request request = oper.makeRequest(2, MY_VNF);
+ Request request = oper.makeRequest(2, MY_VNF).getRight();
// @formatter:off
assertEquals(
@@ -118,11 +126,11 @@ public class AppcOperationTest extends BasicAppcOperation {
oper = new AppcOperation(params, config) {
@Override
- protected Request makeRequest(int attempt) {
+ protected Pair<String, Request> makeRequest(int attempt) {
return oper.makeRequest(attempt, MY_VNF);
}
};
- request = oper.makeRequest(2, MY_VNF);
+ request = oper.makeRequest(2, MY_VNF).getRight();
// @formatter:off
assertEquals(
@@ -144,11 +152,11 @@ public class AppcOperationTest extends BasicAppcOperation {
oper = new AppcOperation(params, config) {
@Override
- protected Request makeRequest(int attempt) {
+ protected Pair<String, Request> makeRequest(int attempt) {
return oper.makeRequest(attempt, MY_VNF);
}
};
- request = oper.makeRequest(2, MY_VNF);
+ request = oper.makeRequest(2, MY_VNF).getRight();
payload.put(AppcOperation.VNF_ID_KEY, MY_VNF);
payload.put(KEY1, "abc");
@@ -160,7 +168,7 @@ public class AppcOperationTest extends BasicAppcOperation {
@Test
public void testGetExpectedKeyValues() {
- Request request = oper.makeRequest(2, MY_VNF);
+ Request request = oper.makeRequest(2, MY_VNF).getRight();
assertEquals(Arrays.asList(request.getCommonHeader().getSubRequestId()),
oper.getExpectedKeyValues(50, request));
}
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
index 460f2c9f0..95629bccf 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
@@ -34,6 +34,7 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.domain.yang.GenericVnf;
@@ -108,7 +109,10 @@ public class ModifyConfigOperationTest extends BasicAppcOperation {
genvnf.setModelInvariantId(RESOURCE_ID);
cq.setInventoryResponseItems(Arrays.asList(genvnf));
- Request request = oper.makeRequest(2);
+ Pair<String, Request> result = oper.makeRequest(2);
+ assertNotNull(result.getLeft());
+
+ Request request = result.getRight();
assertNotNull(request);
assertEquals(MY_VNF, request.getPayload().get(ModifyConfigOperation.VNF_ID_KEY));
diff --git a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java
index 749622714..87ff357e9 100644
--- a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java
+++ b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.appclcm.AppcLcmBody;
import org.onap.policy.appclcm.AppcLcmCommonHeader;
import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
@@ -80,7 +81,7 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr
}
@Override
- protected AppcLcmDmaapWrapper makeRequest(int attempt) {
+ protected Pair<String, AppcLcmDmaapWrapper> makeRequest(int attempt) {
VirtualControlLoopEvent onset = params.getContext().getEvent();
String subRequestId = UUID.randomUUID().toString();
@@ -125,7 +126,7 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr
body.setInput(inputRequest);
dmaapRequest.setBody(body);
- return dmaapRequest;
+ return Pair.of(subRequestId, dmaapRequest);
}
/**
diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
index e94eaecd2..8e6a603eb 100644
--- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
+++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
@@ -36,6 +36,7 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.appclcm.AppcLcmBody;
@@ -118,20 +119,26 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation {
@Test
public void testMakeRequest() {
- AppcLcmDmaapWrapper request = oper.makeRequest(2);
+ Pair<String, AppcLcmDmaapWrapper> result = oper.makeRequest(2);
+ String subreq = result.getLeft();
+ assertNotNull(subreq);
+
+ AppcLcmDmaapWrapper request = result.getRight();
assertEquals("DefaultOperation", request.getBody().getInput().getAction());
AppcLcmCommonHeader header = request.getBody().getInput().getCommonHeader();
assertNotNull(header);
assertEquals(params.getRequestId(), header.getRequestId());
- String subreq = header.getSubRequestId();
- assertNotNull(subreq);
+ assertEquals(subreq, header.getSubRequestId());
assertEquals("{vnf-id=my-target}", request.getBody().getInput().getActionIdentifiers().toString());
// a subsequent request should have a different sub-request id
- assertNotEquals(subreq, oper.makeRequest(2).getBody().getInput().getCommonHeader().getSubRequestId());
+ result = oper.makeRequest(2);
+ assertNotEquals(subreq, result.getLeft());
+ assertNotNull(result.getLeft());
+ assertEquals(result.getLeft(), result.getRight().getBody().getInput().getCommonHeader().getSubRequestId());
}
@Test
@@ -140,7 +147,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation {
params = params.toBuilder().operation(AppcLcmConstants.OPERATION_CONFIG_MODIFY).build();
oper = new AppcLcmOperation(params, config);
- AppcLcmDmaapWrapper req = oper.makeRequest(2);
+ AppcLcmDmaapWrapper req = oper.makeRequest(2).getRight();
assertEquals("{\"key-A\":\"value-A\"}", req.getBody().getInput().getPayload());
// coder exception
@@ -162,7 +169,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation {
@Test
public void testGetExpectedKeyValues() {
- AppcLcmDmaapWrapper request = oper.makeRequest(2);
+ AppcLcmDmaapWrapper request = oper.makeRequest(2).getRight();
assertEquals(Arrays.asList(request.getBody().getInput().getCommonHeader().getSubRequestId()),
oper.getExpectedKeyValues(50, request));
}
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 dd8b9273a..431ad3711 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
@@ -89,6 +89,8 @@ public class GuardOperation extends HttpOperation<DecisionResponse> {
return CompletableFuture.completedFuture(params.makeOutcome());
}
+ outcome.setSubRequestId(String.valueOf(attempt));
+
DecisionRequest request = Util.translate(getName(), makeRequest(), DecisionRequest.class);
Entity<DecisionRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
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 a43292a65..be40ef3b4 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
@@ -96,6 +96,8 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> {
assertTrue(future2.isDone());
assertEquals(PolicyResult.SUCCESS, future2.get().getResult());
+
+ assertEquals("1", future2.get().getSubRequestId());
}
/**
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
index 018578829..1aed75ce6 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
@@ -61,6 +61,7 @@ public abstract class SdncOperation extends HttpOperation<SdncResponse> {
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
SdncRequest request = makeRequest(attempt);
+ outcome.setSubRequestId(request.getHealRequest().getRequestHeaderInfo().getSvcRequestId());
Entity<SdncRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
index 50e97496a..73b81433a 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
@@ -23,6 +23,7 @@ package org.onap.policy.controlloop.actor.sdnc;
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.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
@@ -107,6 +108,8 @@ public abstract class BasicSdncOperation extends BasicHttpOperation<SdncRequest>
assertEquals(PolicyResult.SUCCESS, future2.get().getResult());
+ assertNotNull(future2.get().getSubRequestId());
+
return requestCaptor.getValue().getEntity();
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
index a83c354d2..417029d49 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
@@ -29,6 +29,8 @@ import java.util.Map;
import java.util.TreeMap;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.sdnc.SdncHealRequest;
+import org.onap.policy.sdnc.SdncHealRequestHeaderInfo;
import org.onap.policy.sdnc.SdncRequest;
public class SdncOperationTest extends BasicSdncOperation {
@@ -48,6 +50,13 @@ public class SdncOperationTest extends BasicSdncOperation {
request = new SdncRequest();
request.setUrl(MY_URI);
+ SdncHealRequest healRequest = new SdncHealRequest();
+ request.setHealRequest(healRequest);
+
+ SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo();
+ healRequest.setRequestHeaderInfo(headerInfo);
+ headerInfo.setSvcRequestId(SUB_REQ_ID);
+
oper = new SdncOperation(params, config) {
@Override
protected SdncRequest makeRequest(int attempt) {
diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperation.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperation.java
index 67c3d4521..21f1562cf 100644
--- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperation.java
+++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperation.java
@@ -20,17 +20,12 @@
package org.onap.policy.controlloop.actor.sdnr;
-import java.util.concurrent.CompletableFuture;
-import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.sdnr.PciRequestWrapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class ModifyConfigOperation extends SdnrOperation {
- private static final Logger logger = LoggerFactory.getLogger(ModifyConfigOperation.class);
-
public static final String NAME = "ModifyConfig";
/**
@@ -44,14 +39,14 @@ public class ModifyConfigOperation extends SdnrOperation {
}
@Override
- protected PciRequestWrapper makeRequest(int attempt) {
- PciRequestWrapper request = super.makeRequest(attempt);
+ protected Pair<String, PciRequestWrapper> makeRequest(int attempt) {
+ final Pair<String, PciRequestWrapper> req = super.makeRequest(attempt);
+ final PciRequestWrapper request = req.getRight();
//
// Set the recipe and action information
//
request.setRpcName(NAME.toLowerCase());
request.getBody().setAction(NAME);
- logger.info("SDNR ModifyConfig Request to be sent is {}", request);
- return request;
+ return req;
}
}
diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
index 5faa31d7c..b11c701b2 100644
--- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
+++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
@@ -23,6 +23,7 @@ package org.onap.policy.controlloop.actor.sdnr;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation;
@@ -124,7 +125,7 @@ public abstract class SdnrOperation extends BidirectionalTopicOperation<PciReque
}
@Override
- protected PciRequestWrapper makeRequest(int attempt) {
+ protected Pair<String, PciRequestWrapper> makeRequest(int attempt) {
VirtualControlLoopEvent onset = params.getContext().getEvent();
String subRequestId = UUID.randomUUID().toString();
@@ -158,6 +159,6 @@ public abstract class SdnrOperation extends BidirectionalTopicOperation<PciReque
logger.info("SDNR Request to be sent is {}", dmaapRequest);
/* Return the request to be sent through dmaap. */
- return dmaapRequest;
+ return Pair.of(subRequestId, dmaapRequest);
}
}
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java
index d1e192277..19b2063da 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.when;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
@@ -88,7 +89,8 @@ public class ModifyConfigOperationTest extends BasicSdnrOperation {
@Test
public void testMakeRequest() throws CoderException {
- PciRequestWrapper request = oper.makeRequest(1);
- assertNotNull(request);
+ Pair<String, PciRequestWrapper> result = oper.makeRequest(1);
+ assertNotNull(result.getLeft());
+ assertNotNull(result.getRight());
}
}
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
index fc7e86a94..a7bfa3322 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import java.util.Arrays;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation.Status;
@@ -45,12 +46,7 @@ public class SdnrOperationTest extends BasicSdnrOperation {
public void setUp() throws Exception {
super.setUp();
- operation = new SdnrOperation(params, config) {
- @Override
- protected PciRequestWrapper makeRequest(int attempt) {
- return super.makeRequest(attempt);
- }
- };
+ operation = new SdnrOperation(params, config) {};
}
@Test
@@ -61,7 +57,10 @@ public class SdnrOperationTest extends BasicSdnrOperation {
@Test
public void testMakeRequest() {
- PciRequestWrapper request = operation.makeRequest(1);
+ Pair<String, PciRequestWrapper> result = operation.makeRequest(1);
+ assertNotNull(result.getLeft());
+
+ PciRequestWrapper request = result.getRight();
assertNotNull(request.getBody());
assertEquals("1.0", request.getVersion());
@@ -74,7 +73,7 @@ public class SdnrOperationTest extends BasicSdnrOperation {
@Test
public void testGetExpectedKeyValues() {
- PciRequestWrapper request = operation.makeRequest(1);
+ PciRequestWrapper request = operation.makeRequest(1).getRight();
assertEquals(Arrays.asList(request.getBody().getCommonHeader().getSubRequestId()),
operation.getExpectedKeyValues(50, request));
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
index 1ca6c734c..3a14c3bde 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
@@ -198,12 +198,14 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
if (rawResponse.getStatus() == 200) {
String requestState = getRequestState(response);
if (COMPLETE.equalsIgnoreCase(requestState)) {
+ populateSubRequestId(outcome, response);
successfulCompletion();
return CompletableFuture
.completedFuture(setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response));
}
if (FAILED.equalsIgnoreCase(requestState)) {
+ populateSubRequestId(outcome, response);
return CompletableFuture
.completedFuture(setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response));
}
@@ -212,8 +214,7 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
// still incomplete
// need a request ID with which to query
- if (response == null || response.getRequestReferences() == null
- || response.getRequestReferences().getRequestId() == null) {
+ if (!populateSubRequestId(outcome, response)) {
throw new IllegalArgumentException("missing request ID in response");
}
@@ -230,6 +231,16 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
return sleep(getWaitMsGet(), TimeUnit.MILLISECONDS).thenComposeAsync(doGet);
}
+ private boolean populateSubRequestId(OperationOutcome outcome, SoResponse response) {
+ if (response == null || response.getRequestReferences() == null
+ || response.getRequestReferences().getRequestId() == null) {
+ return false;
+ }
+
+ outcome.setSubRequestId(response.getRequestReferences().getRequestId());
+ return true;
+ }
+
/**
* Invoked when a request completes successfully.
*/
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
index 129c19381..992065638 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
@@ -166,17 +166,21 @@ public class SoOperationTest extends BasicSoOperation {
@Test
public void testPostProcess() throws Exception {
// completed
+ outcome.setSubRequestId(null);
CompletableFuture<OperationOutcome> future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
assertTrue(future2.isDone());
assertSame(outcome, future2.get());
assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertNotNull(outcome.getSubRequestId());
// failed
+ outcome.setSubRequestId(null);
response.getRequest().getRequestStatus().setRequestState(SoOperation.FAILED);
future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
assertTrue(future2.isDone());
assertSame(outcome, future2.get());
assertEquals(PolicyResult.FAILURE, outcome.getResult());
+ assertNotNull(outcome.getSubRequestId());
// no request id in the response
response.getRequestReferences().setRequestId(null);
diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
index dd6852d29..d6940d299 100644
--- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
+++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
@@ -54,6 +54,7 @@ import org.onap.policy.controlloop.policy.PolicyResult;
*/
public class BasicOperation {
protected static final UUID REQ_ID = UUID.randomUUID();
+ protected static final String SUB_REQ_ID = "my-sub-request-id";
protected static final String DEFAULT_ACTOR = "default-actor";
protected static final String DEFAULT_OPERATION = "default-operation";
protected static final String TARGET_ENTITY = "my-target";
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