aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.sdnc
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-02-20 09:40:14 -0500
committerJim Hahn <jrh3@att.com>2020-02-20 16:29:08 -0500
commit467247c7970f9ae83464d78929ed970bbf03c593 (patch)
tree54b78e6505b664c3a61e532bf6f7c276307d6591 /models-interactions/model-actors/actor.sdnc
parentf6da7772d9dc01ce4ddd21a55b0f1c5fb7ad814f (diff)
More actor clean-up
Currently, Operator classes refer to Operation classes, and vice versa, creating a dependency cycle. In addition, there is a slight problem in that if an operator is reconfigured, any running operation may get inconsistent configuration data. Modified the code to create Config objects that are passed to the operation, instead of passing the Operator to the operations. This solved both issues. Replaceed makeOperator() with constructors. Added parameter type to HttpActors. Modified guard to get "ONAP" properties from its configuration, as a default. Changed setUp() to setUpBasic(), so "throws Exception" could be removed, thus resolving a sonar issue. Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I21eb8798acfbc636ff1bd8741b21c7278365b6e4
Diffstat (limited to 'models-interactions/model-actors/actor.sdnc')
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperation.java8
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperation.java8
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java12
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java10
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java2
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java11
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java2
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java2
8 files changed, 26 insertions, 29 deletions
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperation.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperation.java
index 26cdfada3..ff1881302 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperation.java
@@ -23,8 +23,8 @@ package org.onap.policy.controlloop.actor.sdnc;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
-import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.sdnc.SdncHealRequest;
import org.onap.policy.sdnc.SdncHealRequestHeaderInfo;
import org.onap.policy.sdnc.SdncHealRequestInfo;
@@ -49,10 +49,10 @@ public class BandwidthOnDemandOperation extends SdncOperation {
* Constructs the object.
*
* @param params operation parameters
- * @param operator operator that created this operation
+ * @param config configuration for this operation
*/
- public BandwidthOnDemandOperation(ControlLoopOperationParams params, HttpOperator operator) {
- super(params, operator);
+ public BandwidthOnDemandOperation(ControlLoopOperationParams params, HttpConfig config) {
+ super(params, config);
}
@Override
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperation.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperation.java
index f255f3e84..753da1bb1 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperation.java
@@ -23,8 +23,8 @@ package org.onap.policy.controlloop.actor.sdnc;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
-import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.sdnc.SdncHealNetworkInfo;
import org.onap.policy.sdnc.SdncHealRequest;
import org.onap.policy.sdnc.SdncHealRequestHeaderInfo;
@@ -45,10 +45,10 @@ public class RerouteOperation extends SdncOperation {
* Constructs the object.
*
* @param params operation parameters
- * @param operator operator that created this operation
+ * @param config configuration for this operation
*/
- public RerouteOperation(ControlLoopOperationParams params, HttpOperator operator) {
- super(params, operator);
+ public RerouteOperation(ControlLoopOperationParams params, HttpConfig config) {
+ super(params, config);
}
@Override
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java
index 99a4fdadd..cd9ad1ac2 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java
@@ -31,6 +31,7 @@ import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpActor;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.sdnc.SdncHealNetworkInfo;
import org.onap.policy.sdnc.SdncHealRequest;
@@ -46,7 +47,7 @@ import org.onap.policy.sdnc.SdncRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SdncActorServiceProvider extends HttpActor {
+public class SdncActorServiceProvider extends HttpActor<HttpActorParams> {
private static final Logger logger = LoggerFactory.getLogger(SdncActorServiceProvider.class);
public static final String NAME = "SDNC";
@@ -75,13 +76,10 @@ public class SdncActorServiceProvider extends HttpActor {
* Constructs the object.
*/
public SdncActorServiceProvider() {
- super(NAME);
+ super(NAME, HttpActorParams.class);
- addOperator(HttpOperator.makeOperator(NAME, RerouteOperation.NAME,
- RerouteOperation::new));
-
- addOperator(HttpOperator.makeOperator(NAME, BandwidthOnDemandOperation.NAME,
- BandwidthOnDemandOperation::new));
+ addOperator(new HttpOperator(NAME, RerouteOperation.NAME, RerouteOperation::new));
+ addOperator(new HttpOperator(NAME, BandwidthOnDemandOperation.NAME, BandwidthOnDemandOperation::new));
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
index f6cacd97b..a83faa724 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
@@ -29,8 +29,8 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
-import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.sdnc.SdncRequest;
import org.onap.policy.sdnc.SdncResponse;
@@ -43,10 +43,10 @@ public abstract class SdncOperation extends HttpOperation<SdncResponse> {
* Constructs the object.
*
* @param params operation parameters
- * @param operator operator that created this operation
+ * @param config configuration for this operation
*/
- public SdncOperation(ControlLoopOperationParams params, HttpOperator operator) {
- super(params, operator, SdncResponse.class);
+ public SdncOperation(ControlLoopOperationParams params, HttpConfig config) {
+ super(params, config, SdncResponse.class);
}
/**
@@ -73,7 +73,7 @@ public abstract class SdncOperation extends HttpOperation<SdncResponse> {
// @formatter:off
return handleResponse(outcome, url,
- callback -> getOperator().getClient().post(callback, makePath(), entity, headers));
+ callback -> getClient().post(callback, makePath(), entity, headers));
// @formatter:on
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
index e8490627e..ade25133c 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
@@ -42,7 +42,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
@Before
public void setUp() throws Exception {
super.setUp();
- oper = new BandwidthOnDemandOperation(params, operator);
+ oper = new BandwidthOnDemandOperation(params, config);
}
@Test
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
index c1278f1b1..50e97496a 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
@@ -32,12 +32,11 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
-import java.util.function.BiFunction;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
-import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.sdnc.SdncRequest;
import org.onap.policy.sdnc.SdncResponse;
@@ -76,7 +75,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation<SdncRequest>
* Initializes mocks and sets up.
*/
public void setUp() throws Exception {
- super.setUp();
+ super.setUpBasic();
response = new SdncResponse();
@@ -119,12 +118,12 @@ public abstract class BasicSdncOperation extends BasicHttpOperation<SdncRequest>
* @param expectedText text expected in the exception message
*/
protected void verifyMissing(String fieldName, String expectedText,
- BiFunction<ControlLoopOperationParams, HttpOperator, SdncOperation> maker) {
+ OperationMaker<HttpConfig, SdncOperation> maker) {
makeContext();
enrichment.remove(fieldName);
- SdncOperation oper = maker.apply(params, operator);
+ SdncOperation oper = maker.apply(params, config);
assertThatIllegalArgumentException().isThrownBy(() -> Whitebox.invokeMethod(oper, "makeRequest", 1))
.withMessageContaining("missing").withMessageContaining(expectedText);
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
index f0836b939..30ddd8781 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
@@ -42,7 +42,7 @@ public class RerouteOperationTest extends BasicSdncOperation {
@Before
public void setUp() throws Exception {
super.setUp();
- oper = new RerouteOperation(params, operator);
+ oper = new RerouteOperation(params, config);
}
@Test
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
index e0825e13b..b87ed2c80 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
@@ -42,7 +42,7 @@ public class SdncOperationTest extends BasicSdncOperation {
public void setUp() throws Exception {
super.setUp();
- oper = new SdncOperation(params, operator) {
+ oper = new SdncOperation(params, config) {
@Override
protected SdncRequest makeRequest(int attempt) {
return request;