summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.vfc
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.vfc
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.vfc')
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java16
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java15
2 files changed, 28 insertions, 3 deletions
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
index d5ee44a5d..8bd4630d6 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
@@ -20,10 +20,12 @@
package org.onap.policy.controlloop.actor.vfc;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
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.impl.HttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
@@ -44,6 +46,14 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
public static final String REQ_PARAM_NM = "requestParameters";
public static final String CONFIG_PARAM_NM = "configurationParameters";
+ // @formatter:off
+ private static final List<String> PROPERTY_NAMES = List.of(
+ OperationProperties.ENRICHMENT_SERVICE_INSTANCE_ID,
+ OperationProperties.ENRICHMENT_VSERVER_ID,
+ OperationProperties.ENRICHMENT_VSERVER_NAME,
+ OperationProperties.ENRICHMENT_GENERIC_VNF_ID);
+ // @formatter:on
+
/**
* Job ID extracted from the first response.
*/
@@ -57,7 +67,7 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
* @param config configuration for this operation
*/
public VfcOperation(ControlLoopOperationParams params, HttpConfig config) {
- super(params, config, VfcResponse.class);
+ super(params, config, VfcResponse.class, PROPERTY_NAMES);
setUsePolling();
}
@@ -180,14 +190,14 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
additionalParams.setActionInfo(vmActionInfo);
VfcHealRequest healRequest = new VfcHealRequest();
- healRequest.setVnfInstanceId(params.getContext().getEvent().getAai().get(GENERIC_VNF_ID));
+ healRequest.setVnfInstanceId(params.getContext().getEnrichment().get(GENERIC_VNF_ID));
healRequest.setCause(getName());
healRequest.setAdditionalParams(additionalParams);
VfcRequest request = new VfcRequest();
request.setHealRequest(healRequest);
request.setNsInstanceId(serviceInstance);
- request.setRequestId(context.getEvent().getRequestId());
+ request.setRequestId(params.getRequestId());
return request;
}
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
index ed072f761..46666456a 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
@@ -20,10 +20,12 @@
package org.onap.policy.controlloop.actor.vfc;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.AfterClass;
@@ -32,6 +34,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.controlloop.policy.PolicyResult;
@@ -89,6 +92,18 @@ public class RestartTest extends BasicVfcOperation {
}
@Test
+ public void testGetPropertyNames() {
+ // @formatter:off
+ assertThat(restartOper.getPropertyNames()).isEqualTo(
+ List.of(
+ OperationProperties.ENRICHMENT_SERVICE_INSTANCE_ID,
+ OperationProperties.ENRICHMENT_VSERVER_ID,
+ OperationProperties.ENRICHMENT_VSERVER_NAME,
+ OperationProperties.ENRICHMENT_GENERIC_VNF_ID));
+ // @formatter:on
+ }
+
+ @Test
public void testMakeRequest() {
Pair<String, VfcRequest> resultPair = restartOper.makeRequest();
assertNotNull(resultPair.getLeft());