summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.appclcm
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-04-01 11:03:31 -0400
committerJim Hahn <jrh3@att.com>2020-04-01 12:04:48 -0400
commit88fedd4d3edbb581eabe20074a65c32b635fc3b2 (patch)
treeb932b653aa2d89557f08570d51fc5204459dae93 /models-interactions/model-actors/actor.appclcm
parent3a99e95994963c8fd04d7c038cf6b0263b2bbdeb (diff)
Set sub request ID before start callback
Modified new actor code to generate the sub request ID before invoking the start callback. Issue-ID: POLICY-2461 Change-Id: I4adabd6efda2c30c0e2da31f95f01dd5fe546c0a Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.appclcm')
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java10
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java23
2 files changed, 15 insertions, 18 deletions
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 87ff357e9..e34d3c586 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
@@ -22,10 +22,8 @@ package org.onap.policy.controlloop.actor.appclcm;
import java.util.List;
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;
@@ -81,9 +79,9 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr
}
@Override
- protected Pair<String, AppcLcmDmaapWrapper> makeRequest(int attempt) {
+ protected AppcLcmDmaapWrapper makeRequest(int attempt) {
VirtualControlLoopEvent onset = params.getContext().getEvent();
- String subRequestId = UUID.randomUUID().toString();
+ String subRequestId = getSubRequestId();
AppcLcmCommonHeader header = new AppcLcmCommonHeader();
header.setOriginatorId(onset.getRequestId().toString());
@@ -126,7 +124,7 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr
body.setInput(inputRequest);
dmaapRequest.setBody(body);
- return Pair.of(subRequestId, dmaapRequest);
+ return dmaapRequest;
}
/**
@@ -150,7 +148,7 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr
*/
@Override
protected List<String> getExpectedKeyValues(int attempt, AppcLcmDmaapWrapper request) {
- return List.of(request.getBody().getInput().getCommonHeader().getSubRequestId());
+ return List.of(getSubRequestId());
}
@Override
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 9744d829b..b2a44af53 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
@@ -23,7 +23,6 @@ package org.onap.policy.controlloop.actor.appclcm;
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.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -36,7 +35,6 @@ 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.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -170,11 +168,11 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation {
@Test
public void testMakeRequest() {
- Pair<String, AppcLcmDmaapWrapper> result = oper.makeRequest(2);
- String subreq = result.getLeft();
+ oper.generateSubRequestId(2);
+ String subreq = oper.getSubRequestId();
assertNotNull(subreq);
- AppcLcmDmaapWrapper request = result.getRight();
+ AppcLcmDmaapWrapper request = oper.makeRequest(2);
assertEquals("DefaultOperation", request.getBody().getInput().getAction());
AppcLcmCommonHeader header = request.getBody().getInput().getCommonHeader();
@@ -185,11 +183,8 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation {
assertEquals("{vnf-id=my-target}", request.getBody().getInput().getActionIdentifiers().toString());
- // a subsequent request should have a different sub-request id
- result = oper.makeRequest(2);
- assertNotEquals(subreq, result.getLeft());
- assertNotNull(result.getLeft());
- assertEquals(result.getLeft(), result.getRight().getBody().getInput().getCommonHeader().getSubRequestId());
+ request = oper.makeRequest(2);
+ assertEquals(subreq, request.getBody().getInput().getCommonHeader().getSubRequestId());
}
@Test
@@ -198,7 +193,8 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation {
params = params.toBuilder().operation(AppcLcmConstants.OPERATION_CONFIG_MODIFY).build();
oper = new AppcLcmOperation(params, config);
- AppcLcmDmaapWrapper req = oper.makeRequest(2).getRight();
+ oper.generateSubRequestId(2);
+ AppcLcmDmaapWrapper req = oper.makeRequest(2);
assertEquals("{\"key-A\":\"value-A\"}", req.getBody().getInput().getPayload());
// coder exception
@@ -214,13 +210,16 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation {
}
};
+ oper.generateSubRequestId(2);
+
assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest(2))
.withMessage("Cannot convert payload");
}
@Test
public void testGetExpectedKeyValues() {
- AppcLcmDmaapWrapper request = oper.makeRequest(2).getRight();
+ oper.generateSubRequestId(2);
+ AppcLcmDmaapWrapper request = oper.makeRequest(2);
assertEquals(Arrays.asList(request.getBody().getInput().getCommonHeader().getSubRequestId()),
oper.getExpectedKeyValues(50, request));
}