aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.cds/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-07-29 13:50:40 -0400
committerJim Hahn <jrh3@att.com>2020-07-31 14:08:17 -0400
commitacded8235dcbb0b06abaa98297fecef78b4eec41 (patch)
tree8b400d09875cd2c6f7844fbbe0c4d9e1e1a16230 /models-interactions/model-actors/actor.cds/src
parent1da24b28d9df7c8ad5154d7788dab0ab9da589f8 (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')
-rw-r--r--models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java26
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java40
2 files changed, 63 insertions, 3 deletions
diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java
index 0a882ce93..241781254 100644
--- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java
+++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java
@@ -25,8 +25,10 @@ import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Struct;
import com.google.protobuf.Struct.Builder;
import com.google.protobuf.util.JsonFormat;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
@@ -48,6 +50,7 @@ import org.onap.policy.controlloop.actor.aai.AaiGetPnfOperation;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actor.cds.request.CdsActionRequest;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
@@ -84,6 +87,19 @@ public class GrpcOperation extends OperationPartial {
*/
private final Supplier<Map<String, String>> aaiConverter;
+
+ // @formatter:off
+ private static final List<String> PNF_PROPERTY_NAMES = List.of(
+ OperationProperties.AAI_PNF,
+ OperationProperties.EVENT_ADDITIONAL_PARAMS);
+
+
+ private static final List<String> VNF_PROPERTY_NAMES = List.of(
+ OperationProperties.AAI_MODEL_INVARIANT_GENERIC_VNF,
+ OperationProperties.AAI_RESOURCE_SERVICE_INSTANCE,
+ OperationProperties.EVENT_ADDITIONAL_PARAMS);
+ // @formatter:on
+
/**
* Constructs the object.
*
@@ -91,7 +107,7 @@ public class GrpcOperation extends OperationPartial {
* @param config configuration for this operation
*/
public GrpcOperation(ControlLoopOperationParams params, GrpcConfig config) {
- super(params, config);
+ super(params, config, Collections.emptyList());
this.config = config;
if (TargetType.PNF.equals(params.getTarget().getType())) {
@@ -103,6 +119,11 @@ public class GrpcOperation extends OperationPartial {
}
}
+ @Override
+ public List<String> getPropertyNames() {
+ return (TargetType.PNF.equals(params.getTarget().getType()) ? PNF_PROPERTY_NAMES : VNF_PROPERTY_NAMES);
+ }
+
/**
* If no timeout is specified, then it returns the operator's configured timeout.
*/
@@ -287,8 +308,7 @@ public class GrpcOperation extends OperationPartial {
// Build CDS gRPC request common-header
CommonHeader commonHeader = CommonHeader.newBuilder().setOriginatorId(CdsActorConstants.ORIGINATOR_ID)
- .setRequestId(params.getContext().getEvent().getRequestId().toString())
- .setSubRequestId(getSubRequestId()).build();
+ .setRequestId(params.getRequestId().toString()).setSubRequestId(getSubRequestId()).build();
// Build CDS gRPC request action-identifier
ActionIdentifiers actionIdentifiers =
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<>();