From 926646d8e5e86e680a119360f93d7bdb46c89435 Mon Sep 17 00:00:00 2001 From: "a.sreekumar" Date: Tue, 22 Jun 2021 15:55:46 +0100 Subject: Changes to support multiple outputs from a state This review addresses two main changes: 1) inputFields and outputFields are not tied to task definition anymore. Instead inputEvent and outputEvents associated to a task is populated as part of the policy state definition, as the state definition have the information anyway. - Clean up of the usage of inputFields and outputFields in task definition will happen in a future review - inputFields and outputFields defined in task definition in policies until honolulu will not make the policy invalid as the changes are done in backward compatible way. 2) Multiple output events can come out of a final state now. - Define another policy state output with the relevant eventName in the command file - In the task logic, create a map to store the fields of the relevant outputEvent, and then just call "executor.addFieldsToOutput()" These 2 steps are enough to send multiple events to relevant components as per the apex configuration. Change-Id: Id88ca402704106404f529e595e1a76f6bf167876 Issue-ID: POLICY-3336 Signed-off-by: a.sreekumar --- .../service/engine/parameters/dummyclasses/DummyTaskExecutor.java | 5 +++-- .../services/onappf/parameters/dummyclasses/DummyTaskExecutor.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'services') diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/DummyTaskExecutor.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/DummyTaskExecutor.java index fb2dea58b..56f0af5c6 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/DummyTaskExecutor.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/DummyTaskExecutor.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. 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. @@ -43,11 +44,11 @@ public class DummyTaskExecutor extends TaskExecutor { } @Override - public Map execute(final long executionId, final Properties executorProperties, + public Map> execute(final long executionId, final Properties executorProperties, final Map newIncomingFields) throws StateMachineException, ContextException { AxArtifactKey event0Key = new AxArtifactKey("Event0:0.0.1"); - return new EnEvent(event0Key); + return Map.of(event0Key.getName(), new EnEvent(event0Key)); } @Override diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskExecutor.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskExecutor.java index d89fd2eb8..01f45a53e 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskExecutor.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskExecutor.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 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. @@ -44,11 +45,11 @@ public class DummyTaskExecutor extends TaskExecutor { } @Override - public Map execute(final long executionId, final Properties executorProperties, + public Map> execute(final long executionId, final Properties executorProperties, final Map newIncomingFields) throws StateMachineException, ContextException { AxArtifactKey event0Key = new AxArtifactKey("Event0:0.0.1"); - return new EnEvent(event0Key); + return Map.of(event0Key.getName(), new EnEvent(event0Key)); } @Override -- cgit 1.2.3-korg