diff options
author | Jim Hahn <jrh3@att.com> | 2020-03-27 12:35:23 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-03-30 09:01:15 -0400 |
commit | 61a84fecc1eae8640fec2860f4b50102ed0baa64 (patch) | |
tree | 32ba4cf68bd9f6c4f97e92f665ab2de7ad788dc6 /models-interactions/model-actors/actor.test/src/test | |
parent | 3a374cbc9f4bef8856c3e78be1a6b4c5274cd744 (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.test/src/test')
-rw-r--r-- | models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java index 101f130a3..afb8f075e 100644 --- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java +++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java @@ -28,12 +28,18 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import java.util.function.BiConsumer; +import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +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.simulators.TopicServer; public class BasicBidirectionalTopicOperationTest { private static final String ACTOR = "my-actor"; @@ -44,6 +50,16 @@ public class BasicBidirectionalTopicOperationTest { private BasicBidirectionalTopicOperation oper; + @BeforeClass + public static void setUpBeforeClass() throws Exception { + BasicBidirectionalTopicOperation.initBeforeClass(BasicBidirectionalTopicOperation.MY_SINK, + BasicBidirectionalTopicOperation.MY_SOURCE); + } + + @AfterClass + public static void tearDownAfterClass() { + BasicBidirectionalTopicOperation.destroyAfterClass(); + } /** * Sets up. @@ -52,13 +68,28 @@ public class BasicBidirectionalTopicOperationTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - oper = new BasicBidirectionalTopicOperation(ACTOR, OPERATION); + oper = new MyOperation(ACTOR, OPERATION); oper.setUpBasic(); } + @After + public void tearDown() { + oper.tearDownBasic(); + } + + @Test + public void testTopicMgr() { + assertNotNull(BasicBidirectionalTopicOperation.topicMgr.getTopicHandler( + BasicBidirectionalTopicOperation.MY_SINK, BasicBidirectionalTopicOperation.MY_SOURCE)); + } + @Test public void testBasicBidirectionalTopicOperation() { - oper = new BasicBidirectionalTopicOperation(); + oper.tearDownBasic(); + + oper = new MyOperation(); + oper.setUpBasic(); + assertEquals(BasicOperation.DEFAULT_ACTOR, oper.actorName); assertEquals(BasicOperation.DEFAULT_OPERATION, oper.operationName); } @@ -101,4 +132,31 @@ public class BasicBidirectionalTopicOperationTest { assertThatIllegalArgumentException().isThrownBy(() -> oper.provideResponse(listener, "{invalid json")) .withMessage("response is not a Map"); } + + private static class MyOperation extends BasicBidirectionalTopicOperation { + public MyOperation() { + super(); + } + + /** + * Constructs the object. + * + * @param actor actor name + * @param operation operation name + */ + public MyOperation(String actor, String operation) { + super(actor, operation); + } + + @Override + @SuppressWarnings("rawtypes") + protected TopicServer makeServer(TopicSink sink, TopicSource source) { + return new TopicServer<String>(sink, source, null, String.class) { + @Override + protected String process(String request) { + return null; + } + }; + } + } } |