diff options
author | Jim Hahn <jrh3@att.com> | 2020-04-01 11:03:31 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-04-01 12:04:48 -0400 |
commit | 88fedd4d3edbb581eabe20074a65c32b635fc3b2 (patch) | |
tree | b932b653aa2d89557f08570d51fc5204459dae93 /models-interactions/model-actors/actorServiceProvider/src/test | |
parent | 3a99e95994963c8fd04d7c038cf6b0263b2bbdeb (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/actorServiceProvider/src/test')
2 files changed, 12 insertions, 20 deletions
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 48669f799..55782a34d 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,7 +40,6 @@ 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; @@ -67,7 +66,6 @@ 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; @@ -138,8 +136,6 @@ 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()); @@ -183,8 +179,6 @@ 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()); @@ -363,8 +357,8 @@ public class BidirectionalTopicOperationTest { } @Override - protected Pair<String, String> makeRequest(int attempt) { - return Pair.of(SUB_REQID, TEXT); + protected String makeRequest(int attempt) { + return TEXT; } @Override @@ -385,8 +379,8 @@ public class BidirectionalTopicOperationTest { } @Override - protected Pair<String, MyRequest> makeRequest(int attempt) { - return Pair.of(SUB_REQID, new MyRequest()); + protected MyRequest makeRequest(int attempt) { + return new MyRequest(); } @Override @@ -407,8 +401,8 @@ public class BidirectionalTopicOperationTest { } @Override - protected Pair<String, MyRequest> makeRequest(int attempt) { - return Pair.of(SUB_REQID, new MyRequest()); + protected MyRequest makeRequest(int attempt) { + return new MyRequest(); } @Override diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java index 7b8eed59e..75463b9d7 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java @@ -531,7 +531,7 @@ public class OperationPartialTest { } }; - verifyRun("testSetRetryFlag_testRetryOnFailure_NullOutcome", 1, 1, PolicyResult.FAILURE, null, noop()); + verifyRun("testSetRetryFlag_testRetryOnFailure_NullOutcome", 1, 1, PolicyResult.FAILURE, noop()); } @Test @@ -1179,10 +1179,7 @@ public class OperationPartialTest { private void verifyRun(String testName, int expectedCallbacks, int expectedOperations, PolicyResult expectedResult) { - String expectedSubRequestId = - (expectedResult == PolicyResult.FAILURE_EXCEPTION ? null : String.valueOf(expectedOperations)); - - verifyRun(testName, expectedCallbacks, expectedOperations, expectedResult, expectedSubRequestId, noop()); + verifyRun(testName, expectedCallbacks, expectedOperations, expectedResult, noop()); } /** @@ -1192,13 +1189,12 @@ public class OperationPartialTest { * @param expectedCallbacks number of callbacks expected * @param expectedOperations number of operation invocations expected * @param expectedResult expected outcome - * @param expectedSubRequestId expected sub request ID * @param manipulator function to modify the future returned by * {@link OperationPartial#start(ControlLoopOperationParams)} before the tasks * in the executor are run */ private void verifyRun(String testName, int expectedCallbacks, int expectedOperations, PolicyResult expectedResult, - String expectedSubRequestId, Consumer<CompletableFuture<OperationOutcome>> manipulator) { + Consumer<CompletableFuture<OperationOutcome>> manipulator) { tstart = null; opstart = null; @@ -1244,7 +1240,9 @@ public class OperationPartialTest { } if (expectedOperations > 0) { - assertEquals(testName, expectedSubRequestId, opend.getSubRequestId()); + assertNotNull(testName, oper.getSubRequestId()); + assertEquals(testName + " op start", oper.getSubRequestId(), opstart.getSubRequestId()); + assertEquals(testName + " op end", oper.getSubRequestId(), opend.getSubRequestId()); } } |