aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-03-27 12:35:23 -0400
committerJim Hahn <jrh3@att.com>2020-03-30 09:01:15 -0400
commit61a84fecc1eae8640fec2860f4b50102ed0baa64 (patch)
tree32ba4cf68bd9f6c4f97e92f665ab2de7ad788dc6 /models-interactions/model-actors/actor.so/src/test
parent3a374cbc9f4bef8856c3e78be1a6b4c5274cd744 (diff)
Test new actors against simulators
Also modified HttpParams to allow "path" to be blank to support any cases that really have no "path" to append to the context URI base path. Issue-ID: POLICY-2405 Change-Id: I49eebde6759659d2804b5a11c1504c37674bd0c4 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.so/src/test')
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java20
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java28
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java28
3 files changed, 76 insertions, 0 deletions
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 f33d501b6..e6a3615ad 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
@@ -30,6 +30,9 @@ import java.util.List;
import java.util.Map;
import org.mockito.Mock;
import org.onap.policy.aai.AaiCqResponse;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.policy.Target;
@@ -81,6 +84,23 @@ public abstract class BasicSoOperation extends BasicHttpOperation<SoRequest> {
}
/**
+ * Starts the simulator.
+ */
+ protected static void initBeforeClass() throws Exception {
+ org.onap.policy.simulators.Util.buildSoSim();
+
+ BusTopicParams clientParams =
+ BusTopicParams.builder().clientName(MY_CLIENT).basePath("").hostname("localhost")
+ .managed(true).port(org.onap.policy.simulators.Util.SOSIM_SERVER_PORT).build();
+ HttpClientFactoryInstance.getClientFactory().build(clientParams);
+ }
+
+ protected static void destroyAfterClass() {
+ HttpClientFactoryInstance.getClientFactory().destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ }
+
+ /**
* Initializes mocks and sets up.
*/
public void setUp() throws Exception {
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 1d5d44cc8..918559a20 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
@@ -36,7 +36,9 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.lang3.tuple.Pair;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.onap.aai.domain.yang.CloudRegion;
@@ -45,6 +47,7 @@ import org.onap.aai.domain.yang.ModelVer;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
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.parameters.ControlLoopOperationParams;
@@ -63,6 +66,15 @@ public class VfModuleCreateTest extends BasicSoOperation {
super(DEFAULT_ACTOR, VfModuleCreate.NAME);
}
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ initBeforeClass();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ destroyAfterClass();
+ }
@Before
public void setUp() throws Exception {
@@ -70,6 +82,22 @@ public class VfModuleCreateTest extends BasicSoOperation {
oper = new VfModuleCreate(params, config);
}
+ /**
+ * Tests "success" case with simulator.
+ */
+ @Test
+ public void testSuccess() throws Exception {
+ SoParams opParams = SoParams.builder().clientName(MY_CLIENT).path("serviceInstantiation/v7/serviceInstances")
+ .pathGet("orchestrationRequests/v5/").build();
+ config = new SoConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
+
+ params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
+ oper = new VfModuleCreate(params, config);
+
+ outcome = oper.start().get();
+ assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ }
+
@Test
public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
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 cb2bceffd..16775fe5d 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
@@ -48,7 +48,9 @@ import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.tuple.Pair;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -58,6 +60,7 @@ import org.onap.aai.domain.yang.ModelVer;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.aai.AaiCqResponse;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -89,6 +92,15 @@ public class VfModuleDeleteTest extends BasicSoOperation {
super(DEFAULT_ACTOR, VfModuleDelete.NAME);
}
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ initBeforeClass();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ destroyAfterClass();
+ }
/**
* Sets up.
@@ -104,6 +116,22 @@ public class VfModuleDeleteTest extends BasicSoOperation {
oper = new MyOperation(params, config);
}
+ /**
+ * Tests "success" case with simulator.
+ */
+ @Test
+ public void testSuccess() throws Exception {
+ SoParams opParams = SoParams.builder().clientName(MY_CLIENT).path("serviceInstances/v7")
+ .pathGet("orchestrationRequests/v5/").build();
+ config = new SoConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
+
+ params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
+ oper = new VfModuleDelete(params, config);
+
+ outcome = oper.start().get();
+ assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ }
+
@Test
public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());