diff options
author | Jim Hahn <jrh3@att.com> | 2020-03-06 18:22:28 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-03-06 19:04:13 -0500 |
commit | 2440b81428fa4bfa28a51f87c58e12c78ced744b (patch) | |
tree | 61ca5668446ed47301ee3b2cca520cc7a83d46aa /models-interactions/model-actors/actor.appc/src/test | |
parent | 3c1fb89886d7ebf2efe1183e92b4ed8191f506b4 (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/actor.appc/src/test')
2 files changed, 26 insertions, 14 deletions
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)); |