diff options
Diffstat (limited to 'models-interactions/model-actors/actor.so/src')
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()); |