summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.sdnr/src
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.sdnr/src
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.sdnr/src')
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java13
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java46
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java21
3 files changed, 79 insertions, 1 deletions
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java
index 27d7d435c..15f919b21 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java
@@ -31,6 +31,8 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
+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.StandardCoderObject;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
@@ -43,6 +45,8 @@ import org.onap.policy.sdnr.PciMessage;
import org.onap.policy.sdnr.PciResponse;
import org.onap.policy.sdnr.Status;
import org.onap.policy.sdnr.util.StatusCodeEnum;
+import org.onap.policy.simulators.SdnrTopicServer;
+import org.onap.policy.simulators.TopicServer;
import org.powermock.reflect.Whitebox;
public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperation {
@@ -86,6 +90,15 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio
status.setValue(StatusCodeEnum.SUCCESS.toString());
}
+ public void tearDown() {
+ super.tearDownBasic();
+ }
+
+ @SuppressWarnings("rawtypes")
+ protected TopicServer makeServer(TopicSink sink, TopicSource source) {
+ return new SdnrTopicServer(sink, source);
+ }
+
/**
* Runs the operation and verifies that the response is successful.
*
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java
index 3165d5814..e3e3c9925 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/ModifyConfigOperationTest.java
@@ -30,11 +30,17 @@ import static org.mockito.Mockito.when;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
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.common.utils.coder.CoderException;
+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.parameters.BidirectionalTopicConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.sdnr.PciMessage;
@@ -46,15 +52,53 @@ public class ModifyConfigOperationTest extends BasicSdnrOperation {
super(DEFAULT_ACTOR, ModifyConfigOperation.NAME);
}
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ BasicBidirectionalTopicOperation.initBeforeClass(MY_SINK, MY_SOURCE);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ destroyAfterClass();
+ }
+
@Before
public void setUp() throws Exception {
super.setUp();
oper = new ModifyConfigOperation(params, config);
}
+ @After
+ @Override
+ public void tearDown() {
+ super.tearDown();
+ }
+
+
+ /**
+ * 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, SdnrOperation.SELECTOR_KEYS);
+
+ params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
+
+ oper = new ModifyConfigOperation(params, config) {
+ @Override
+ protected CompletableFuture<OperationOutcome> startGuardAsync() {
+ return null;
+ }
+ };
+
+ outcome = oper.start().get();
+ assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ }
@Test
- public void testModifyConfigOperation() {
+ public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(ModifyConfigOperation.NAME, oper.getName());
}
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
index 5f6a5df3b..8f58f7d87 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
@@ -27,8 +27,12 @@ import static org.junit.Assert.assertSame;
import java.util.Arrays;
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.controlloop.actor.test.BasicBidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation.Status;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.sdnr.PciCommonHeader;
@@ -39,16 +43,33 @@ public class SdnrOperationTest extends BasicSdnrOperation {
private SdnrOperation operation;
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ BasicBidirectionalTopicOperation.initBeforeClass(MY_SINK, MY_SOURCE);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ destroyAfterClass();
+ }
+
/**
* Setup.
*/
@Before
+ @Override
public void setUp() throws Exception {
super.setUp();
operation = new SdnrOperation(params, config) {};
}
+ @After
+ @Override
+ public void tearDown() {
+ super.tearDown();
+ }
+
@Test
public void testSdnrOperation() {
assertEquals(DEFAULT_ACTOR, operation.getActorName());