summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.appc
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.appc
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.appc')
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java23
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java13
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java54
3 files changed, 88 insertions, 2 deletions
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
index 30450d02a..7f7ac7a54 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
@@ -30,7 +30,10 @@ import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;
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.appc.CommonHeader;
import org.onap.policy.appc.Request;
@@ -42,10 +45,22 @@ import org.onap.policy.controlloop.policy.PolicyResult;
public class AppcOperationTest extends BasicAppcOperation {
private AppcOperation oper;
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // use same topic name for both sides
+ initBeforeClass(MY_SINK, MY_SINK);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ destroyAfterClass();
+ }
+
/**
* Sets up.
*/
@Before
+ @Override
public void setUp() throws Exception {
super.setUp();
@@ -57,8 +72,14 @@ public class AppcOperationTest extends BasicAppcOperation {
};
}
+ @After
+ @Override
+ public void tearDown() {
+ super.tearDown();
+ }
+
@Test
- public void testAppcOperation() {
+ public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
index 06ad1661d..546a38d3a 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
@@ -35,6 +35,8 @@ import java.util.function.BiConsumer;
import org.onap.policy.appc.Response;
import org.onap.policy.appc.ResponseCode;
import org.onap.policy.appc.ResponseStatus;
+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.StandardCoderInstantAsMillis;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
@@ -44,6 +46,8 @@ import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.controlloop.policy.Target;
+import org.onap.policy.simulators.AppcLegacyTopicServer;
+import org.onap.policy.simulators.TopicServer;
import org.powermock.reflect.Whitebox;
/**
@@ -94,6 +98,15 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio
status.setDescription(MY_DESCRIPTION);
}
+ public void tearDown() {
+ super.tearDownBasic();
+ }
+
+ @SuppressWarnings("rawtypes")
+ protected TopicServer makeServer(TopicSink sink, TopicSource source) {
+ return new AppcLegacyTopicServer(sink, source);
+ }
+
/**
* Runs the operation and verifies that the response is successful.
*
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
index 95629bccf..743896c18 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
@@ -35,7 +35,10 @@ import java.util.Arrays;
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.aai.domain.yang.GenericVnf;
import org.onap.policy.aai.AaiCqResponse;
@@ -43,6 +46,8 @@ import org.onap.policy.appc.Request;
import org.onap.policy.common.utils.coder.CoderException;
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;
public class ModifyConfigOperationTest extends BasicAppcOperation {
@@ -53,14 +58,61 @@ public class ModifyConfigOperationTest extends BasicAppcOperation {
super(DEFAULT_ACTOR, ModifyConfigOperation.NAME);
}
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // use same topic name for both sides
+ initBeforeClass(MY_SINK, MY_SINK);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ destroyAfterClass();
+ }
+
@Before
+ @Override
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_SINK).build();
+ config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcOperation.SELECTOR_KEYS);
+
+ AaiCqResponse cq = mock(AaiCqResponse.class);
+ GenericVnf genvnf = mock(GenericVnf.class);
+ when(genvnf.getVnfId()).thenReturn(MY_VNF);
+ when(cq.getGenericVnfByModelInvariantId(any())).thenReturn(genvnf);
+
+ params.getContext().setProperty(AaiCqResponse.CONTEXT_KEY, cq);
+
+ 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());
}