summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actor.so')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java2
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.java63
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java37
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java62
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java9
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java19
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoConfigTest.java82
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java18
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperatorTest.java50
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java8
10 files changed, 212 insertions, 138 deletions
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
index c7c6b00e9..1dbad623b 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
@@ -98,7 +98,7 @@ public class SoActorServiceProvider extends ActorImpl {
public SoActorServiceProvider() {
super(NAME);
- addOperator(SoOperator.makeSoOperator(NAME, VfModuleCreate.NAME, VfModuleCreate::new));
+ addOperator(new SoOperator(NAME, VfModuleCreate.NAME, VfModuleCreate::new));
}
// TODO old code: remove lines down to **HERE**
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.java
new file mode 100644
index 000000000..959cd454a
--- /dev/null
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.so;
+
+import java.util.concurrent.Executor;
+import lombok.Getter;
+import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+
+@Getter
+public class SoConfig extends HttpConfig {
+
+ /**
+ * Path to use for the "get" request. A trailing "/" is added, if it is missing.
+ */
+ private String pathGet;
+
+ /**
+ * Maximum number of "get" requests permitted, after the initial request, to retrieve
+ * the response.
+ */
+ private int maxGets;
+
+ /**
+ * Time, in seconds, to wait between issuing "get" requests.
+ */
+ private int waitSecGet;
+
+
+ /**
+ * Constructs the object.
+ *
+ * @param blockingExecutor executor to be used for tasks that may perform blocking I/O
+ * @param params operator parameters
+ * @param clientFactory factory from which to obtain the {@link HttpClient}
+ */
+ public SoConfig(Executor blockingExecutor, SoParams params, HttpClientFactory clientFactory) {
+ super(blockingExecutor, params, clientFactory);
+
+ this.pathGet = params.getPathGet() + (params.getPathGet().endsWith("/") ? "" : "/");
+ this.maxGets = params.getMaxGets();
+ this.waitSecGet = params.getWaitSecGet();
+ }
+}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
index 510a737a6..d8d960e54 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
@@ -41,6 +41,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.controlloop.policy.Target;
import org.onap.policy.so.SoModelInfo;
@@ -68,8 +69,7 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
public static final String REQ_PARAM_NM = "requestParameters";
public static final String CONFIG_PARAM_NM = "configurationParameters";
- @Getter
- private final SoOperator operator;
+ private final SoConfig config;
/**
* Number of "get" requests issued so far, on the current operation attempt.
@@ -82,11 +82,11 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
* Constructs the object.
*
* @param params operation parameters
- * @param operator operator that created this operation
+ * @param config configuration for this operation
*/
- public SoOperation(ControlLoopOperationParams params, SoOperator operator) {
- super(params, operator, SoResponse.class);
- this.operator = operator;
+ public SoOperation(ControlLoopOperationParams params, HttpConfig config) {
+ super(params, config, SoResponse.class);
+ this.config = (SoConfig) config;
}
/**
@@ -134,9 +134,8 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
}
// see if the limit for the number of "gets" has been reached
- if (getCount++ >= operator.getMaxGets()) {
- logger.warn("{}: execeeded 'get' limit {} for {}", getFullName(), operator.getMaxGets(),
- params.getRequestId());
+ if (getCount++ >= getMaxGets()) {
+ logger.warn("{}: execeeded 'get' limit {} for {}", getFullName(), getMaxGets(), params.getRequestId());
setOutcome(outcome, PolicyResult.FAILURE_TIMEOUT);
outcome.setMessage(SO_RESPONSE_CODE + " " + outcome.getMessage());
return CompletableFuture.completedFuture(outcome);
@@ -155,15 +154,15 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
* @return a future that can be used to cancel the "get" request or await its response
*/
private CompletableFuture<OperationOutcome> issueGet(OperationOutcome outcome, SoResponse response) {
- String path = operator.getPathGet() + response.getRequestReferences().getRequestId();
- String url = operator.getClient().getBaseUrl() + path;
+ String path = getPathGet() + response.getRequestReferences().getRequestId();
+ String url = getClient().getBaseUrl() + path;
logger.debug("{}: 'get' count {} for {}", getFullName(), getCount, params.getRequestId());
logMessage(EventType.OUT, CommInfrastructure.REST, url, null);
// TODO should this use "path" or the full "url"?
- return handleResponse(outcome, url, callback -> operator.getClient().get(callback, path, null));
+ return handleResponse(outcome, url, callback -> getClient().get(callback, path, null));
}
/**
@@ -335,6 +334,18 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
* @return the wait time, in milliseconds, between "get" requests
*/
public long getWaitMsGet() {
- return TimeUnit.MILLISECONDS.convert(operator.getWaitSecGet(), TimeUnit.SECONDS);
+ return TimeUnit.MILLISECONDS.convert(getWaitSecGet(), TimeUnit.SECONDS);
+ }
+
+ public int getMaxGets() {
+ return config.getMaxGets();
+ }
+
+ public String getPathGet() {
+ return config.getPathGet();
+ }
+
+ public int getWaitSecGet() {
+ return config.getWaitSecGet();
}
}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java
index 011201f23..b8d0e652a 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java
@@ -21,70 +21,32 @@
package org.onap.policy.controlloop.actor.so;
import java.util.Map;
-import java.util.function.BiFunction;
-import lombok.Getter;
import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
+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.impl.OperationMaker;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-@Getter
-public abstract class SoOperator extends HttpOperator {
-
- /**
- * Path to use for the "get" request. A trailing "/" is added, if it is missing.
- */
- private String pathGet;
-
- /**
- * Maximum number of "get" requests permitted, after the initial request, to retrieve
- * the response.
- */
- private int maxGets;
-
- /**
- * Time, in seconds, to wait between issuing "get" requests.
- */
- private int waitSecGet;
-
+/**
+ * SO Operator.
+ */
+public class SoOperator extends HttpOperator {
- public SoOperator(String actorName, String name) {
- super(actorName, name);
+ public SoOperator(String actorName, String name,
+ @SuppressWarnings("rawtypes") OperationMaker<HttpConfig, HttpOperation> operationMaker) {
+ super(actorName, name, operationMaker);
}
@Override
- protected void doConfigure(Map<String, Object> parameters) {
+ protected HttpConfig makeConfiguration(Map<String, Object> parameters) {
SoParams params = Util.translate(getFullName(), parameters, SoParams.class);
ValidationResult result = params.validate(getFullName());
if (!result.isValid()) {
throw new ParameterValidationRuntimeException("invalid parameters", result);
}
- this.pathGet = params.getPathGet() + (params.getPathGet().endsWith("/") ? "" : "/");
- this.maxGets = params.getMaxGets();
- this.waitSecGet = params.getWaitSecGet();
-
- super.doConfigure(params);
- }
-
- /**
- * Makes an operator that will construct operations.
- *
- * @param actorName actor name
- * @param operation operation name
- * @param operationMaker function to make an operation
- * @return a new operator
- */
- public static SoOperator makeSoOperator(String actorName, String operation,
- BiFunction<ControlLoopOperationParams, SoOperator, SoOperation> operationMaker) {
-
- return new SoOperator(actorName, operation) {
- @Override
- public Operation buildOperation(ControlLoopOperationParams params) {
- return operationMaker.apply(params, this);
- }
- };
+ return new SoConfig(getBlockingExecutor(), params, getClientFactory());
}
}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
index f356dcefc..c17d25211 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
@@ -35,6 +35,7 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.controlloop.actor.aai.AaiCustomQueryOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.so.SoCloudConfiguration;
import org.onap.policy.so.SoModelInfo;
import org.onap.policy.so.SoOperationType;
@@ -47,8 +48,8 @@ import org.onap.policy.so.SoRequestParameters;
public class VfModuleCreate extends SoOperation {
public static final String NAME = "VF Module Create";
- public VfModuleCreate(ControlLoopOperationParams params, SoOperator operator) {
- super(params, operator);
+ public VfModuleCreate(ControlLoopOperationParams params, HttpConfig config) {
+ super(params, config);
}
/**
@@ -75,13 +76,13 @@ public class VfModuleCreate extends SoOperation {
SoRequest request = pair.getRight();
Entity<SoRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
- String url = getOperator().getClient().getBaseUrl() + path;
+ String url = getClient().getBaseUrl() + path;
logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
// TODO should this use "path" or the full "url"?
- return handleResponse(outcome, url, callback -> getOperator().getClient().post(callback, path, entity, null));
+ return handleResponse(outcome, url, callback -> getClient().post(callback, path, entity, null));
}
/**
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
index 089470420..3a2aaf849 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
@@ -54,7 +54,7 @@ public abstract class BasicSoOperation extends BasicHttpOperation<SoRequest> {
public static final int WAIT_SEC_GETS = 20;
@Mock
- protected SoOperator soOperator;
+ protected SoConfig config;
protected Target target;
protected SoResponse response;
@@ -80,7 +80,7 @@ public abstract class BasicSoOperation extends BasicHttpOperation<SoRequest> {
* Initializes mocks and sets up.
*/
public void setUp() throws Exception {
- super.setUp();
+ super.setUpBasic();
response = new SoResponse();
@@ -98,17 +98,16 @@ public abstract class BasicSoOperation extends BasicHttpOperation<SoRequest> {
when(rawResponse.getStatus()).thenReturn(200);
when(rawResponse.readEntity(String.class)).thenReturn(coder.encode(response));
- operator = soOperator;
-
- initOperator();
+ initConfig();
}
@Override
- protected void initOperator() {
- super.initOperator();
- when(soOperator.getMaxGets()).thenReturn(MAX_GETS);
- when(soOperator.getPathGet()).thenReturn(PATH_GET);
- when(soOperator.getWaitSecGet()).thenReturn(WAIT_SEC_GETS);
+ protected void initConfig() {
+ super.initConfig();
+ when(config.getClient()).thenReturn(client);
+ when(config.getMaxGets()).thenReturn(MAX_GETS);
+ when(config.getPathGet()).thenReturn(PATH_GET);
+ when(config.getWaitSecGet()).thenReturn(WAIT_SEC_GETS);
}
@Override
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoConfigTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoConfigTest.java
new file mode 100644
index 000000000..17fd9c9de
--- /dev/null
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoConfigTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.so;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.Executor;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
+
+public class SoConfigTest {
+ private static final String MY_CLIENT = "my-client";
+ private static final String MY_PATH = "my-path";
+ private static final String GET_PATH = "get-path";
+ private static final int TIMEOUT_SEC = 10;
+ private static final int MAX_GETS = 20;
+ private static final int WAIT_SEC = 30;
+
+ @Mock
+ private HttpClient client;
+ @Mock
+ private HttpClientFactory factory;
+ @Mock
+ private Executor executor;
+
+ private SoParams params;
+ private SoConfig config;
+
+ /**
+ * Sets up.
+ */
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ when(factory.get(MY_CLIENT)).thenReturn(client);
+
+ params = SoParams.builder().maxGets(MAX_GETS).pathGet(GET_PATH).waitSecGet(WAIT_SEC).clientName(MY_CLIENT)
+ .path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
+ config = new SoConfig(executor, params, factory);
+ }
+
+ @Test
+ public void test() {
+ assertEquals(GET_PATH + "/", config.getPathGet());
+ assertEquals(MAX_GETS, config.getMaxGets());
+ assertEquals(WAIT_SEC, config.getWaitSecGet());
+
+ // check value from superclass
+ assertSame(executor, config.getBlockingExecutor());
+ assertSame(client, config.getClient());
+
+ // path with trailing "/"
+ params = params.toBuilder().pathGet(GET_PATH + "/").build();
+ config = new SoConfig(executor, params, factory);
+ assertEquals(GET_PATH + "/", config.getPathGet());
+ }
+}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
index e70413876..871d37032 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
@@ -68,16 +68,16 @@ public class SoOperationTest extends BasicSoOperation {
public void setUp() throws Exception {
super.setUp();
- initOperator();
+ initConfig();
- oper = new SoOperation(params, soOperator) {};
+ oper = new SoOperation(params, config) {};
}
@Test
public void testConstructor_testGetWaitMsGet() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
- assertSame(soOperator, oper.getOperator());
+ assertSame(config, oper.getConfig());
assertEquals(1000 * WAIT_SEC_GETS, oper.getWaitMsGet());
}
@@ -85,7 +85,7 @@ public class SoOperationTest extends BasicSoOperation {
public void testStartPreprocessorAsync() {
AtomicBoolean guardStarted = new AtomicBoolean();
- oper = new SoOperation(params, soOperator) {
+ oper = new SoOperation(params, config) {
@Override
protected CompletableFuture<OperationOutcome> startGuardAsync() {
guardStarted.set(true);
@@ -150,7 +150,7 @@ public class SoOperationTest extends BasicSoOperation {
// use a real executor
params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
- oper = new SoOperation(params, soOperator) {
+ oper = new SoOperation(params, config) {
@Override
public long getWaitMsGet() {
return 1;
@@ -159,7 +159,7 @@ public class SoOperationTest extends BasicSoOperation {
CompletableFuture<OperationOutcome> future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
- assertSame(outcome, future2.get(5, TimeUnit.SECONDS));
+ assertSame(outcome, future2.get(500, TimeUnit.SECONDS));
assertEquals(PolicyResult.SUCCESS, outcome.getResult());
assertEquals(2, oper.getGetCount());
@@ -236,7 +236,7 @@ public class SoOperationTest extends BasicSoOperation {
// try with null target
params = params.toBuilder().target(null).build();
- oper = new SoOperation(params, soOperator) {};
+ oper = new SoOperation(params, config) {};
assertThatIllegalArgumentException().isThrownBy(() -> oper.prepareSoModelInfo()).withMessage("missing Target");
}
@@ -274,7 +274,7 @@ public class SoOperationTest extends BasicSoOperation {
// null payload
params = params.toBuilder().payload(null).build();
- oper = new SoOperation(params, soOperator) {};
+ oper = new SoOperation(params, config) {};
assertNull(oper.buildRequestParameters());
}
@@ -295,7 +295,7 @@ public class SoOperationTest extends BasicSoOperation {
// null payload
params = params.toBuilder().payload(null).build();
- oper = new SoOperation(params, soOperator) {};
+ oper = new SoOperation(params, config) {};
assertNull(oper.buildConfigurationParameters());
}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperatorTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperatorTest.java
index 16bbdea2a..20403237b 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperatorTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperatorTest.java
@@ -22,9 +22,7 @@ package org.onap.policy.controlloop.actor.so;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import java.util.Map;
@@ -34,11 +32,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
public class SoOperatorTest {
@@ -86,35 +80,8 @@ public class SoOperatorTest {
}
@Test
- public void testMakeSoOperator() {
- oper = SoOperator.makeSoOperator(ACTOR, OPERATION, MyOperation::new);
-
- VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- ControlLoopEventContext context = new ControlLoopEventContext(event);
- ControlLoopOperationParams params =
- ControlLoopOperationParams.builder().actor(ACTOR).operation(OPERATION).context(context).build();
-
- Operation operation1 = oper.buildOperation(params);
- assertNotNull(operation1);
-
- Operation operation2 = oper.buildOperation(params);
- assertNotNull(operation2);
- assertNotSame(operation1, operation2);
- }
-
- @Test
public void testDoConfigure_testGetters() {
- // should use given values
- assertSame(client, oper.getClient());
- assertEquals(PATH_GET, oper.getPathGet());
- assertEquals(MAX_GETS, oper.getMaxGets());
- assertEquals(WAIT_SEC_GETS, oper.getWaitSecGet());
-
- SoParams params = SoParams.builder().pathGet("unslashed").maxGets(MAX_GETS).waitSecGet(WAIT_SEC_GETS)
- .clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
- Map<String, Object> paramMap = Util.translateToMap(OPERATION, params);
- oper.configure(paramMap);
- assertEquals("unslashed/", oper.getPathGet());
+ assertTrue(oper.getCurrentConfig() instanceof SoConfig);
// test invalid parameters
Map<String, Object> paramMap2 = Util.translateToMap(OPERATION, SoParams.builder().build());
@@ -124,12 +91,7 @@ public class SoOperatorTest {
private class MyOperator extends SoOperator {
public MyOperator() {
- super(ACTOR, OPERATION);
- }
-
- @Override
- public Operation buildOperation(ControlLoopOperationParams params) {
- return null;
+ super(ACTOR, OPERATION, null);
}
@Override
@@ -137,10 +99,4 @@ public class SoOperatorTest {
return factory;
}
}
-
- private class MyOperation extends SoOperation {
- public MyOperation(ControlLoopOperationParams params, SoOperator operator) {
- super(params, operator);
- }
- }
}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
index 40efdc880..6c3cfbf66 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
@@ -64,7 +64,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
@Before
public void setUp() throws Exception {
super.setUp();
- oper = new VfModuleCreate(params, soOperator);
+ oper = new VfModuleCreate(params, config);
}
@Test
@@ -82,7 +82,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
AtomicBoolean guardStarted = new AtomicBoolean();
- oper = new VfModuleCreate(params, soOperator) {
+ oper = new VfModuleCreate(params, config) {
@Override
protected CompletableFuture<OperationOutcome> startGuardAsync() {
guardStarted.set(true);
@@ -102,7 +102,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
// use a real executor
params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
- oper = new VfModuleCreate(params, soOperator) {
+ oper = new VfModuleCreate(params, config) {
@Override
public long getWaitMsGet() {
return 1;
@@ -128,7 +128,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
// use a real executor
params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
- oper = new VfModuleCreate(params, soOperator) {
+ oper = new VfModuleCreate(params, config) {
@Override
public long getWaitMsGet() {
return 1;