.actor(actor.getActor())
.operation(actor.getOperation())
.requestId(event.getRequestId())
- .preprocessed(true)
.executor(getExecutor())
.retry(policy.getRetries())
.timeoutSec(policy.getTimeout())
if (guardDisabled && "GUARD".equals($step.getActorName())) {
// guard is disabled - just enqueue a "SUCCESS" (i.e., "Permit")
- OperationOutcome outcome = $step.getParams().makeOutcome();
+ OperationOutcome outcome = $step.getParams().makeOutcome(null);
outcome.setStart(Instant.now());
outcome.setEnd(outcome.getStart());
import org.onap.policy.controlloop.eventmanager.StepContext;
public class AaiCqStep2Test {
- private static final String MY_TARGET = "my-target";
private static final UUID REQ_ID = UUID.randomUUID();
@Mock
future = new CompletableFuture<>();
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder().actorService(actors)
- .targetEntity(MY_TARGET).requestId(REQ_ID));
+ .requestId(REQ_ID));
// configure policy operation
when(actors.getActor(AaiActor.NAME)).thenReturn(policyActor);
future = new CompletableFuture<>();
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder().actorService(actors)
- .targetEntity("my-target").requestId(REQ_ID));
+ .requestId(REQ_ID));
// configure policy operation
when(actors.getActor(AaiActor.NAME)).thenReturn(policyActor);
params = ControlLoopOperationParams.builder()
.actor(MASTER_ACTOR)
.operation(MASTER_OPERATION)
- .targetEntity(MY_TARGET)
.requestId(REQ_ID)
.targetType(target)
.build();
assertTrue(step.start(100));
// complete the operation's future
- OperationOutcome outcome = params.makeOutcome();
+ OperationOutcome outcome = step.makeOutcome();
outcome.setTarget(MY_TARGET);
future.complete(outcome);
params = ControlLoopOperationParams.builder().actor(POLICY_ACTOR).actorService(actors)
.completeCallback(completions::add).executor(ForkJoinPool.commonPool())
.operation(POLICY_OPERATION).payload(new TreeMap<>(payload)).startCallback(starts::add)
- .targetType(TargetType.VM).targetEntityIds(entityIds).targetEntity(MY_TARGET)
+ .targetType(TargetType.VM).targetEntityIds(entityIds)
.requestId(REQ_ID).build();
step = new Step2(stepContext, params, event);
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;
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);
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());
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() + ")";
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;
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");
.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<>();
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);
assertSame(policyOperation, step.buildOperation());
}
+ @Test
+ public void testMakeOutcome() {
+ step.init();
+ assertEquals(MY_TARGET, step.makeOutcome().getTarget());
+ }
+
@Test
public void testToString() {
assertNotNull(step.toString());