summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.cds/src
diff options
context:
space:
mode:
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<>();