diff options
author | 2020-11-20 13:28:27 +0000 | |
---|---|---|
committer | 2020-11-20 13:28:27 +0000 | |
commit | 022405974f42fc183d8de46a603a1049dfb2ee15 (patch) | |
tree | e34c31c1233a1dfcf4771ca2de1b233f9b84d0f9 /controlloop/common/eventmanager/src | |
parent | 03c9f7be0e81f39f71c5ba87a77448a726db06db (diff) | |
parent | 3d776b9d24b73b366b2f1e70b6c536e4d2705202 (diff) |
Merge "Delete preprocessed flag from actors"
Diffstat (limited to 'controlloop/common/eventmanager/src')
2 files changed, 22 insertions, 4 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java index 1cbdb53b2..d406e6efe 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java @@ -30,6 +30,7 @@ import lombok.Getter; import lombok.NonNull; import org.onap.policy.controlloop.actorserviceprovider.Operation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineUtil; import org.slf4j.Logger; @@ -190,7 +191,7 @@ public class Step { logger.warn("{}.{}: exception starting operation for {}", params.getActor(), params.getOperation(), params.getRequestId(), thrown); - OperationOutcome outcome = new PipelineUtil(params).setOutcome(params.makeOutcome(), thrown); + OperationOutcome outcome = new PipelineUtil(params).setOutcome(makeOutcome(), thrown); outcome.setStart(startTime.get()); outcome.setEnd(Instant.now()); outcome.setFinalOutcome(true); @@ -210,7 +211,7 @@ public class Step { logger.warn("{}.{}: control loop timeout for {}", params.getActor(), params.getOperation(), params.getRequestId(), thrown); - OperationOutcome outcome = new PipelineUtil(params).setOutcome(params.makeOutcome(), thrown); + OperationOutcome outcome = new PipelineUtil(params).setOutcome(makeOutcome(), thrown); outcome.setActor(ActorConstants.CL_TIMEOUT_ACTOR); outcome.setOperation(null); outcome.setStart(startTime.get()); @@ -262,6 +263,16 @@ public class Step { return params.build(); } + /** + * Makes an operation outcome, populating the target entity from the operation's + * properties. + * + * @return a new operation outcome + */ + public OperationOutcome makeOutcome() { + return params.makeOutcome(operation.getProperty(OperationProperties.AAI_TARGET_ENTITY)); + } + @Override public String toString() { return "Step(actor=" + getActorName() + ", operation=" + getOperationName() + ")"; diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java index aec4693f8..cd22881b8 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java @@ -52,6 +52,7 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.actorserviceprovider.Operation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.Operator; import org.onap.policy.controlloop.actorserviceprovider.TargetType; @@ -103,6 +104,7 @@ public class StepTest { when(policyActor.getOperator(POLICY_OPERATION)).thenReturn(policyOperator); when(policyOperator.buildOperation(any())).thenReturn(policyOperation); when(policyOperation.start()).thenReturn(future); + when(policyOperation.getProperty(OperationProperties.AAI_TARGET_ENTITY)).thenReturn(MY_TARGET); entityIds = Map.of("entity-name-A", "entity-value-A"); @@ -123,7 +125,7 @@ public class StepTest { .completeCallback(completions::add).executor(ForkJoinPool.commonPool()) .operation(POLICY_OPERATION).payload(new TreeMap<>(payload)).startCallback(starts::add) .targetType(TargetType.valueOf(target.getTargetType())).targetEntityIds(target.getEntityIds()) - .requestId(REQ_ID).targetEntity(MY_TARGET).build(); + .requestId(REQ_ID).build(); startTime = new AtomicReference<>(); @@ -160,7 +162,6 @@ public class StepTest { assertNull(params2.getTimeoutSec()); assertEquals(target.getTargetType().toString(), params2.getTargetType().toString()); assertSame(entityIds, params2.getTargetEntityIds()); - assertEquals(MY_TARGET, params2.getTargetEntity()); assertTrue(params2.getPayload().isEmpty()); when(actors.getActor(params2.getActor())).thenReturn(policyActor); @@ -364,6 +365,12 @@ public class StepTest { } @Test + public void testMakeOutcome() { + step.init(); + assertEquals(MY_TARGET, step.makeOutcome().getTarget()); + } + + @Test public void testToString() { assertNotNull(step.toString()); } |