aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'feature-lifecycle/src/test')
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java16
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java24
2 files changed, 21 insertions, 19 deletions
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
index 7fc7fd29..c61227b9 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
@@ -131,11 +131,11 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
int preCount = fsm.client.getSink().getRecentEvents().length;
assertTrue(fsm.status());
- assertEquals(preCount, fsm.client.getSink().getRecentEvents().length);
+ assertEquals(preCount + 1, fsm.client.getSink().getRecentEvents().length);
fsm.start(controllerSupport.getController());
assertTrue(fsm.status());
- assertEquals(preCount + 1, fsm.client.getSink().getRecentEvents().length);
+ assertEquals(preCount + 2, fsm.client.getSink().getRecentEvents().length);
fsm.stop(controllerSupport.getController());
fsm.shutdown();
@@ -207,7 +207,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
assertTrue(fsm.update(update));
assertEquals(qlength + 1, fsm.client.getSink().getRecentEvents().length);
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
PdpStatus cachedStatus = new StandardCoder()
.decode(fsm.client.getSink().getRecentEvents()[qlength], PdpStatus.class);
assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -221,7 +221,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
assertTrue(fsm.update(update));
assertEquals(qlength + 2, fsm.client.getSink().getRecentEvents().length);
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
cachedStatus = new StandardCoder()
.decode(fsm.client.getSink().getRecentEvents()[qlength + 1], PdpStatus.class);
assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -237,7 +237,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
update.setPolicies(Collections.emptyList());
assertTrue(fsm.update(update));
assertEquals(qlength + 3, fsm.client.getSink().getRecentEvents().length);
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
cachedStatus = new StandardCoder()
.decode(fsm.client.getSink().getRecentEvents()[qlength + 2], PdpStatus.class);
assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -251,7 +251,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
update.setPolicies(Arrays.asList(toscaPolicyRestartV1));
assertTrue(fsm.update(update));
assertEquals(qlength + 4, fsm.client.getSink().getRecentEvents().length);
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
cachedStatus = new StandardCoder()
.decode(fsm.client.getSink().getRecentEvents()[qlength + 3], PdpStatus.class);
assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -269,7 +269,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
update.setPolicies(Arrays.asList(toscaPolicyRestartV2));
assertTrue(fsm.update(update));
assertEquals(qlength + 5, fsm.client.getSink().getRecentEvents().length);
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
cachedStatus = new StandardCoder()
.decode(fsm.client.getSink().getRecentEvents()[qlength + 4], PdpStatus.class);
assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -288,7 +288,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
update.setPolicies(Arrays.asList(toscaPolicyRestartV2, toscaPolicyFirewall));
assertTrue(fsm.update(update));
assertEquals(qlength + 6, fsm.client.getSink().getRecentEvents().length);
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
cachedStatus = new StandardCoder()
.decode(fsm.client.getSink().getRecentEvents()[qlength + 5], PdpStatus.class);
assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
index 60d71d0c..b42e0fb6 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
@@ -74,8 +74,10 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
public void testController() {
fsm.start(controllerSupport.getController());
assertSame(controllerSupport.getController(),
- fsm.getController(new ToscaPolicyTypeIdentifier(ControllerSupport.POLICY_TYPE,
- ControllerSupport.POLICY_TYPE_VERSION)));
+ ((PolicyTypeDroolsController) fsm.getController(
+ new ToscaPolicyTypeIdentifier(
+ ControllerSupport.POLICY_TYPE, ControllerSupport.POLICY_TYPE_VERSION)))
+ .getController());
fsm.stop(controllerSupport.getController());
assertNull(fsm.getController(new ToscaPolicyTypeIdentifier(ControllerSupport.POLICY_TYPE,
@@ -121,7 +123,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
public void testStatus() {
assertTrue(fsm.client.getSink().isAlive());
assertTrue(fsm.status());
- assertSame(0, fsm.client.getSink().getRecentEvents().length);
+ assertSame(1, fsm.client.getSink().getRecentEvents().length);
fsm.start(controllerSupport.getController());
@@ -179,7 +181,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals("z", fsm.getSubgroup());
assertBasicPassive();
- assertTrue(fsm.policyTypesMap.isEmpty());
+ assertEquals(2, fsm.policyTypesMap.size());
assertTrue(fsm.policiesMap.isEmpty());
update.setPdpGroup(null);
@@ -192,7 +194,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertNull(fsm.getSubgroup());
assertBasicPassive();
- assertTrue(fsm.policyTypesMap.isEmpty());
+ assertEquals(2, fsm.policyTypesMap.size());
assertTrue(fsm.policiesMap.isEmpty());
update.setPdpGroup("A");
@@ -205,15 +207,15 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("a", fsm.getSubgroup());
assertBasicPassive();
- assertTrue(fsm.policyTypesMap.isEmpty());
+ assertEquals(2, fsm.policyTypesMap.size());
assertTrue(fsm.policiesMap.isEmpty());
fsm.start(controllerSupport.getController());
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
assertTrue(fsm.policiesMap.isEmpty());
assertTrue(fsm.update(update));
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
assertEquals(1, fsm.policiesMap.size());
assertEquals(fsm.policiesMap.get(toscaPolicy.getIdentifier()), toscaPolicy);
assertEquals(PdpState.PASSIVE, fsm.state());
@@ -227,7 +229,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
update.setPdpSubgroup(null);
update.setPolicies(Collections.emptyList());
assertTrue(fsm.update(update));
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
assertEquals(0, fsm.policiesMap.size());
assertEquals(PdpState.PASSIVE, fsm.state());
assertEquals(interval, fsm.getStatusTimerSeconds());
@@ -267,11 +269,11 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
controllerSupport.getController().start();
fsm.start(controllerSupport.getController());
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
assertTrue(fsm.policiesMap.isEmpty());
assertTrue(fsm.update(update));
- assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(3, fsm.policyTypesMap.size());
assertEquals(1, fsm.policiesMap.size());
assertEquals(fsm.policiesMap.get(toscaPolicy.getIdentifier()), toscaPolicy);
assertEquals(PdpState.PASSIVE, fsm.state());