diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2018-10-08 11:59:25 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-10-08 11:59:25 +0000 |
commit | fb0ea8cd5d4a7b4a1c9731b45839be1f291455bf (patch) | |
tree | 4674e4949b0c1379899dc38d23aa41513496c45b /services | |
parent | 5b416f07f49e719d1e0ad1f0830588c1d19a17dd (diff) | |
parent | 7a5e85e17d58e4d75812a3015adc7cbc06e4e49c (diff) |
Merge "Unit test for Apex engine"
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()); } } |