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.cds/src/test | |
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.cds/src/test')
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java index fe8d42814..cbc88a30e 100644 --- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java +++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java @@ -19,6 +19,7 @@ package org.onap.policy.controlloop.actor.cds; +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.assertNotNull; @@ -30,6 +31,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -62,6 +64,7 @@ import org.onap.policy.controlloop.actor.aai.AaiGetPnfOperation; import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants; import org.onap.policy.controlloop.actorserviceprovider.ActorService; 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.ControlLoopOperationParams; import org.onap.policy.controlloop.policy.PolicyResult; @@ -171,6 +174,43 @@ public class GrpcOperationTest { } @Test + public void testGetPropertyNames() { + ControlLoopEventContext context = mock(ControlLoopEventContext.class); + when(context.getEvent()).thenReturn(onset); + + ControlLoopOperationParams params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR) + .operation(GrpcOperation.NAME).context(context).actorService(new ActorService()) + .targetEntity(TARGET_ENTITY).target(target).build(); + GrpcConfig config = new GrpcConfig(executor, cdsProps); + + /* + * check VNF case + */ + operation = new GrpcOperation(params, config); + + // @formatter:off + assertThat(operation.getPropertyNames()).isEqualTo( + List.of( + OperationProperties.AAI_MODEL_INVARIANT_GENERIC_VNF, + OperationProperties.AAI_RESOURCE_SERVICE_INSTANCE, + OperationProperties.EVENT_ADDITIONAL_PARAMS)); + // @formatter:on + + /* + * check PNF case + */ + target.setType(TargetType.PNF); + operation = new GrpcOperation(params, config); + + // @formatter:off + assertThat(operation.getPropertyNames()).isEqualTo( + List.of( + OperationProperties.AAI_PNF, + OperationProperties.EVENT_ADDITIONAL_PARAMS)); + // @formatter:on + } + + @Test public void testStartPreprocessorAsync() throws InterruptedException, ExecutionException, TimeoutException { CompletableFuture<OperationOutcome> future2 = new CompletableFuture<>(); |