aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so/src/test/java
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.so/src/test/java
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.so/src/test/java')
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java13
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java16
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java16
3 files changed, 40 insertions, 5 deletions
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 46d96fded..7314c59fa 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
@@ -60,6 +60,9 @@ public class SoOperationTest extends BasicSoOperation {
private static final String VF_COUNT_KEY = SoConstants.VF_COUNT_PREFIX
+ "[my-model-customization-id][my-model-invariant-id][my-model-version-id]";
+
+ private static final List<String> PROP_NAMES = Collections.emptyList();
+
private SoOperation oper;
/**
@@ -71,7 +74,7 @@ public class SoOperationTest extends BasicSoOperation {
initConfig();
- oper = new SoOperation(params, config) {};
+ oper = new SoOperation(params, config, PROP_NAMES) {};
}
@Test
@@ -83,7 +86,7 @@ public class SoOperationTest extends BasicSoOperation {
// check when Target is null
params = params.toBuilder().target(null).build();
- assertThatIllegalArgumentException().isThrownBy(() -> new SoOperation(params, config) {})
+ assertThatIllegalArgumentException().isThrownBy(() -> new SoOperation(params, config, PROP_NAMES) {})
.withMessageContaining("Target information");
}
@@ -222,7 +225,7 @@ public class SoOperationTest extends BasicSoOperation {
// try with null target
params = params.toBuilder().target(null).build();
- assertThatIllegalArgumentException().isThrownBy(() -> new SoOperation(params, config) {})
+ assertThatIllegalArgumentException().isThrownBy(() -> new SoOperation(params, config, PROP_NAMES) {})
.withMessageContaining("missing Target");
}
@@ -258,7 +261,7 @@ public class SoOperationTest extends BasicSoOperation {
// null payload
params = params.toBuilder().payload(null).build();
- oper = new SoOperation(params, config) {};
+ oper = new SoOperation(params, config, PROP_NAMES) {};
assertTrue(oper.buildRequestParameters().isEmpty());
}
@@ -278,7 +281,7 @@ public class SoOperationTest extends BasicSoOperation {
// null payload
params = params.toBuilder().payload(null).build();
- oper = new SoOperation(params, config) {};
+ oper = new SoOperation(params, config, PROP_NAMES) {};
assertTrue(oper.buildConfigurationParameters().isEmpty());
}
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 94268646d..0db209dad 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
@@ -20,6 +20,7 @@
package org.onap.policy.controlloop.actor.so;
+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.assertFalse;
@@ -30,6 +31,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
@@ -50,6 +52,7 @@ import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
@@ -116,6 +119,19 @@ public class VfModuleCreateTest extends BasicSoOperation {
}
@Test
+ public void testGetPropertyNames() {
+ // @formatter:off
+ assertThat(oper.getPropertyNames()).isEqualTo(
+ List.of(
+ OperationProperties.AAI_MODEL_SERVICE,
+ OperationProperties.AAI_MODEL_VNF,
+ OperationProperties.AAI_MODEL_CLOUD_REGION,
+ OperationProperties.AAI_MODEL_TENANT,
+ OperationProperties.DATA_VF_COUNT));
+ // @formatter:on
+ }
+
+ @Test
public void testStartPreprocessorAsync() throws Exception {
// insert CQ data so it's there for the check
context.setProperty(AaiCqResponse.CONTEXT_KEY, makeCqResponse());
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
index d7b53411b..7c37dc900 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.controlloop.actor.so;
+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.assertFalse;
@@ -39,6 +40,7 @@ import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
@@ -63,6 +65,7 @@ import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
@@ -145,6 +148,19 @@ public class VfModuleDeleteTest extends BasicSoOperation {
}
@Test
+ public void testGetPropertyNames() {
+ // @formatter:off
+ assertThat(oper.getPropertyNames()).isEqualTo(
+ List.of(
+ OperationProperties.AAI_MODEL_SERVICE,
+ OperationProperties.AAI_MODEL_VNF,
+ OperationProperties.AAI_MODEL_CLOUD_REGION,
+ OperationProperties.AAI_MODEL_TENANT,
+ OperationProperties.DATA_VF_COUNT));
+ // @formatter:on
+ }
+
+ @Test
public void testStartPreprocessorAsync() throws Exception {
// insert CQ data so it's there for the check
context.setProperty(AaiCqResponse.CONTEXT_KEY, makeCqResponse());