aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java27
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java3
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java8
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java3
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java33
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java3
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java14
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java3
-rw-r--r--plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java7
9 files changed, 65 insertions, 36 deletions
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
index faae7527c..9359e4ef9 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
@@ -61,7 +60,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
public void init(final EventProtocolParameters parameters) {
// Check and get the YAML parameters
if (!(parameters instanceof YamlEventProtocolParameters)) {
- final String errorMessage = "specified consumer properties are not applicable to the YAML event protocol";
+ final var errorMessage = "specified consumer properties are not applicable to the YAML event protocol";
throw new ApexEventRuntimeException(errorMessage);
}
@@ -85,13 +84,13 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
throw new ApexEventException(errorMessage);
}
- final String yamlEventString = (String) eventObject;
+ final var yamlEventString = (String) eventObject;
// The list of events we will return
final List<ApexEvent> eventList = new ArrayList<>();
// Convert the YAML document string into an object
- Object yamlObject = new Yaml().load(yamlEventString);
+ var yamlObject = new Yaml().load(yamlEventString);
// If the incoming YAML did not create a map it is a primitive type or a collection so we
// convert it into a map for processing
@@ -161,7 +160,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
}
// Use Snake YAML to convert the APEX event to YAML
- Yaml yaml = new Yaml();
+ var yaml = new Yaml();
return yaml.dumpAs(yamlMap, null, FlowStyle.BLOCK);
}
@@ -175,7 +174,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
*/
private ApexEvent yamlMap2ApexEvent(final String eventName, final Map<?, ?> yamlMap) throws ApexEventException {
// Process the mandatory Apex header
- final ApexEvent apexEvent = processApexEventHeader(eventName, yamlMap);
+ final var apexEvent = processApexEventHeader(eventName, yamlMap);
// Get the event definition for the event from the model service
final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(apexEvent.getName(),
@@ -197,7 +196,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
if (fieldValue != null) {
// Get the schema helper
- final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory().createSchemaHelper(eventField.getKey(),
+ final var fieldSchemaHelper = new SchemaHelperFactory().createSchemaHelper(eventField.getKey(),
eventField.getSchema());
apexEvent.put(fieldName, fieldSchemaHelper.createNewInstance(fieldValue));
} else {
@@ -219,7 +218,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
*/
private ApexEvent processApexEventHeader(final String eventName, final Map<?, ?> yamlMap)
throws ApexEventException {
- String name = getYamlStringField(yamlMap, ApexEvent.NAME_HEADER_FIELD, yamlPars.getNameAlias(),
+ var name = getYamlStringField(yamlMap, ApexEvent.NAME_HEADER_FIELD, yamlPars.getNameAlias(),
ApexEvent.NAME_REGEXP, false);
// Check that an event name has been specified
@@ -239,7 +238,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
// Now, find the event definition in the model service. If version is null, the newest event
// definition in the model service is used
- String version = getYamlStringField(yamlMap, ApexEvent.VERSION_HEADER_FIELD, yamlPars.getVersionAlias(),
+ var version = getYamlStringField(yamlMap, ApexEvent.VERSION_HEADER_FIELD, yamlPars.getVersionAlias(),
ApexEvent.VERSION_REGEXP, false);
final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(name, version);
if (eventDefinition == null) {
@@ -270,7 +269,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
*/
private String getEventHeaderNamespace(final Map<?, ?> yamlMap, String name, final AxEvent eventDefinition) {
// Check the name space is OK if it is defined, if not, use the name space from the model
- String namespace = getYamlStringField(yamlMap, ApexEvent.NAMESPACE_HEADER_FIELD, yamlPars.getNameSpaceAlias(),
+ var namespace = getYamlStringField(yamlMap, ApexEvent.NAMESPACE_HEADER_FIELD, yamlPars.getNameSpaceAlias(),
ApexEvent.NAMESPACE_REGEXP, false);
if (namespace != null) {
if (!namespace.equals(eventDefinition.getNameSpace())) {
@@ -293,7 +292,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
*/
private String getEventHeaderSource(final Map<?, ?> yamlMap, final AxEvent eventDefinition) {
// For source, use the defined source only if the source is not found on the incoming event
- String source = getYamlStringField(yamlMap, ApexEvent.SOURCE_HEADER_FIELD, yamlPars.getSourceAlias(),
+ var source = getYamlStringField(yamlMap, ApexEvent.SOURCE_HEADER_FIELD, yamlPars.getSourceAlias(),
ApexEvent.SOURCE_REGEXP, false);
if (source == null) {
source = eventDefinition.getSource();
@@ -310,7 +309,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
*/
private String getHeaderTarget(final Map<?, ?> yamlMap, final AxEvent eventDefinition) {
// For target, use the defined source only if the source is not found on the incoming event
- String target = getYamlStringField(yamlMap, ApexEvent.TARGET_HEADER_FIELD, yamlPars.getTargetAlias(),
+ var target = getYamlStringField(yamlMap, ApexEvent.TARGET_HEADER_FIELD, yamlPars.getTargetAlias(),
ApexEvent.TARGET_REGEXP, false);
if (target == null) {
target = eventDefinition.getTarget();
@@ -345,7 +344,7 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
+ yamlField.getClass().getName() + "\" is not a string value");
}
- final String fieldValueString = (String) yamlField;
+ final var fieldValueString = (String) yamlField;
// Is regular expression checking required
if (fieldRegexp == null) {
diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
index 2ccddcf0f..736249efd 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +77,7 @@ public class JavaTaskExecutor extends TaskExecutor {
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ public Map<String, Map<String, Object>> execute(final long executionId, final Properties executionProperties,
final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
executePre(executionId, executionProperties, incomingFields);
diff --git a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
index 7f263245c..96bc6bb3d 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +29,7 @@ import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +40,7 @@ import org.onap.policy.apex.context.parameters.LockManagerParameters;
import org.onap.policy.apex.context.parameters.PersistorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
+import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.concepts.AxTask;
import org.onap.policy.common.parameters.ParameterService;
@@ -83,7 +86,8 @@ public class JavaTaskExecutorTest {
assertThatThrownBy(jte::prepare)
.hasMessage("instantiation error on Java class \"\"");
task.getTaskLogic().setLogic("java.lang.String");
-
+ task.setInputEvent(new AxEvent());
+ task.setOutputEvents(new TreeMap<>());
jte.prepare();
assertThatThrownBy(() -> jte.execute(-1, new Properties(), null))
@@ -96,7 +100,7 @@ public class JavaTaskExecutorTest {
assertThatThrownBy(() -> jte.execute(-1, new Properties(), incomingParameters))
.hasMessage("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0");
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters);
+ Map<String, Map<String, Object>> returnMap = jte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
index a25dca0c6..f88e3ef1e 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutor.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,7 +67,7 @@ public class JavascriptTaskExecutor extends TaskExecutor {
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ public Map<String, Map<String, Object>> execute(final long executionId, final Properties executionProperties,
final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
executePre(executionId, executionProperties, incomingFields);
boolean result = javascriptExecutor.execute(getExecutionContext());
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 991c89bcb..fbf7db864 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +30,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.TreeMap;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -47,6 +49,8 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
+import org.onap.policy.apex.model.eventmodel.concepts.AxField;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.concepts.AxTask;
import org.onap.policy.common.parameters.ParameterService;
@@ -123,7 +127,8 @@ public class JavascriptTaskExecutorTest {
jte.execute(-1, props, null);
}).isInstanceOf(NullPointerException.class);
jte.cleanUp();
-
+ task.setInputEvent(new AxEvent());
+ task.setOutputEvents(new TreeMap<>());
task.getTaskLogic().setLogic("var returnValue = false;\nreturnValue;");
Map<String, Object> incomingParameters = new HashMap<>();
@@ -138,13 +143,14 @@ public class JavascriptTaskExecutorTest {
task.getTaskLogic().setLogic("var returnValue = true;\nreturnValue;");
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters);
+ Map<String, Map<String, Object>> returnMap = jte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
}
@Test
public void testJavascriptTaskExecutorLogic() throws Exception {
+
JavascriptTaskExecutor jte = new JavascriptTaskExecutor();
assertNotNull(jte);
@@ -160,16 +166,25 @@ public class JavascriptTaskExecutorTest {
internalContext.getContextAlbums().put(contextAlbum.getKey(), contextAlbum);
task.getContextAlbumReferences().add(contextAlbum.getKey());
- task.getOutputFields().put("par0", null);
- task.getOutputFields().put("par1", null);
+ String parKey0 = "par0";
+ task.getOutputFields().put(parKey0, null);
+ String parKey1 = "par1";
+ task.getOutputFields().put(parKey1, null);
jte.setContext(null, task, internalContext);
Map<String, Object> incomingParameters = new HashMap<>();
- incomingParameters.put("par0", "value0");
+ incomingParameters.put(parKey0, "value0");
- task.getTaskLogic().setLogic(TextFileUtils.getTextFileAsString("src/test/resources/javascript/TestLogic00.js"));
+ AxEvent inEvent = new AxEvent();
+ inEvent.setParameterMap(Map.of(parKey0, new AxField()));
+ task.setInputEvent(inEvent);
+ AxEvent outEvent = new AxEvent();
+ outEvent.setParameterMap(Map.of(parKey0, new AxField(), parKey1, new AxField()));
+ final String eventName = "event1";
+ task.setOutputEvents(Map.of(eventName, outEvent));
+ task.getTaskLogic().setLogic(TextFileUtils.getTextFileAsString("src/test/resources/javascript/TestLogic00.js"));
jte.prepare();
jte.execute(-1, new Properties(), incomingParameters);
jte.cleanUp();
@@ -177,11 +192,11 @@ public class JavascriptTaskExecutorTest {
task.getTaskLogic().setLogic(TextFileUtils.getTextFileAsString("src/test/resources/javascript/TestLogic01.js"));
jte.prepare();
- Map<String, Object> outcomingParameters = jte.execute(-1, new Properties(), incomingParameters);
+ Map<String, Map<String, Object>> outcomingParameters = jte.execute(-1, new Properties(), incomingParameters);
jte.cleanUp();
- assertEquals("returnVal0", outcomingParameters.get("par0"));
- assertEquals("returnVal1", outcomingParameters.get("par1"));
+ assertEquals("returnVal0", outcomingParameters.get(eventName).get(parKey0));
+ assertEquals("returnVal1", outcomingParameters.get(eventName).get(parKey1));
}
private ContextAlbum createTestContextAlbum() throws ContextException {
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java
index 02504c670..aa5700433 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,7 +81,7 @@ public class JrubyTaskExecutor extends TaskExecutor {
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ public Map<String, Map<String, Object>> execute(final long executionId, final Properties executionProperties,
final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
executePre(executionId, executionProperties, incomingFields);
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 e2785d816..0cc476425 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -39,6 +40,7 @@ import org.onap.policy.apex.context.parameters.LockManagerParameters;
import org.onap.policy.apex.context.parameters.PersistorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
+import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.concepts.AxTask;
import org.onap.policy.common.parameters.ParameterService;
@@ -91,7 +93,8 @@ public class JrubyTaskExecutorTest {
AxTask task = new AxTask();
ApexInternalContext internalContext = null;
internalContext = new ApexInternalContext(new AxPolicyModel());
-
+ task.setInputEvent(new AxEvent());
+ task.setOutputEvents(new TreeMap<>());
jte.setContext(null, task, internalContext);
jte.prepare();
@@ -102,14 +105,13 @@ public class JrubyTaskExecutorTest {
final String jrubyLogic = "if executor.executionId == -1" + "\n return false" + "\n else " + "\n return true"
+ "\n end";
task.getTaskLogic().setLogic(jrubyLogic);
-
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters);
+ Map<String, Map<String, Object>> returnMap = jte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
jte.prepare();
- Map<String, Object> returnMap1 = jte.execute(0, new Properties(), incomingParameters);
+ Map<String, Map<String, Object>> returnMap1 = jte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap1.size());
jte.cleanUp();
}
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java
index 179462bb1..07a287f4d 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,7 +78,7 @@ public class MvelTaskExecutor extends TaskExecutor {
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ public Map<String, Map<String, Object>> execute(final long executionId, final Properties executionProperties,
final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
executePre(executionId, executionProperties, incomingFields);
diff --git a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
index a4d2cbf2b..3d59c4b21 100644
--- a/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-mvel/src/test/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutorTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +29,7 @@ import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +40,7 @@ import org.onap.policy.apex.context.parameters.LockManagerParameters;
import org.onap.policy.apex.context.parameters.PersistorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
+import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.concepts.AxTask;
import org.onap.policy.common.parameters.ParameterService;
@@ -77,6 +80,8 @@ public class MvelTaskExecutorTest {
AxTask task = new AxTask();
ApexInternalContext internalContext = null;
internalContext = new ApexInternalContext(new AxPolicyModel());
+ task.setInputEvent(new AxEvent());
+ task.setOutputEvents(new TreeMap<>());
mte.setContext(null, task, internalContext);
task.getTaskLogic().setLogic("x > 1 2 ()");
@@ -97,7 +102,7 @@ public class MvelTaskExecutorTest {
.hasMessage("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0");
mte.prepare();
- Map<String, Object> returnMap = mte.execute(0, new Properties(), incomingParameters);
+ Map<String, Map<String, Object>> returnMap = mte.execute(0, new Properties(), incomingParameters);
assertEquals(0, returnMap.size());
mte.cleanUp();
}