aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.appc/src
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actor.appc/src')
-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
4 files changed, 33 insertions, 18 deletions
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));