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 /plugins/plugins-executor/plugins-executor-javascript/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 'plugins/plugins-executor/plugins-executor-javascript/src/test')
3 files changed, 19 insertions, 13 deletions
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java index d42ad6cb9..724c70bd2 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptStateFinalizerExecutorTest.java @@ -26,6 +26,8 @@ import static org.junit.Assert.fail; import java.util.HashMap; import java.util.Map; +import java.util.Properties; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -117,7 +119,7 @@ public class JavascriptStateFinalizerExecutorTest { Map<String, Object> incomingParameters1 = new HashMap<>(); try { - jsfe.execute(-1, null, incomingParameters1); + jsfe.execute(-1, new Properties(), incomingParameters1); fail("test should throw an exception here"); } catch (Exception jteException) { assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"", @@ -141,7 +143,7 @@ public class JavascriptStateFinalizerExecutorTest { + "var returnValue = new returnValueType(true);}"); try { jsfe.prepare(); - jsfe.execute(-1, null, event); + jsfe.execute(-1, new Properties(), event); fail("test should throw an exception here"); } catch (Exception jtseException) { assertEquals( @@ -153,7 +155,7 @@ public class JavascriptStateFinalizerExecutorTest { state.getStateOutputs().put("SelectedOutputIsMe", null); try { jsfe.prepare(); - String stateOutput = jsfe.execute(0, null, event); + String stateOutput = jsfe.execute(0, new Properties(), event); assertEquals("SelectedOutputIsMe", stateOutput); jsfe.cleanUp(); } catch (Exception jtseException) { diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java index 20e758fae..fed293921 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java @@ -26,6 +26,8 @@ import static org.junit.Assert.fail; import java.util.HashMap; import java.util.Map; +import java.util.Properties; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -95,7 +97,7 @@ public class JavascriptTaskExecutorTest { Map<String, Object> incomingParameters2 = new HashMap<>(); try { - jte.execute(-1, null, incomingParameters2); + jte.execute(-1, new Properties(), incomingParameters2); fail("test should throw an exception here"); } catch (Exception jteException) { assertEquals("task logic failed to run for task \"NULL:0.0.0\"", jteException.getMessage()); @@ -110,7 +112,7 @@ public class JavascriptTaskExecutorTest { } try { - jte.execute(-1, null, null); + jte.execute(-1, new Properties(), null); fail("test should throw an exception here"); } catch (Exception jteException) { assertEquals(java.lang.NullPointerException.class, jteException.getClass()); @@ -118,7 +120,7 @@ public class JavascriptTaskExecutorTest { Map<String, Object> incomingParameters = new HashMap<>(); try { - jte.execute(-1, null, incomingParameters); + jte.execute(-1, new Properties(), incomingParameters); fail("test should throw an exception here"); } catch (Exception jteException) { assertEquals("execute: task logic failed to set a return value for task \"NULL:0.0.0\"", @@ -129,7 +131,7 @@ public class JavascriptTaskExecutorTest { + "var returnValue = new returnValueType(false); "); try { jte.prepare(); - jte.execute(-1, null, incomingParameters); + jte.execute(-1, new Properties(), incomingParameters); fail("test should throw an exception here"); } catch (Exception jteException) { assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0", @@ -140,7 +142,7 @@ public class JavascriptTaskExecutorTest { + "var returnValue = new returnValueType(true); "); try { jte.prepare(); - Map<String, Object> returnMap = jte.execute(0, null, incomingParameters); + Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters); assertEquals(0, returnMap.size()); jte.cleanUp(); } catch (Exception jteException) { diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java index 8efbc6241..9a705020c 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java @@ -24,6 +24,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import java.util.Properties; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -98,7 +100,7 @@ public class JavascriptTaskSelectExecutorTest { AxEvent axEvent1 = new AxEvent(new AxArtifactKey("Event", "0.0.1")); EnEvent event1 = new EnEvent(axEvent1); try { - jtse.execute(-1, null, event1); + jtse.execute(-1, new Properties(), event1); fail("test should throw an exception here"); } catch (Exception jtseException) { assertEquals( @@ -115,7 +117,7 @@ public class JavascriptTaskSelectExecutorTest { } try { - jtse.execute(-1, null, null); + jtse.execute(-1, new Properties(), null); fail("test should throw an exception here"); } catch (Exception jtseException) { assertEquals(java.lang.NullPointerException.class, jtseException.getClass()); @@ -124,7 +126,7 @@ public class JavascriptTaskSelectExecutorTest { AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1")); EnEvent event = new EnEvent(axEvent); try { - jtse.execute(-1, null, event); + jtse.execute(-1, new Properties(), event); fail("test should throw an exception here"); } catch (Exception jtseException) { assertEquals( @@ -136,7 +138,7 @@ public class JavascriptTaskSelectExecutorTest { + "var returnValue = new returnValueType(false); "); try { jtse.prepare(); - jtse.execute(-1, null, event); + jtse.execute(-1, new Properties(), event); fail("test should throw an exception here"); } catch (Exception jtseException) { assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"", @@ -147,7 +149,7 @@ public class JavascriptTaskSelectExecutorTest { + "var returnValue = new returnValueType(true); "); try { jtse.prepare(); - AxArtifactKey taskKey = jtse.execute(0, null, event); + AxArtifactKey taskKey = jtse.execute(0, new Properties(), event); assertEquals("NULL:0.0.0", taskKey.getId()); jtse.cleanUp(); } catch (Exception jtseException) { |