summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.sdnr/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.sdnr/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.sdnr/src')
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java13
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java8
2 files changed, 15 insertions, 6 deletions
diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
index 6c8f45d94..f88f3c300 100644
--- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
+++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
@@ -22,8 +22,8 @@ package org.onap.policy.controlloop.actor.sdnr;
import java.util.List;
import java.util.concurrent.CompletableFuture;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
@@ -46,6 +46,8 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
*/
public static final String NAME = "any";
+ private static final List<String> PROPERTY_NAMES = List.of(OperationProperties.AAI_VSERVER_LINK);
+
/**
* Keys used to match the response with the request listener. The sub request ID is a
* UUID, so it can be used to uniquely identify the response.
@@ -57,7 +59,7 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
List.of(new SelectorKey("body", "output", "CommonHeader", "SubRequestID"));
public SdnrOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
- super(params, config, PciMessage.class);
+ super(params, config, PciMessage.class, PROPERTY_NAMES);
}
/**
@@ -135,14 +137,13 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
@Override
protected PciMessage makeRequest(int attempt) {
- VirtualControlLoopEvent onset = params.getContext().getEvent();
String subRequestId = getSubRequestId();
/* Construct an SDNR request using pci Model */
PciMessage dmaapRequest = new PciMessage();
dmaapRequest.setVersion("1.0");
- dmaapRequest.setCorrelationId(onset.getRequestId() + "-" + subRequestId);
+ dmaapRequest.setCorrelationId(params.getRequestId() + "-" + subRequestId);
dmaapRequest.setType("request");
dmaapRequest.setRpcName(params.getOperation().toLowerCase());
@@ -151,11 +152,11 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
/* The common header is a required field for all SDNR requests. */
PciCommonHeader requestCommonHeader = new PciCommonHeader();
- requestCommonHeader.setRequestId(onset.getRequestId());
+ requestCommonHeader.setRequestId(params.getRequestId());
requestCommonHeader.setSubRequestId(subRequestId);
sdnrRequest.setCommonHeader(requestCommonHeader);
- sdnrRequest.setPayload(onset.getPayload());
+ sdnrRequest.setPayload(params.getContext().getEvent().getPayload());
sdnrRequest.setAction(params.getOperation());
/*
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
index 7e9d263ad..8ec1e4a20 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.controlloop.actor.sdnr;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -29,6 +30,7 @@ import static org.mockito.Mockito.mock;
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;
@@ -38,6 +40,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
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.BidirectionalTopicOperation.Status;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
@@ -86,6 +89,11 @@ public class SdnrOperationTest extends BasicSdnrOperation {
}
@Test
+ public void testGetPropertyNames() {
+ assertThat(operation.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_VSERVER_LINK));
+ }
+
+ @Test
public void testMakeRequest() {
operation.generateSubRequestId(1);