aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-engine/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-07-10 19:44:39 +0000
committerliamfallon <liam.fallon@est.tech>2019-07-10 19:44:39 +0000
commitadf67497761295115dc75b525500d687518fc4fd (patch)
treec5c5b5e737ac08256e9f782b5dccbd3ddc08d3c3 /services/services-engine/src
parent5c384fb2888029c2babb859c30318749e1ce828c (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 'services/services-engine/src')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java10
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java3
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java3
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java7
5 files changed, 15 insertions, 10 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
index b820ee3fd..7828960b4 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
@@ -124,7 +124,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
private long executionId = ApexEvent.getNextExecutionId();
// Event related properties used during processing of this event
- private Properties executionProperties;
+ private Properties executionProperties = new Properties();
// A string holding a message that indicates why processing of this event threw an exception
private String exceptionMessage;
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
index bd0753d02..14486614c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
@@ -5,15 +5,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -84,8 +84,8 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter {
final ApexEvent apexEvent = new ApexEvent(axEvent.getKey().getName(), axEvent.getKey().getVersion(),
axEvent.getNameSpace(), axEvent.getSource(), axEvent.getTarget());
- // Copy the ExecutionID from the EnEvent into the ApexEvent
apexEvent.setExecutionId(enEvent.getExecutionId());
+ apexEvent.setExecutionProperties(enEvent.getExecutionProperties());
// Copy he exception message to the Apex event if it is set
if (enEvent.getExceptionMessage() != null) {
@@ -126,8 +126,8 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter {
// Set the data on the engine event
enEvent.putAll(apexEvent);
- // copy the ExecutionID from the ApexEvent into the EnEvent
enEvent.setExecutionId(apexEvent.getExecutionId());
+ enEvent.setExecutionProperties(apexEvent.getExecutionProperties());
return enEvent;
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
index da945209b..4581b179c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
@@ -22,6 +22,7 @@ package org.onap.policy.apex.service.engine.event.impl.eventrequestor;
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -177,7 +178,7 @@ public class EventRequestorConsumer implements ApexEventConsumer, Runnable {
}
// Send the event into Apex
- eventReceiver.receiveEvent(null, eventObject);
+ eventReceiver.receiveEvent(new Properties(), eventObject);
eventsReceived++;
} catch (final InterruptedException e) {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java
index e99663c9e..7366528c7 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/ApexFileEventConsumer.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicLong;
import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
@@ -195,7 +196,7 @@ public class ApexFileEventConsumer implements ApexEventConsumer, Runnable {
// Process the event from the text block if there is one there
if (textBlock.getText() != null) {
- eventReceiver.receiveEvent(getNextExecutionId(), null, textBlock.getText());
+ eventReceiver.receiveEvent(getNextExecutionId(), new Properties(), textBlock.getText());
}
}
while (!textBlock.isEndOfText());
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
index f03b58ca2..8708e97e6 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
@@ -27,6 +27,8 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
+import lombok.NonNull;
+
import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
@@ -182,7 +184,8 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
* {@inheritDoc}.
*/
@Override
- public void receiveEvent(final Properties executionProperties, final Object event) throws ApexEventException {
+ public void receiveEvent(@NonNull final Properties executionProperties, final Object event)
+ throws ApexEventException {
receiveEvent(0, executionProperties, event, true);
}
@@ -190,7 +193,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
* {@inheritDoc}.
*/
@Override
- public void receiveEvent(final long executionId, final Properties executionProperties, final Object event)
+ public void receiveEvent(final long executionId, @NonNull final Properties executionProperties, final Object event)
throws ApexEventException {
receiveEvent(executionId, executionProperties, event, false);
}