diff options
author | Jim Hahn <jrh3@att.com> | 2020-02-24 10:38:07 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-02-24 18:34:44 -0500 |
commit | d71b4e3cc240e350ff146554b3f3d8399d03a669 (patch) | |
tree | 0aae368534ddc2f9e10782fa5b29c1ffe7e6a498 /models-interactions/model-actors/actorServiceProvider/src/test | |
parent | 4782f3267518d66d01b3d3cbec9d98ba7e1e92bd (diff) |
Add "finalOutcome" flag to OperationOutcome
The Actor clients receive notifications of operation failures, but
no indication if it's the final failure, thus they do not know if
they should progress on to the "failure" policies.
Issue-ID: POLICY-2385
Signed-off-by: Jim Hahn <jrh3@att.com>
Change-Id: If053ed459e1d790e58eca950a8feeabaf4d67a41
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider/src/test')
-rw-r--r-- | models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java | 38 |
1 files changed, 33 insertions, 5 deletions
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 2893cb627..229e5a32a 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 @@ -34,7 +34,9 @@ import static org.mockito.Mockito.when; import ch.qos.logback.classic.Logger; import java.time.Instant; +import java.util.ArrayDeque; import java.util.Arrays; +import java.util.Deque; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -128,6 +130,9 @@ public class OperationPartialTest { private OperationOutcome opstart; private OperationOutcome opend; + private Deque<OperationOutcome> starts; + private Deque<OperationOutcome> ends; + private OperatorConfig config; /** @@ -182,6 +187,9 @@ public class OperationPartialTest { opstart = null; opend = null; + + starts = new ArrayDeque<>(10); + ends = new ArrayDeque<>(10); } @Test @@ -519,10 +527,10 @@ public class OperationPartialTest { // arrange to return null from doOperation() oper = new MyOper() { @Override - protected OperationOutcome doOperation(int attempt, OperationOutcome operation) { + protected OperationOutcome doOperation(int attempt, OperationOutcome outcome) { // update counters - super.doOperation(attempt, operation); + super.doOperation(attempt, outcome); return null; } }; @@ -587,7 +595,7 @@ public class OperationPartialTest { * Tests handleFailure() when the outcome is a success. */ @Test - public void testHandlePreprocessorFailureTrue() { + public void testHandlePreprocessorFailureSuccess() { oper.setPreProc(CompletableFuture.completedFuture(makeSuccess())); verifyRun("testHandlePreprocessorFailureTrue", 1, 1, PolicyResult.SUCCESS); } @@ -596,7 +604,7 @@ public class OperationPartialTest { * Tests handleFailure() when the outcome is <i>not</i> a success. */ @Test - public void testHandlePreprocessorFailureFalse() throws Exception { + public void testHandlePreprocessorFailureFailed() throws Exception { oper.setPreProc(CompletableFuture.completedFuture(makeFailure())); verifyRun("testHandlePreprocessorFailureFalse", 1, 0, PolicyResult.FAILURE_GUARD); } @@ -1130,11 +1138,13 @@ public class OperationPartialTest { ++numStart; tstart = oper.getStart(); opstart = oper; + starts.add(oper); } private void completer(OperationOutcome oper) { ++numEnd; opend = oper; + ends.add(oper); } /** @@ -1194,6 +1204,12 @@ public class OperationPartialTest { private void verifyRun(String testName, int expectedCallbacks, int expectedOperations, PolicyResult expectedResult, String expectedSubRequestId, Consumer<CompletableFuture<OperationOutcome>> manipulator) { + tstart = null; + opstart = null; + opend = null; + starts.clear(); + ends.clear(); + CompletableFuture<OperationOutcome> future = oper.start(); manipulator.accept(future); @@ -1213,7 +1229,19 @@ public class OperationPartialTest { try { assertTrue(future.isDone()); - assertSame(testName, opend, future.get()); + assertEquals(testName, opend, future.get()); + + // "start" is never final + for (OperationOutcome outcome : starts) { + assertFalse(testName, outcome.isFinalOutcome()); + } + + // only the last "complete" is final + assertTrue(testName, ends.removeLast().isFinalOutcome()); + + for (OperationOutcome outcome : ends) { + assertFalse(outcome.isFinalOutcome()); + } } catch (InterruptedException | ExecutionException e) { throw new IllegalStateException(e); |