aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src/test
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2019-09-04 21:26:56 -0500
committerjhh <jorge.hernandez-herrero@att.com>2019-09-04 21:32:56 -0500
commit5d526310e8d2f3c729af4c6a8b1eec0f0a79008d (patch)
tree25860a90c164b4c581cbdd5eaa8acc04e4e95629 /policy-management/src/test
parent1281abe9fdb4a2e0a4f4880b8e0b9b375a0b9a3d (diff)
Split Engine start method into "start" and "open"
"open" meaning to open external configuration interfaces to external provisioning systems. Issue-ID: POLICY-2055 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Ic984f0ebccd088503b6b13620c3b80ed8e640899 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'policy-management/src/test')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java71
1 files changed, 63 insertions, 8 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
index e9f0b48a..5e0ead9d 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
@@ -670,11 +670,11 @@ public class PolicyEngineManagerTest {
// servlet wait fails - still does everything
testStart(false, () -> when(server1.waitedStart(anyLong())).thenReturn(false));
- // topic source fails to start - still does everything
- testStart(false, () -> when(source1.start()).thenReturn(false));
+ // topic source is not started with start
+ testStart(true, () -> when(source1.start()).thenReturn(false));
- // topic sink fails to start - still does everything
- testStart(false, () -> when(sink1.start()).thenReturn(false));
+ // topic sink is not started with start
+ testStart(true, () -> when(sink1.start()).thenReturn(false));
// controller fails to start - still does everything
testStart(false, () -> when(controller.start()).thenReturn(false));
@@ -735,11 +735,11 @@ public class PolicyEngineManagerTest {
verify(server1).waitedStart(anyLong());
verify(server2).waitedStart(anyLong());
- verify(source1).start();
- verify(source2).start();
+ verify(source1, never()).start();
+ verify(source2, never()).start();
- verify(sink1).start();
- verify(sink2).start();
+ verify(sink1, never()).start();
+ verify(sink2, never()).start();
verify(controller).start();
verify(controller2).start();
@@ -1484,6 +1484,61 @@ public class PolicyEngineManagerTest {
}
@Test
+ public void testOpen() throws Throwable {
+ when(prov1.beforeOpen(mgr)).thenThrow(new RuntimeException(EXPECTED));
+ when(prov1.afterOpen(mgr)).thenThrow(new RuntimeException(EXPECTED));
+
+ assertTrue(mgr.lock());
+ assertThatIllegalStateException().isThrownBy(() -> mgr.open());
+ unsuccessfulOpen();
+
+ assertTrue(mgr.unlock());
+ unsuccessfulOpen();
+
+ setUp();
+ mgr.configure(properties);
+ assertTrue(mgr.start());
+
+ verify(source1, never()).start();
+ verify(source2, never()).start();
+
+ assertTrue(mgr.open());
+
+ verify(prov1).beforeOpen(mgr);
+ verify(prov2).beforeOpen(mgr);
+
+ verify(source1).start();
+ verify(source2).start();
+
+ verify(prov1).afterOpen(mgr);
+ verify(prov2).afterOpen(mgr);
+
+ when(source1.start()).thenReturn(false);
+ assertFalse(mgr.open());
+ when(source1.start()).thenReturn(true);
+
+ when(sink1.start()).thenReturn(false);
+ assertFalse(mgr.open());
+ when(sink1.start()).thenReturn(true);
+
+ assertTrue(mgr.open());
+ }
+
+ private void unsuccessfulOpen() {
+ verify(prov1).beforeOpen(mgr);
+ verify(prov2).beforeOpen(mgr);
+
+ verify(prov1, never()).afterOpen(mgr);
+ verify(prov2, never()).afterOpen(mgr);
+
+ verify(source1, never()).start();
+ verify(source2, never()).start();
+
+ verify(sink1, never()).start();
+ verify(sink2, never()).start();
+ }
+
+ @Test
public void testControllerConfig() throws Exception {
mgr.configure(properties);
assertTrue(mgr.configure(pdpConfig));