Merge "Delete preprocessed flag from actors"
diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
index 091b26b..0649f18 100644
--- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
+++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
@@ -338,7 +338,6 @@
                         .actor(actor.getActor())
                         .operation(actor.getOperation())
                         .requestId(event.getRequestId())
-                        .preprocessed(true)
                         .executor(getExecutor())
                         .retry(policy.getRetries())
                         .timeoutSec(policy.getTimeout())
diff --git a/controlloop/common/controller-usecases/src/main/resources/usecases.drl b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
index 12c9849..578bd9c 100644
--- a/controlloop/common/controller-usecases/src/main/resources/usecases.drl
+++ b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
@@ -395,7 +395,7 @@
 
         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());
 
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java
index 9869c21..d05aa60 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java
@@ -48,7 +48,6 @@
 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
@@ -80,7 +79,7 @@
         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);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java
index 65c27b4..7b1bae7 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java
@@ -84,7 +84,7 @@
         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);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java
index ab95072..2ab647a 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java
@@ -168,7 +168,6 @@
         params = ControlLoopOperationParams.builder()
                     .actor(MASTER_ACTOR)
                     .operation(MASTER_OPERATION)
-                    .targetEntity(MY_TARGET)
                     .requestId(REQ_ID)
                     .targetType(target)
                     .build();
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java
index 2afd395..c68f187 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java
@@ -107,7 +107,7 @@
         assertTrue(step.start(100));
 
         // complete the operation's future
-        OperationOutcome outcome = params.makeOutcome();
+        OperationOutcome outcome = step.makeOutcome();
         outcome.setTarget(MY_TARGET);
 
         future.complete(outcome);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
index 7695d5b..8119019 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
@@ -132,7 +132,7 @@
         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);
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 1cbdb53..d406e6e 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.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 @@
 
         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 @@
         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 @@
         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 aec4693..cd22881 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.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 @@
         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 @@
                         .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 @@
         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 @@
     }
 
     @Test
+    public void testMakeOutcome() {
+        step.init();
+        assertEquals(MY_TARGET, step.makeOutcome().getTarget());
+    }
+
+    @Test
     public void testToString() {
         assertNotNull(step.toString());
     }