Remove targetEntity from makeOutcome 53/115553/1
authorJim Hahn <jrh3@att.com>
Mon, 30 Nov 2020 16:02:31 +0000 (11:02 -0500)
committerJim Hahn <jrh3@att.com>
Mon, 30 Nov 2020 16:04:55 +0000 (11:04 -0500)
The Actor Params class had two flavors of makeOutcome, the second of
which took a "targetEntity" parameter.  As the Params no longer deal
directly with the targetEntity, the second flavor was removed.

Issue-ID: POLICY-2804
Change-Id: Ic736dd1c809ce54f6bb7cd37d03bc84cf4a1410c
Signed-off-by: Jim Hahn <jrh3@att.com>
models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java

index b5ba5d2..3cec9b6 100644 (file)
@@ -167,10 +167,10 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation {
 
     @Test
     public void testSetOutcome() {
-        outcome = oper.setOutcome(params.makeOutcome(null), OperationResult.SUCCESS, null, null);
+        outcome = oper.setOutcome(params.makeOutcome(), OperationResult.SUCCESS, null, null);
         assertNull(outcome.getResponse());
 
-        outcome = oper.setOutcome(params.makeOutcome(null), OperationResult.SUCCESS, null, "{}");
+        outcome = oper.setOutcome(params.makeOutcome(), OperationResult.SUCCESS, null, "{}");
         assertTrue(outcome.getResponse() instanceof AaiCqResponse);
     }
 
index f83f782..9291a3a 100644 (file)
@@ -219,7 +219,7 @@ public class GrpcOperationTest {
     public void testStartOperationAsyncError() throws Exception {
         operation = new GrpcOperation(params, config);
         assertThatIllegalArgumentException()
-                        .isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome(null)));
+                        .isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
     }
 
     private void verifyOperation(TargetType targetType, Runnable loader) {
@@ -240,7 +240,7 @@ public class GrpcOperationTest {
         operation.generateSubRequestId(1);
 
         loader.run();
-        CompletableFuture<OperationOutcome> future3 = operation.startOperationAsync(1, params.makeOutcome(null));
+        CompletableFuture<OperationOutcome> future3 = operation.startOperationAsync(1, params.makeOutcome());
         assertNotNull(future3);
     }
 
index c3d3f66..6874c5e 100644 (file)
@@ -899,7 +899,9 @@ public abstract class OperationPartial implements Operation {
      * @return a new operation outcome
      */
     protected OperationOutcome makeOutcome() {
-        return params.makeOutcome(getProperty(OperationProperties.AAI_TARGET_ENTITY));
+        OperationOutcome outcome = params.makeOutcome();
+        outcome.setTarget(getProperty(OperationProperties.AAI_TARGET_ENTITY));
+        return outcome;
     }
 
     /**
index 2769697..f287770 100644 (file)
@@ -52,6 +52,9 @@ import org.slf4j.LoggerFactory;
 public class ControlLoopOperationParams {
     private static final Logger logger = LoggerFactory.getLogger(ControlLoopOperationParams.class);
 
+    /*
+     * Optional keys within the "targetEntityIds" map.
+     */
     public static final String PARAMS_ENTITY_RESOURCEID = "resourceID";
     public static final String PARAMS_ENTITY_MODEL_INVARIANT_ID = "modelInvariantId";
     public static final String PARAMS_ENTITY_MODEL_VERSION_ID = "modelVersionId";
@@ -185,21 +188,9 @@ public class ControlLoopOperationParams {
      * @return a new operation outcome
      */
     public OperationOutcome makeOutcome() {
-        return makeOutcome(null);
-    }
-
-    /**
-     * Makes an operation outcome, populating it from the parameters.
-     *
-     * @param targetEntity the target entity
-     *
-     * @return a new operation outcome
-     */
-    public OperationOutcome makeOutcome(String targetEntity) {
         OperationOutcome outcome = new OperationOutcome();
         outcome.setActor(getActor());
         outcome.setOperation(getOperation());
-        outcome.setTarget(targetEntity);
 
         return outcome;
     }
index 14b1daf..08d4adf 100644 (file)
@@ -110,7 +110,7 @@ public class BidirectionalTopicOperationTest {
         executor = new PseudoExecutor();
 
         params = ControlLoopOperationParams.builder().actor(ACTOR).operation(OPERATION).executor(executor).build();
-        outcome = params.makeOutcome(null);
+        outcome = params.makeOutcome();
 
         response = new MyResponse();
         response.setRequestId(REQ_ID);
index 587313a..82aa091 100644 (file)
@@ -182,7 +182,7 @@ public class HttpOperationTest {
 
         params = ControlLoopOperationParams.builder().actor(ACTOR).operation(OPERATION).requestId(REQ_ID).build();
 
-        outcome = params.makeOutcome(null);
+        outcome = params.makeOutcome();
 
         callback = new AtomicReference<>();
         future = new CompletableFuture<>();
index 845758a..45ef293 100644 (file)
@@ -100,7 +100,7 @@ public class HttpPollingOperationTest {
         when(rawResponse.readEntity(String.class)).thenReturn(response);
 
         params = ControlLoopOperationParams.builder().actor(MY_ACTOR).operation(MY_OPERATION).build();
-        outcome = params.makeOutcome(null);
+        outcome = params.makeOutcome();
 
         oper = new MyOper(params, config);
     }
index 72a7338..f6dbcd8 100644 (file)
@@ -283,7 +283,7 @@ public class OperationPartialTest {
     public void testIsActorFailed() {
         assertFalse(oper.isActorFailed(null));
 
-        OperationOutcome outcome = params.makeOutcome(null);
+        OperationOutcome outcome = params.makeOutcome();
 
         // incorrect outcome
         outcome.setResult(OperationResult.SUCCESS);
@@ -343,7 +343,7 @@ public class OperationPartialTest {
             @Override
             protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
 
-                OperationOutcome outcome2 = params.makeOutcome(null);
+                OperationOutcome outcome2 = params.makeOutcome();
                 outcome2.setResult(OperationResult.SUCCESS);
 
                 /*
@@ -480,7 +480,7 @@ public class OperationPartialTest {
     public void testIsSameOperation() {
         assertFalse(oper.isSameOperation(null));
 
-        OperationOutcome outcome = params.makeOutcome(null);
+        OperationOutcome outcome = params.makeOutcome();
 
         // wrong actor - should be false
         outcome.setActor(null);
@@ -523,7 +523,7 @@ public class OperationPartialTest {
         // first task completes, others do not
         List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
 
-        final OperationOutcome outcome = params.makeOutcome(null);
+        final OperationOutcome outcome = params.makeOutcome();
 
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
         tasks.add(() -> new CompletableFuture<>());
@@ -588,7 +588,7 @@ public class OperationPartialTest {
 
     @Test
     public void testAllOfArray() throws Exception {
-        final OperationOutcome outcome = params.makeOutcome(null);
+        final OperationOutcome outcome = params.makeOutcome();
 
         CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
         CompletableFuture<OperationOutcome> future2 = new CompletableFuture<>();
@@ -619,7 +619,7 @@ public class OperationPartialTest {
 
     @Test
     public void testAllOfList() throws Exception {
-        final OperationOutcome outcome = params.makeOutcome(null);
+        final OperationOutcome outcome = params.makeOutcome();
 
         CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
         CompletableFuture<OperationOutcome> future2 = new CompletableFuture<>();
@@ -708,9 +708,9 @@ public class OperationPartialTest {
 
         // null outcome - takes precedence over a success
         List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
-        tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome(null)));
+        tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
         tasks.add(() -> CompletableFuture.completedFuture(null));
-        tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome(null)));
+        tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
         CompletableFuture<OperationOutcome> result = oper.allOf(tasks);
 
         assertTrue(executor.runAll(MAX_REQUESTS));
@@ -721,9 +721,9 @@ public class OperationPartialTest {
         IllegalStateException except = new IllegalStateException(EXPECTED_EXCEPTION);
 
         tasks.clear();
-        tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome(null)));
+        tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
         tasks.add(() -> CompletableFuture.failedFuture(except));
-        tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome(null)));
+        tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
         result = oper.allOf(tasks);
 
         assertTrue(executor.runAll(MAX_REQUESTS));
@@ -736,7 +736,7 @@ public class OperationPartialTest {
      */
     @Test
     public void testSequence() throws Exception {
-        final OperationOutcome outcome = params.makeOutcome(null);
+        final OperationOutcome outcome = params.makeOutcome();
 
         List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
@@ -758,7 +758,7 @@ public class OperationPartialTest {
         assertSame(outcome, result.get());
 
         // second task fails, third should not run
-        OperationOutcome failure = params.makeOutcome(null);
+        OperationOutcome failure = params.makeOutcome();
         failure.setResult(OperationResult.FAILURE);
         tasks.clear();
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
@@ -797,7 +797,7 @@ public class OperationPartialTest {
         OperationOutcome expectedOutcome = null;
 
         for (int count = 0; count < results.length; ++count) {
-            OperationOutcome outcome = params.makeOutcome(null);
+            OperationOutcome outcome = params.makeOutcome();
             outcome.setResult(results[count]);
             tasks.add(() -> CompletableFuture.completedFuture(outcome));
 
@@ -817,7 +817,7 @@ public class OperationPartialTest {
     public void testDetmPriority() throws CoderException {
         assertEquals(1, oper.detmPriority(null));
 
-        OperationOutcome outcome = params.makeOutcome(null);
+        OperationOutcome outcome = params.makeOutcome();
 
         Map<OperationResult, Integer> map = Map.of(OperationResult.SUCCESS, 0, OperationResult.FAILURE_GUARD, 2,
                 OperationResult.FAILURE_RETRIES, 3, OperationResult.FAILURE, 4, OperationResult.FAILURE_TIMEOUT, 5,
@@ -1049,7 +1049,7 @@ public class OperationPartialTest {
     }
 
     private OperationOutcome makeSuccess() {
-        OperationOutcome outcome = params.makeOutcome(null);
+        OperationOutcome outcome = params.makeOutcome();
         outcome.setResult(OperationResult.SUCCESS);
 
         return outcome;
index fc36c12..3390451 100644 (file)
@@ -61,7 +61,6 @@ public class ControlLoopOperationParamsTest {
     private static final String EXPECTED_EXCEPTION = "expected exception";
     private static final String ACTOR = "my-actor";
     private static final String OPERATION = "my-operation";
-    private static final String TARGET_ENTITY = "my-target";
     private static final Integer RETRY = 3;
     private static final Integer TIMEOUT = 100;
     private static final UUID REQ_ID = UUID.randomUUID();
@@ -115,7 +114,7 @@ public class ControlLoopOperationParamsTest {
                         .retry(RETRY).timeoutSec(TIMEOUT)
                         .startCallback(starter).build();
 
-        outcome = params.makeOutcome(TARGET_ENTITY);
+        outcome = params.makeOutcome();
     }
 
     @Test
@@ -139,25 +138,13 @@ public class ControlLoopOperationParamsTest {
 
     @Test
     public void testMakeOutcome() {
-        outcome = params.makeOutcome();
-        assertNull(outcome.getTarget());
-        checkRemainingFields("with actor");
-    }
-
-    @Test
-    public void testMakeOutcomeString() {
-        assertEquals(TARGET_ENTITY, outcome.getTarget());
-        checkRemainingFields("with actor");
-    }
-
-    protected void checkRemainingFields(String testName) {
         assertEquals(ACTOR, outcome.getActor());
         assertEquals(OPERATION, outcome.getOperation());
-        assertNull(testName, outcome.getStart());
-        assertNull(testName, outcome.getEnd());
-        assertNull(testName, outcome.getSubRequestId());
-        assertNotNull(testName, outcome.getResult());
-        assertNull(testName, outcome.getMessage());
+        assertNull(outcome.getStart());
+        assertNull(outcome.getEnd());
+        assertNull(outcome.getSubRequestId());
+        assertNotNull(outcome.getResult());
+        assertNull(outcome.getMessage());
     }
 
     @Test