From 61a84fecc1eae8640fec2860f4b50102ed0baa64 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 27 Mar 2020 12:35:23 -0400 Subject: 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 --- .../actor/appclcm/AppcLcmOperationTest.java | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'models-interactions/model-actors/actor.appclcm/src') diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java index 8e6a603eb..9744d829b 100644 --- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java +++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java @@ -37,13 +37,18 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.Pair; +import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.appclcm.AppcLcmBody; import org.onap.policy.appclcm.AppcLcmCommonHeader; import org.onap.policy.appclcm.AppcLcmDmaapWrapper; import org.onap.policy.appclcm.AppcLcmOutput; import org.onap.policy.appclcm.AppcLcmResponseStatus; +import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.endpoints.event.comm.TopicSource; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -52,8 +57,12 @@ import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation.Status; +import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; +import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.controlloop.policy.Target; +import org.onap.policy.simulators.AppcLcmTopicServer; +import org.onap.policy.simulators.TopicServer; public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation { @@ -68,6 +77,16 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation { private AppcLcmDmaapWrapper response; private AppcLcmOperation oper; + @BeforeClass + public static void setUpBeforeClass() throws Exception { + initBeforeClass(MY_SINK, MY_SOURCE); + } + + @AfterClass + public static void tearDownAfterClass() { + destroyAfterClass(); + } + /** * Sets up. */ @@ -80,6 +99,38 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation { oper = new AppcLcmOperation(params, config); } + @After + public void tearDown() { + super.tearDownBasic(); + } + + @SuppressWarnings("rawtypes") + protected TopicServer makeServer(TopicSink sink, TopicSource source) { + return new AppcLcmTopicServer(sink, source); + } + + /** + * Tests "success" case with simulator. + */ + @Test + public void testSuccess() throws Exception { + BidirectionalTopicParams opParams = + BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE).build(); + config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcLcmOperation.SELECTOR_KEYS); + + params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build(); + + oper = new AppcLcmOperation(params, config) { + @Override + protected CompletableFuture startGuardAsync() { + return null; + } + }; + + outcome = oper.start().get(); + assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + } + @Test public void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); -- cgit 1.2.3-korg