diff options
author | liamfallon <liam.fallon@est.tech> | 2019-07-10 19:44:39 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-07-10 19:44:39 +0000 |
commit | adf67497761295115dc75b525500d687518fc4fd (patch) | |
tree | c5c5b5e737ac08256e9f782b5dccbd3ddc08d3c3 /core/core-engine/src/test | |
parent | 5c384fb2888029c2babb859c30318749e1ce828c (diff) |
Add integration tests for executor properties
Added integration test that sets properties in a dummy plugin and amends
them in tasks in a policy. Variosu tests added to check combinations of
where properties are set in plugins or in tasks or both.
Implementaiton changed to:
- Always pass in a Properies object, the properties object coming into
the policy cannot be null because the task/TSL/SFL may wish to set it
- Fix a bug where the properties were not passed from the ApexEvent to
the engine event in the ApexEventUnmarshaller class
Issue-ID: POLICY-1743
Change-Id: I6aa152b28d46cf3cc6fa56a1a95b76a8e55f5a49
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'core/core-engine/src/test')
3 files changed, 52 insertions, 21 deletions
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java index a94fe9e80..6fb28bca8 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import java.util.Map; +import java.util.Properties; import org.junit.Before; import org.junit.Test; @@ -117,19 +118,25 @@ public class StateFinalizerExecutorTest { } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception ex) { assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage()); } try { executor.executePre(0, null, incomingEvent); + } catch (Exception ex) { + assertEquals("executionProperties is marked @NonNull but is null", ex.getMessage()); + } + + try { + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } try { - executor.execute(0, null, incomingEvent); + executor.execute(0, new Properties(), incomingEvent); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute() not implemented on abstract StateFinalizerExecutionContext class, " @@ -154,7 +161,7 @@ public class StateFinalizerExecutorTest { } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -168,7 +175,7 @@ public class StateFinalizerExecutorTest { } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception ex) { fail("test should not throw an exception"); } @@ -184,7 +191,7 @@ public class StateFinalizerExecutorTest { } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception ex) { fail("test should not throw an exception"); } diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java index a4a0f21ec..eb2d11177 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java @@ -26,6 +26,7 @@ import static org.junit.Assert.fail; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Properties; import org.junit.Before; import org.junit.Test; @@ -158,24 +159,32 @@ public class TaskExecutorTest { Map<String, Object> incomingFields = new LinkedHashMap<>(); try { - executor.executePre(0, null, incomingFields); + executor.executePre(0, new Properties(), incomingFields); } catch (Exception ex) { assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage()); } incomingFields.put("InField0", "A Value"); try { - executor.executePre(0, null, incomingFields); + executor.executePre(0, new Properties(), incomingFields); } catch (Exception e) { fail("test should not throw an exception"); } try { - executor.execute(0, null, incomingFields); + executor.execute(0, new Properties(), incomingFields); + fail("test should throw an exception"); + } catch (Exception ex) { + assertEquals("execute() not implemented on abstract TaskExecutor class, only on its subclasses", + ex.getMessage()); + } + + try { + executor.execute(0, new Properties(), incomingFields); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute() not implemented on abstract TaskExecutor class, only on its subclasses", - ex.getMessage()); + ex.getMessage()); } try { @@ -183,7 +192,7 @@ public class TaskExecutorTest { fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute-post: task logic execution failure on task \"Task0\" in model Context:0.0.1", - ex.getMessage()); + ex.getMessage()); } executor.getExecutionContext().setMessage("Execution message"); @@ -192,7 +201,7 @@ public class TaskExecutorTest { fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute-post: task logic execution failure on task \"Task0\" in model Context:0.0.1, " - + "user message: Execution message", ex.getMessage()); + + "user message: Execution message", ex.getMessage()); } try { @@ -216,7 +225,7 @@ public class TaskExecutorTest { fail("test should throw an exception"); } catch (Exception ex) { assertEquals("task output fields \"[BadExtraField]\" are unwanted for task \"Task0:0.0.1\"", - ex.getMessage()); + ex.getMessage()); } executor.getExecutionContext().outFields.remove("BadExtraField"); @@ -247,5 +256,12 @@ public class TaskExecutorTest { } catch (Exception ex) { fail("test should not throw an exception"); } + + try { + executor.executePre(0, null, incomingFields); + fail("test should throw an exception"); + } catch (Exception ex) { + assertEquals("executionProperties is marked @NonNull but is null", ex.getMessage()); + } } } diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java index 2ee308977..8e907e12a 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java @@ -25,6 +25,7 @@ import static org.junit.Assert.fail; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Properties; import org.junit.Before; import org.junit.Test; @@ -127,19 +128,19 @@ public class TaskSelectExecutorTest { } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception ex) { assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage()); } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } try { - executor.execute(0, null, incomingEvent); + executor.execute(0, new Properties(), incomingEvent); fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute() not implemented on class", ex.getMessage()); @@ -150,7 +151,7 @@ public class TaskSelectExecutorTest { fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute-post: task selection logic failed on state \"State0Parent:0.0.1:Parent:State0\"", - ex.getMessage()); + ex.getMessage()); } executor.getExecutionContext().setMessage("Execution message"); @@ -159,11 +160,11 @@ public class TaskSelectExecutorTest { fail("test should throw an exception"); } catch (Exception ex) { assertEquals("execute-post: task selection logic failed on state \"State0Parent:0.0.1:Parent:State0\", " - + "user message: Execution message", ex.getMessage()); + + "user message: Execution message", ex.getMessage()); } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } @@ -176,7 +177,7 @@ public class TaskSelectExecutorTest { } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } @@ -187,11 +188,11 @@ public class TaskSelectExecutorTest { fail("test should throw an exception"); } catch (Exception ex) { assertEquals("task \"IDontExist:0.0.0\" returned by task selection logic not defined " - + "on state \"State0Parent:0.0.1:Parent:State0\"", ex.getMessage()); + + "on state \"State0Parent:0.0.1:Parent:State0\"", ex.getMessage()); } try { - executor.executePre(0, null, incomingEvent); + executor.executePre(0, new Properties(), incomingEvent); } catch (Exception e) { fail("test should not throw an exception"); } @@ -204,5 +205,12 @@ public class TaskSelectExecutorTest { } catch (Exception e) { fail("test should not throw an exception"); } + + try { + executor.executePre(0, null, incomingEvent); + fail("test should throw an exception"); + } catch (Exception ex) { + assertEquals("executionProperties is marked @NonNull but is null", ex.getMessage()); + } } } |