diff options
author | Jim Hahn <jrh3@att.com> | 2020-07-29 13:50:40 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-07-31 14:08:17 -0400 |
commit | acded8235dcbb0b06abaa98297fecef78b4eec41 (patch) | |
tree | 8b400d09875cd2c6f7844fbbe0c4d9e1e1a16230 /models-interactions/model-actors/actor.appc/src | |
parent | 1da24b28d9df7c8ad5154d7788dab0ab9da589f8 (diff) |
Add property lists to Actors
Modified the Actor code to provide a list of properties needed by the
actor to perform a given operation.
Added a build() method to the parameter class so invokers can build an
operation and set its properties prior to starting it.
Added a "preprocessed" field to the parameter class so invokers can
indicate that the Actor need not perform any preprocessing steps. Will
modify the actors, in a subsequent review, to observe the flag.
Added "properties" to Operation so invokers can set the properties. Will
modify the actors, in a subsequent review, to use the property values
instead of the event context.
Tweaked a few Actors to get values using the "params" object instead of
reaching inside to the event object that it contains.
Addressed review comment(s):
- add prefix to other property names
Issue-ID: POLICY-2746
Change-Id: I65996aef5cec5afe25e8287c0b2f5f322c532ca5
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.appc/src')
4 files changed, 19 insertions, 4 deletions
diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java index 9af24185c..e07093ae6 100644 --- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java +++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java @@ -63,9 +63,11 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request, * * @param params operation parameters * @param config configuration for this operation + * @param propertyNames names of properties required by this operation */ - public AppcOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) { - super(params, config, Response.class); + public AppcOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config, + List<String> propertyNames) { + super(params, config, Response.class, propertyNames); } /** diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java index a318444aa..d1f27b505 100644 --- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java +++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java @@ -20,12 +20,14 @@ package org.onap.policy.controlloop.actor.appc; +import java.util.List; import java.util.concurrent.CompletableFuture; import org.onap.aai.domain.yang.GenericVnf; import org.onap.policy.aai.AaiConstants; import org.onap.policy.aai.AaiCqResponse; import org.onap.policy.appc.Request; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.slf4j.Logger; @@ -36,6 +38,8 @@ public class ModifyConfigOperation extends AppcOperation { public static final String NAME = "ModifyConfig"; + private static final List<String> PROPERTY_NAMES = List.of(OperationProperties.AAI_RESOURCE_VNF); + /** * Constructs the object. * @@ -43,7 +47,7 @@ public class ModifyConfigOperation extends AppcOperation { * @param config configuration for this operation */ public ModifyConfigOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) { - super(params, config); + super(params, config, PROPERTY_NAMES); } /** diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java index b2d012a9f..e544d46cb 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import java.util.Arrays; +import java.util.Collections; import java.util.Map; import java.util.TreeMap; import org.junit.After; @@ -234,7 +235,7 @@ public class AppcOperationTest extends BasicAppcOperation { private static class MyOper extends AppcOperation { public MyOper(ControlLoopOperationParams params, BidirectionalTopicConfig config) { - super(params, config); + super(params, config, Collections.emptyList()); } @Override diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java index 0e29dd208..d000038e3 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java @@ -20,6 +20,7 @@ package org.onap.policy.controlloop.actor.appc; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -32,6 +33,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.Arrays; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.After; @@ -45,6 +47,7 @@ import org.onap.policy.appc.Request; import org.onap.policy.appc.Response; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams; @@ -119,6 +122,11 @@ public class ModifyConfigOperationTest extends BasicAppcOperation { } @Test + public void testGetPropertyNames() { + assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_RESOURCE_VNF)); + } + + @Test public void testStartPreprocessorAsync() throws Exception { CompletableFuture<OperationOutcome> future2 = new CompletableFuture<>(); context = mock(ControlLoopEventContext.class); |