From adf67497761295115dc75b525500d687518fc4fd Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 10 Jul 2019 19:44:39 +0000 Subject: 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 --- .../plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java | 6 ++++-- .../policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java | 6 ++++-- .../apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'plugins/plugins-executor/plugins-executor-jruby') diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java index 635430fa1..af34e434d 100644 --- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutorTest.java @@ -25,6 +25,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.lang.reflect.Field; +import java.util.Properties; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -113,7 +115,7 @@ public class JrubyStateFinalizerExecutorTest { } try { - jsfe.execute(-1, null, null); + jsfe.execute(-1, new Properties(), null); fail("test should throw an exception here"); } catch (Exception jtseException) { assertEquals("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" on " @@ -130,7 +132,7 @@ public class JrubyStateFinalizerExecutorTest { 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-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java index 9f83459d8..8b58c38d8 100644 --- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java @@ -27,6 +27,8 @@ import static org.junit.Assert.fail; import java.lang.reflect.Field; 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 JrubyTaskExecutorTest { Map 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-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0", @@ -108,7 +110,7 @@ public class JrubyTaskExecutorTest { try { jte.prepare(); - Map returnMap = jte.execute(0, null, incomingParameters); + Map returnMap = jte.execute(0, new Properties(), incomingParameters); assertEquals(0, returnMap.size()); jte.cleanUp(); } catch (Exception jteException) { diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java index 683c43cb4..def5e1a7f 100644 --- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutorTest.java @@ -25,6 +25,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.lang.reflect.Field; +import java.util.Properties; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -99,7 +101,7 @@ public class JrubyTaskSelectExecutorTest { 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("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"", @@ -112,7 +114,7 @@ public class JrubyTaskSelectExecutorTest { 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) { -- cgit 1.2.3-korg