summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.test/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-02-20 09:40:14 -0500
committerJim Hahn <jrh3@att.com>2020-02-20 16:29:08 -0500
commit467247c7970f9ae83464d78929ed970bbf03c593 (patch)
tree54b78e6505b664c3a61e532bf6f7c276307d6591 /models-interactions/model-actors/actor.test/src/test
parentf6da7772d9dc01ce4ddd21a55b0f1c5fb7ad814f (diff)
More actor clean-up
Currently, Operator classes refer to Operation classes, and vice versa, creating a dependency cycle. In addition, there is a slight problem in that if an operator is reconfigured, any running operation may get inconsistent configuration data. Modified the code to create Config objects that are passed to the operation, instead of passing the Operator to the operations. This solved both issues. Replaceed makeOperator() with constructors. Added parameter type to HttpActors. Modified guard to get "ONAP" properties from its configuration, as a default. Changed setUp() to setUpBasic(), so "throws Exception" could be removed, thus resolving a sonar issue. Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I21eb8798acfbc636ff1bd8741b21c7278365b6e4
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.java24
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java20
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java2
3 files changed, 17 insertions, 29 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 9ec118e69..101f130a3 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
@@ -24,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
@@ -54,14 +53,14 @@ public class BasicBidirectionalTopicOperationTest {
MockitoAnnotations.initMocks(this);
oper = new BasicBidirectionalTopicOperation(ACTOR, OPERATION);
- oper.setUp();
+ oper.setUpBasic();
}
@Test
public void testBasicBidirectionalTopicOperation() {
oper = new BasicBidirectionalTopicOperation();
- assertEquals(BasicHttpOperation.DEFAULT_ACTOR, oper.actorName);
- assertEquals(BasicHttpOperation.DEFAULT_OPERATION, oper.operationName);
+ assertEquals(BasicOperation.DEFAULT_ACTOR, oper.actorName);
+ assertEquals(BasicOperation.DEFAULT_OPERATION, oper.operationName);
}
@Test
@@ -72,24 +71,19 @@ public class BasicBidirectionalTopicOperationTest {
@Test
public void testSetUp() {
- assertNotNull(oper.topicParams);
+ assertNotNull(oper.config);
assertNotNull(oper.context);
assertNotNull(oper.outcome);
assertNotNull(oper.executor);
- assertTrue(oper.operator.isAlive());
}
@Test
public void testInitOperator() {
- oper.initOperator();
-
- assertTrue(oper.operator.isAlive());
- assertEquals(ACTOR + "." + OPERATION, oper.operator.getFullName());
- assertEquals(ACTOR, oper.operator.getActorName());
- assertEquals(OPERATION, oper.operator.getName());
- assertSame(oper.topicHandler, oper.operator.getTopicHandler());
- assertSame(oper.forwarder, oper.operator.getForwarder());
- assertSame(oper.topicParams, oper.operator.getParams());
+ oper.initConfig();
+
+ assertSame(oper.topicHandler, oper.config.getTopicHandler());
+ assertSame(oper.forwarder, oper.config.getForwarder());
+ assertEquals(BasicBidirectionalTopicOperation.TIMEOUT_MS, oper.config.getTimeoutMs());
}
@Test
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
index c463d6d49..c19aa487c 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.controlloop.actor.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -42,14 +41,14 @@ public class BasicHttpOperationTest {
@Before
public void setUp() throws Exception {
oper = new BasicHttpOperation<>(ACTOR, OPERATION);
- oper.setUp();
+ oper.setUpBasic();
}
@Test
public void testBasicHttpOperation() {
oper = new BasicHttpOperation<>();
- assertEquals(BasicHttpOperation.DEFAULT_ACTOR, oper.actorName);
- assertEquals(BasicHttpOperation.DEFAULT_OPERATION, oper.operationName);
+ assertEquals(BasicOperation.DEFAULT_ACTOR, oper.actorName);
+ assertEquals(BasicOperation.DEFAULT_OPERATION, oper.operationName);
}
@Test
@@ -68,19 +67,14 @@ public class BasicHttpOperationTest {
assertNotNull(oper.context);
assertNotNull(oper.outcome);
assertNotNull(oper.executor);
- assertTrue(oper.operator.isAlive());
}
@Test
public void testInitOperator() throws Exception {
- oper.initOperator();
-
- assertTrue(oper.operator.isAlive());
- assertEquals(ACTOR + "." + OPERATION, oper.operator.getFullName());
- assertEquals(ACTOR, oper.operator.getActorName());
- assertEquals(OPERATION, oper.operator.getName());
- assertSame(oper.client, oper.operator.getClient());
- assertEquals(BasicHttpOperation.PATH, oper.operator.getPath());
+ oper.initConfig();
+
+ assertSame(oper.client, oper.config.getClient());
+ assertEquals(BasicHttpOperation.PATH, oper.config.getPath());
}
@Test
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
index ee0e5cee4..60bb00892 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
@@ -43,7 +43,7 @@ public class BasicOperationTest {
@Before
public void setUp() throws Exception {
oper = new BasicHttpOperation<>(ACTOR, OPERATION);
- oper.setUp();
+ oper.setUpBasic();
}
@Test