aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/test/java
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2019-05-13 23:31:44 -0500
committerjhh <jorge.hernandez-herrero@att.com>2019-05-13 23:40:58 -0500
commit9d93b8b4c3577a381e9b5181965d2ceb31e446ed (patch)
tree9f381d2201ed436c4374f1db5aa419ffe5e97f45 /feature-lifecycle/src/test/java
parent6615d0388a27266a0487ed1b334e613e4e80cc6d (diff)
Ensure passive policies are injected when active
Add vim package for testing support Change-Id: Icefcf8a57eea80b4fed97d4c63080f6159d8167a Issue-ID: POLICY-1748 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/test/java')
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java38
1 files changed, 35 insertions, 3 deletions
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 71147e2a..711db028 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
@@ -267,7 +267,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
}
@Test
- public void stateChange() throws CoderException {
+ public void stateChange() throws CoderException, IOException {
/* no name */
PdpStateChange change = new PdpStateChange();
change.setPdpGroup("A");
@@ -282,13 +282,45 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertNull(fsm.getGroup());
assertNull(fsm.getSubgroup());
+ PdpUpdate update = new PdpUpdate();
+ update.setName(NetworkUtil.getHostname());
+ update.setPdpGroup("A");
+ update.setPdpSubgroup("a");
+
+ String rawPolicy =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/tosca-policy-operational-restart.json")));
+ ToscaPolicy toscaPolicy = new StandardCoder().decode(rawPolicy, ToscaPolicy.class);
+ update.setPolicies(Arrays.asList(toscaPolicy));
+
+ controllerSupport.getController().start();
+ fsm.start(controllerSupport.getController());
+ assertEquals(1, fsm.policyTypesMap.size());
+ assertTrue(fsm.policiesMap.isEmpty());
+
+ assertTrue(fsm.update(update));
+ assertEquals(1, fsm.policyTypesMap.size());
+ assertEquals(1, fsm.policiesMap.size());
+ assertEquals(fsm.policiesMap.get(toscaPolicy.getIdentifier()), toscaPolicy);
+ assertEquals(PdpState.PASSIVE, fsm.state());
+ assertEquals("A", fsm.getGroup());
+ assertEquals("a", fsm.getSubgroup());
+ assertBasicPassive();
+ assertEquals(0, controllerSupport.getController().getDrools().factCount("junits"));
+
/* correct name */
change.setName(fsm.getName());
fsm.source.offer(new StandardCoder().encode(change));
assertEquals(PdpState.ACTIVE, fsm.state());
- assertNull(fsm.getGroup());
- assertNull(fsm.getSubgroup());
+ assertEquals("A", fsm.getGroup());
+ assertEquals("a", fsm.getSubgroup());
+
+ await()
+ .atMost(5, TimeUnit.SECONDS)
+ .until(() -> controllerSupport.getController().getDrools().factCount("junits") == 1);
+
+ assertTrue(controllerSupport.getController().getDrools().delete(ToscaPolicy.class));
+ assertEquals(0, controllerSupport.getController().getDrools().factCount("junits"));
fsm.shutdown();
}