diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-10-06 13:33:26 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-10-07 22:45:35 +0100 |
commit | 7a5e85e17d58e4d75812a3015adc7cbc06e4e49c (patch) | |
tree | fa71bf921739219e6b7ebbc2bb2d1f7eb86a2ad8 /services | |
parent | 9cedbd41c0ee3bade89de5d2e1e822cc4e9a36e7 (diff) |
Unit test for Apex engine
Coverage for unit test of engie state and state machine handling.
Added coverage of the facade and executor context classes
Added coverage for executors
Added coverage for the remainder of the core engine
Issue-ID: POLICY-1034
Change-Id: I85c66005dfdffdf2b4ee5672473a3ae4823d0d9c
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'services')
2 files changed, 33 insertions, 9 deletions
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java index 582e61948..f68a4872b 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java @@ -171,7 +171,13 @@ public class EngineServiceImplTest { esImpl.registerActionListener(null, new DummyApexEventListener()); esImpl.registerActionListener("DummyListener", new DummyApexEventListener()); - esImpl.deregisterActionListener(null); + try { + esImpl.deregisterActionListener(null); + fail("test should throw an exception"); + } catch (Exception apEx) { + assertEquals("removeEventListener()<-Engine-0:0.0.1,STOPPED, listenerName is null", apEx.getMessage()); + } + esImpl.deregisterActionListener("DummyListener"); assertEquals(esImpl, esImpl.getEngineServiceEventInterface()); diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java index 5ffda6ed6..1f8052d4a 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java @@ -143,7 +143,7 @@ public class EngineWorkerTest { ParameterService.deregister(ContextParameterConstants.MAIN_GROUP_NAME); ParameterService.deregister(EngineParameterConstants.MAIN_GROUP_NAME); } - + @After public void cleardownTest() { ModelService.clear(); @@ -155,12 +155,31 @@ public class EngineWorkerTest { EngineWorker worker = new EngineWorker(new AxArtifactKey("Worker", "0.0.1"), eventQueue, atFactory); - worker.registerActionListener(null, null); + try { + worker.registerActionListener(null, null); + fail("test should throw an exception"); + } catch (Exception apEx) { + assertEquals("addEventListener()<-Worker:0.0.1,STOPPED, listenerName is null", apEx.getMessage()); + } + worker.registerActionListener("DummyListener", null); - worker.registerActionListener(null, new DummyApexEventListener()); + + try { + worker.registerActionListener(null, new DummyApexEventListener()); + fail("test should throw an exception"); + } catch (Exception apEx) { + assertEquals("addEventListener()<-Worker:0.0.1,STOPPED, listenerName is null", apEx.getMessage()); + } worker.registerActionListener("DummyListener", new DummyApexEventListener()); - worker.deregisterActionListener(null); + + try { + worker.deregisterActionListener(null); + fail("test should throw an exception"); + } catch (Exception apEx) { + assertEquals("removeEventListener()<-Worker:0.0.1,STOPPED, listenerName is null", apEx.getMessage()); + } + worker.deregisterActionListener("DummyListener"); try { @@ -308,7 +327,6 @@ public class EngineWorkerTest { apEx.getMessage()); } } - @Test public void testApexImplModelWIthModel() throws ApexException { @@ -322,7 +340,7 @@ public class EngineWorkerTest { } catch (ApexException apEx) { fail("test should not throw an exception"); } - + eventQueue.add(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget")); try { @@ -352,7 +370,7 @@ public class EngineWorkerTest { assertEquals(AxEngineState.STOPPED, worker.getState()); worker.startAll(); - + assertEquals(AxEngineState.READY, worker.getState()); String status = worker.getStatus(worker.getEngineKeys().iterator().next()); @@ -425,7 +443,7 @@ public class EngineWorkerTest { } catch (ApexException apEx) { fail("test should not throw an exception"); } - + assertNotNull(worker.getApexModelKey()); } } |