From cd68fc9bae7d6258f77ff59c1431e4f925f61a4c Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 13 Sep 2018 23:48:50 +0100 Subject: Address sonar/Checkstyle Issues Sweep through Apex codebase to fix most ceheckstyle and straightforward sonar issues. Issue-ID: POLICY-1034 Change-Id: I149d9a94ad893affc93573e8de5e3304b6bdde2d Signed-off-by: liamfallon --- .../test/common/model/EvalDomainModelFactory.java | 501 ------------- .../common/model/SampleDomainModelFactory.java | 717 ------------------- .../test/common/model/SampleDomainModelSaver.java | 82 --- .../test/common/model/java/DefaultState_Logic.java | 43 -- .../test/common/model/java/DefaultTask_Logic.java | 71 -- .../test/common/model/java/EvalState_Logic.java | 42 -- .../test/common/model/java/EvalTask_Logic.java | 50 -- .../apex/test/common/model/java/package-info.java | 26 - .../apex/test/common/model/package-info.java | 26 - .../common/model/EvalDomainModelFactory.java | 585 ++++++++++++++++ .../common/model/SampleDomainModelFactory.java | 776 +++++++++++++++++++++ .../common/model/SampleDomainModelSaver.java | 92 +++ .../common/model/java/DefaultStateLogic.java | 41 ++ .../common/model/java/DefaultTaskLogic.java | 74 ++ .../common/model/java/EvalStateLogic.java | 40 ++ .../common/model/java/EvalTaskLogic.java | 56 ++ .../common/model/java/package-info.java | 26 + .../integration/common/model/package-info.java | 26 + .../model/javascript/DefaultState_Logic.javascript | 27 - .../model/javascript/DefaultTask_Logic.javascript | 34 - .../model/javascript/EvalState_Logic.javascript | 25 - .../model/javascript/EvalTask_Logic.javascript | 29 - .../common/model/jruby/DefaultState_Logic.jruby | 24 - .../common/model/jruby/DefaultTask_Logic.jruby | 33 - .../test/common/model/jruby/EvalState_Logic.jruby | 23 - .../test/common/model/jruby/EvalTask_Logic.jruby | 32 - .../common/model/jython/DefaultState_Logic.jython | 27 - .../common/model/jython/DefaultTask_Logic.jython | 35 - .../common/model/jython/EvalState_Logic.jython | 25 - .../test/common/model/jython/EvalTask_Logic.jython | 32 - .../test/common/model/mvel/DefaultState_Logic.mvel | 23 - .../test/common/model/mvel/DefaultTask_Logic.mvel | 30 - .../test/common/model/mvel/EvalState_Logic.mvel | 23 - .../test/common/model/mvel/EvalTask_Logic.mvel | 26 - .../model/javascript/DefaultStateLogic.javascript | 27 + .../model/javascript/DefaultTaskLogic.javascript | 34 + .../model/javascript/EvalStateLogic.javascript | 25 + .../model/javascript/EvalTaskLogic.javascript | 29 + .../common/model/jruby/DefaultStateLogic.jruby | 24 + .../common/model/jruby/DefaultTaskLogic.jruby | 33 + .../common/model/jruby/EvalStateLogic.jruby | 23 + .../common/model/jruby/EvalTaskLogic.jruby | 32 + .../common/model/jython/DefaultStateLogic.jython | 27 + .../common/model/jython/DefaultTaskLogic.jython | 35 + .../common/model/jython/EvalStateLogic.jython | 25 + .../common/model/jython/EvalTaskLogic.jython | 32 + .../common/model/mvel/DefaultStateLogic.mvel | 23 + .../common/model/mvel/DefaultTaskLogic.mvel | 30 + .../common/model/mvel/EvalStateLogic.mvel | 23 + .../common/model/mvel/EvalTaskLogic.mvel | 26 + 50 files changed, 2164 insertions(+), 2006 deletions(-) delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/EvalDomainModelFactory.java delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelFactory.java delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelSaver.java delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultState_Logic.java delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultTask_Logic.java delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalState_Logic.java delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalTask_Logic.java delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/package-info.java delete mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/package-info.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactory.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactory.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaver.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultStateLogic.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalStateLogic.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalTaskLogic.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/package-info.java create mode 100644 testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/package-info.java delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/DefaultState_Logic.javascript delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/DefaultTask_Logic.javascript delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/EvalState_Logic.javascript delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/EvalTask_Logic.javascript delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/DefaultState_Logic.jruby delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/DefaultTask_Logic.jruby delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/EvalState_Logic.jruby delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/EvalTask_Logic.jruby delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/DefaultState_Logic.jython delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/DefaultTask_Logic.jython delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/EvalState_Logic.jython delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/EvalTask_Logic.jython delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/DefaultState_Logic.mvel delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/DefaultTask_Logic.mvel delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/EvalState_Logic.mvel delete mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/EvalTask_Logic.mvel create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultStateLogic.javascript create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultTaskLogic.javascript create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalStateLogic.javascript create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalTaskLogic.javascript create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/DefaultStateLogic.jruby create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/DefaultTaskLogic.jruby create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/EvalStateLogic.jruby create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/EvalTaskLogic.jruby create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/DefaultStateLogic.jython create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/DefaultTaskLogic.jython create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/EvalStateLogic.jython create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/EvalTaskLogic.jython create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/DefaultStateLogic.mvel create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/DefaultTaskLogic.mvel create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/EvalStateLogic.mvel create mode 100644 testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/EvalTaskLogic.mvel (limited to 'testsuites/integration/integration-common/src') diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/EvalDomainModelFactory.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/EvalDomainModelFactory.java deleted file mode 100644 index a3f626f48..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/EvalDomainModelFactory.java +++ /dev/null @@ -1,501 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -package org.onap.policy.apex.test.common.model; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; - -import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; -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.AxEvents; -import org.onap.policy.apex.model.eventmodel.concepts.AxField; -import org.onap.policy.apex.model.policymodel.concepts.AxLogicReader; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicies; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicy; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.model.policymodel.concepts.AxState; -import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput; -import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType; -import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference; -import org.onap.policy.apex.model.policymodel.concepts.AxTask; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic; -import org.onap.policy.apex.model.policymodel.concepts.AxTasks; -import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader; - -/** - * This class creates sample evaluation Policy Models. - * - * @author John Keeney (john.keeney@ericsson.com) - */ -public class EvalDomainModelFactory { - private static final int THIRD_MEMBER = 3; - - private static final String PACKAGE = EvalDomainModelFactory.class.getPackage().getName(); - - private String justOneLang = null; - - private final AxContextSchema typeTimestamp; - private final AxContextSchema typeDouble; - private final AxContextSchema typeCounter; - private final AxContextSchemas schemas; - private final AxEvent event0000; - private final AxEvent event0001; - private final AxEvent event0002; - private final AxEvent event0003; - private final AxEvent event0004; - private final AxEvents events; - - /** - * The Constructor for the factory. - */ - public EvalDomainModelFactory() { - this(null); - } - - /** - * The Constructor for the factory that creates models for a single executor language flavour. - * - * @param justOneLang the just one lang - */ - public EvalDomainModelFactory(final String justOneLang) { - this.justOneLang = justOneLang; - - typeTimestamp = new AxContextSchema(new AxArtifactKey("TestTimestamp", "0.0.1"), "Java", "java.lang.Long"); - typeDouble = new AxContextSchema(new AxArtifactKey("TestTemperature", "0.0.1"), "Java", "java.lang.Double"); - typeCounter = new AxContextSchema(new AxArtifactKey("TestTimestamp", "0.0.1"), "Java", "java.lang.Long"); - - schemas = new AxContextSchemas(new AxArtifactKey("TestDatatypes", "0.0.1")); - schemas.getSchemasMap().put(typeTimestamp.getKey(), typeTimestamp); - schemas.getSchemasMap().put(typeDouble.getKey(), typeDouble); - schemas.getSchemasMap().put(typeCounter.getKey(), typeCounter); - - event0000 = new AxEvent(new AxArtifactKey("Event0000", "0.0.1"), PACKAGE + ".events"); - event0000.getParameterMap().put("SentTimestamp", new AxField(new AxReferenceKey(event0000.getKey(), "SentTimestamp"), typeTimestamp.getKey())); - event0000.getParameterMap().put("TestTemperature", new AxField(new AxReferenceKey(event0000.getKey(), "TestTemperature"), typeDouble.getKey())); - event0000.getParameterMap().put("FirstEventTimestamp", - new AxField(new AxReferenceKey(event0000.getKey(), "FirstEventTimestamp"), typeTimestamp.getKey())); - event0000.getParameterMap().put("EventNumber", new AxField(new AxReferenceKey(event0000.getKey(), "EventNumber"), typeCounter.getKey())); - - event0001 = new AxEvent(new AxArtifactKey("Event0001", "0.0.1"), PACKAGE + ".events"); - event0001.getParameterMap().put("SentTimestamp", new AxField(new AxReferenceKey(event0001.getKey(), "SentTimestamp"), typeTimestamp.getKey())); - event0001.getParameterMap().put("State1Timestamp", new AxField(new AxReferenceKey(event0001.getKey(), "State1Timestamp"), typeTimestamp.getKey())); - event0001.getParameterMap().put("TestTemperature", new AxField(new AxReferenceKey(event0001.getKey(), "TestTemperature"), typeDouble.getKey())); - event0001.getParameterMap().put("FirstEventTimestamp", - new AxField(new AxReferenceKey(event0001.getKey(), "FirstEventTimestamp"), typeTimestamp.getKey())); - event0001.getParameterMap().put("EventNumber", new AxField(new AxReferenceKey(event0001.getKey(), "EventNumber"), typeCounter.getKey())); - - event0002 = new AxEvent(new AxArtifactKey("Event0002", "0.0.1"), PACKAGE + ".events"); - event0002.getParameterMap().put("SentTimestamp", new AxField(new AxReferenceKey(event0002.getKey(), "SentTimestamp"), typeTimestamp.getKey())); - event0002.getParameterMap().put("State1Timestamp", new AxField(new AxReferenceKey(event0002.getKey(), "State1Timestamp"), typeTimestamp.getKey())); - event0002.getParameterMap().put("State2Timestamp", new AxField(new AxReferenceKey(event0002.getKey(), "State2Timestamp"), typeTimestamp.getKey())); - event0002.getParameterMap().put("TestTemperature", new AxField(new AxReferenceKey(event0002.getKey(), "TestTemperature"), typeDouble.getKey())); - event0002.getParameterMap().put("FirstEventTimestamp", - new AxField(new AxReferenceKey(event0002.getKey(), "FirstEventTimestamp"), typeTimestamp.getKey())); - event0002.getParameterMap().put("EventNumber", new AxField(new AxReferenceKey(event0002.getKey(), "EventNumber"), typeCounter.getKey())); - - event0003 = new AxEvent(new AxArtifactKey("Event0003", "0.0.1"), PACKAGE + ".events"); - event0003.getParameterMap().put("SentTimestamp", new AxField(new AxReferenceKey(event0003.getKey(), "SentTimestamp"), typeTimestamp.getKey())); - event0003.getParameterMap().put("State1Timestamp", new AxField(new AxReferenceKey(event0003.getKey(), "State1Timestamp"), typeTimestamp.getKey())); - event0003.getParameterMap().put("State2Timestamp", new AxField(new AxReferenceKey(event0003.getKey(), "State2Timestamp"), typeTimestamp.getKey())); - event0003.getParameterMap().put("State3Timestamp", new AxField(new AxReferenceKey(event0003.getKey(), "State3Timestamp"), typeTimestamp.getKey())); - event0003.getParameterMap().put("TestTemperature", new AxField(new AxReferenceKey(event0003.getKey(), "TestTemperature"), typeDouble.getKey())); - event0003.getParameterMap().put("FirstEventTimestamp", - new AxField(new AxReferenceKey(event0003.getKey(), "FirstEventTimestamp"), typeTimestamp.getKey())); - event0003.getParameterMap().put("EventNumber", new AxField(new AxReferenceKey(event0003.getKey(), "EventNumber"), typeCounter.getKey())); - - event0004 = new AxEvent(new AxArtifactKey("Event0004", "0.0.1"), PACKAGE + ".events"); - event0004.getParameterMap().put("SentTimestamp", new AxField(new AxReferenceKey(event0004.getKey(), "SentTimestamp"), typeTimestamp.getKey())); - event0004.getParameterMap().put("State1Timestamp", new AxField(new AxReferenceKey(event0004.getKey(), "State1Timestamp"), typeTimestamp.getKey())); - event0004.getParameterMap().put("State2Timestamp", new AxField(new AxReferenceKey(event0004.getKey(), "State2Timestamp"), typeTimestamp.getKey())); - event0004.getParameterMap().put("State3Timestamp", new AxField(new AxReferenceKey(event0004.getKey(), "State3Timestamp"), typeTimestamp.getKey())); - event0004.getParameterMap().put("State4Timestamp", new AxField(new AxReferenceKey(event0004.getKey(), "State4Timestamp"), typeTimestamp.getKey())); - event0004.getParameterMap().put("TestTemperature", new AxField(new AxReferenceKey(event0004.getKey(), "TestTemperature"), typeDouble.getKey())); - event0004.getParameterMap().put("FirstEventTimestamp", - new AxField(new AxReferenceKey(event0004.getKey(), "FirstEventTimestamp"), typeTimestamp.getKey())); - event0004.getParameterMap().put("EventNumber", new AxField(new AxReferenceKey(event0004.getKey(), "EventNumber"), typeCounter.getKey())); - - events = new AxEvents(new AxArtifactKey("Events", "0.0.1")); - events.getEventMap().put(event0000.getKey(), event0000); - events.getEventMap().put(event0001.getKey(), event0001); - events.getEventMap().put(event0002.getKey(), event0002); - events.getEventMap().put(event0003.getKey(), event0003); - events.getEventMap().put(event0004.getKey(), event0004); - } - - /** - * Get a sample OODA policy model. - * - * @return the sample policy model - */ - public AxPolicyModel getOODAPolicyModel() { - final AxTasks tasks = new AxTasks(new AxArtifactKey("Tasks", "0.0.1")); - - final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE).setDefaultLogic("EvalTask_Logic"); - - final AxTask obTask = new AxTask(new AxArtifactKey("Task_Observe_0", "0.0.1")); - obTask.duplicateInputFields(event0000.getParameterMap()); - obTask.duplicateOutputFields(event0001.getParameterMap()); - final AxTaskLogic obAxLogic = new AxTaskLogic(obTask.getKey(), "TaskLogic", (justOneLang == null ? "JRUBY" : justOneLang), logicReader); - obAxLogic.setLogic(obAxLogic.getLogic().replaceAll("", "Observe").replaceAll("", obTask.getKey().getName()) - .replaceAll("", "1")); - obTask.setTaskLogic(obAxLogic); - - final AxTask orTask = new AxTask(new AxArtifactKey("Task_Orient_0", "0.0.1")); - orTask.duplicateInputFields(event0001.getParameterMap()); - orTask.duplicateOutputFields(event0002.getParameterMap()); - final AxTaskLogic orAxLogic = new AxTaskLogic(orTask.getKey(), "TaskLogic", (justOneLang == null ? "JAVASCRIPT" : justOneLang), logicReader); - orAxLogic.setLogic(orAxLogic.getLogic().replaceAll("", "Orient").replaceAll("", orTask.getKey().getName()) - .replaceAll("", "2")); - orTask.setTaskLogic(orAxLogic); - - final AxTask dTask = new AxTask(new AxArtifactKey("Task_Decide_0", "0.0.1")); - dTask.duplicateInputFields(event0002.getParameterMap()); - dTask.duplicateOutputFields(event0003.getParameterMap()); - final AxTaskLogic dAxLogic = new AxTaskLogic(dTask.getKey(), "TaskLogic", (justOneLang == null ? "MVEL" : justOneLang), logicReader); - dAxLogic.setLogic( - dAxLogic.getLogic().replaceAll("", "Orient").replaceAll("", dTask.getKey().getName()).replaceAll("", "3")); - dTask.setTaskLogic(dAxLogic); - - final AxTask aTask = new AxTask(new AxArtifactKey("Task_Act_0", "0.0.1")); - aTask.duplicateInputFields(event0003.getParameterMap()); - aTask.duplicateOutputFields(event0004.getParameterMap()); - final AxTaskLogic aAxLogic = new AxTaskLogic(aTask.getKey(), "TaskLogic", (justOneLang == null ? "JAVA" : justOneLang), logicReader); - aAxLogic.setLogic( - aAxLogic.getLogic().replaceAll("", "Act").replaceAll("", aTask.getKey().getName()).replaceAll("", "4")); - aTask.setTaskLogic(aAxLogic); - - tasks.getTaskMap().put(obTask.getKey(), obTask); - tasks.getTaskMap().put(orTask.getKey(), orTask); - tasks.getTaskMap().put(dTask.getKey(), dTask); - tasks.getTaskMap().put(aTask.getKey(), aTask); - - final Set obTasks = new TreeSet<>(); - final Set orTasks = new TreeSet<>(); - final Set decTasks = new TreeSet<>(); - final Set actTasks = new TreeSet<>(); - - for (final AxTask task : tasks.getTaskMap().values()) { - if (task.getKey().getName().contains("Observe")) { - obTasks.add(task.getKey()); - } - if (task.getKey().getName().contains("Orient")) { - orTasks.add(task.getKey()); - } - if (task.getKey().getName().contains("Decide")) { - decTasks.add(task.getKey()); - } - if (task.getKey().getName().contains("Act")) { - actTasks.add(task.getKey()); - } - } - final List> taskReferenceList = new ArrayList<>(); - taskReferenceList.add(obTasks); - taskReferenceList.add(orTasks); - taskReferenceList.add(decTasks); - taskReferenceList.add(actTasks); - - final List p0InEventList = new ArrayList<>(); - p0InEventList.add(event0000.getKey()); - p0InEventList.add(event0001.getKey()); - p0InEventList.add(event0002.getKey()); - p0InEventList.add(event0003.getKey()); - - final List p0OutEventList = new ArrayList<>(); - p0OutEventList.add(event0001.getKey()); - p0OutEventList.add(event0002.getKey()); - p0OutEventList.add(event0003.getKey()); - p0OutEventList.add(event0004.getKey()); - - final List p0defaultTaskList = new ArrayList<>(); - p0defaultTaskList.add(tasks.get("Task_Observe_0").getKey()); - p0defaultTaskList.add(tasks.get("Task_Orient_0").getKey()); - p0defaultTaskList.add(tasks.get("Task_Decide_0").getKey()); - p0defaultTaskList.add(tasks.get("Task_Act_0").getKey()); - - final AxPolicy policy0 = new AxPolicy(new AxArtifactKey("OODAPolicy_0", "0.0.1")); - final List axLogicExecutorTypeList = Arrays.asList((justOneLang == null ? "JAVASCRIPT" : justOneLang), - (justOneLang == null ? "MVEL" : justOneLang), (justOneLang == null ? "JYTHON" : justOneLang), (justOneLang == null ? "JRUBY" : justOneLang)); - policy0.setStateMap(getOODAStateMap(policy0.getKey(), p0InEventList, p0OutEventList, axLogicExecutorTypeList, p0defaultTaskList, taskReferenceList)); - policy0.setFirstState(policy0.getStateMap().get("Observe").getKey().getLocalName()); - - final AxPolicies policies = new AxPolicies(new AxArtifactKey("OODAPolicies", "0.0.1")); - policies.getPolicyMap().put(policy0.getKey(), policy0); - - final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInformation", "0.0.1")); - final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("EvaluationPolicyModel_OODA", "0.0.1")); - policyModel.setPolicies(policies); - policyModel.setEvents(events); - policyModel.setTasks(tasks); - policyModel.setAlbums(new AxContextAlbums(new AxArtifactKey("Albums", "0.0.1"))); - policyModel.setSchemas(schemas); - policyModel.setKeyInformation(keyInformation); - policyModel.getKeyInformation().generateKeyInfo(policyModel); - - final AxValidationResult result = policyModel.validate(new AxValidationResult()); - if (!result.isOk()) { - throw new ApexRuntimeException("model " + policyModel.getId() + " is not valid" + result); - } - return policyModel; - } - - /** - * Gets the OODA state map. - * - * @param policyKey the policy key - * @param inEventKeyList the in event key list - * @param outEventKeyList the out event key list - * @param axLogicExecutorTypeList the ax logic executor type list - * @param defaultTaskList the default task list - * @param taskKeySetList the task key set list - * @return the OODA state map - */ - private Map getOODAStateMap(final AxArtifactKey policyKey, final List inEventKeyList, - final List outEventKeyList, final List axLogicExecutorTypeList, final List defaultTaskList, - final List> taskKeySetList) { - final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE).setDefaultLogic("EvalState_Logic"); - - final AxState actState = new AxState(new AxReferenceKey(policyKey, "Act")); - actState.setTrigger(inEventKeyList.get(THIRD_MEMBER)); - final AxStateOutput act2Out = new AxStateOutput(new AxReferenceKey(actState.getKey(), "Act2Out"), outEventKeyList.get(THIRD_MEMBER), - AxReferenceKey.getNullKey()); - actState.getStateOutputs().put(act2Out.getKey().getLocalName(), act2Out); - actState.setTaskSelectionLogic( - new AxTaskSelectionLogic(actState.getKey(), "TaskSelectionLogic", axLogicExecutorTypeList.get(THIRD_MEMBER), logicReader)); - actState.setDefaultTask(defaultTaskList.get(THIRD_MEMBER)); - for (final AxArtifactKey taskKey : taskKeySetList.get(THIRD_MEMBER)) { - actState.getTaskReferences().put(taskKey, - new AxStateTaskReference(new AxReferenceKey(actState.getKey(), taskKey.getName()), AxStateTaskOutputType.DIRECT, act2Out.getKey())); - } - - final AxState decState = new AxState(new AxReferenceKey(policyKey, "Decide")); - decState.setTrigger(inEventKeyList.get(2)); - final AxStateOutput dec2Act = new AxStateOutput(new AxReferenceKey(decState.getKey(), "Dec2Act"), outEventKeyList.get(2), actState.getKey()); - decState.getStateOutputs().put(dec2Act.getKey().getLocalName(), dec2Act); - decState.setTaskSelectionLogic(new AxTaskSelectionLogic(decState.getKey(), "TaskSelectionLogic", axLogicExecutorTypeList.get(2), logicReader)); - decState.setDefaultTask(defaultTaskList.get(2)); - for (final AxArtifactKey taskKey : taskKeySetList.get(2)) { - decState.getTaskReferences().put(taskKey, - new AxStateTaskReference(new AxReferenceKey(decState.getKey(), taskKey.getName()), AxStateTaskOutputType.DIRECT, dec2Act.getKey())); - } - - final AxState orState = new AxState(new AxReferenceKey(policyKey, "Orient")); - orState.setTrigger(inEventKeyList.get(1)); - final AxStateOutput or2Dec = new AxStateOutput(new AxReferenceKey(orState.getKey(), "Or2Dec"), outEventKeyList.get(1), decState.getKey()); - orState.getStateOutputs().put(or2Dec.getKey().getLocalName(), or2Dec); - orState.setTaskSelectionLogic(new AxTaskSelectionLogic(orState.getKey(), "TaskSelectionLogic", axLogicExecutorTypeList.get(1), logicReader)); - orState.setDefaultTask(defaultTaskList.get(1)); - for (final AxArtifactKey taskKey : taskKeySetList.get(1)) { - orState.getTaskReferences().put(taskKey, - new AxStateTaskReference(new AxReferenceKey(orState.getKey(), taskKey.getName()), AxStateTaskOutputType.DIRECT, or2Dec.getKey())); - } - - final AxState obState = new AxState(new AxReferenceKey(policyKey, "Observe")); - obState.setTrigger(inEventKeyList.get(0)); - final AxStateOutput ob2Or = new AxStateOutput(new AxReferenceKey(obState.getKey(), "Ob2Or"), outEventKeyList.get(0), orState.getKey()); - obState.getStateOutputs().put(ob2Or.getKey().getLocalName(), ob2Or); - obState.setTaskSelectionLogic(new AxTaskSelectionLogic(obState.getKey(), "TaskSelectionLogic", axLogicExecutorTypeList.get(0), logicReader)); - obState.setDefaultTask(defaultTaskList.get(0)); - for (final AxArtifactKey taskKey : taskKeySetList.get(0)) { - obState.getTaskReferences().put(taskKey, - new AxStateTaskReference(new AxReferenceKey(obState.getKey(), taskKey.getName()), AxStateTaskOutputType.DIRECT, ob2Or.getKey())); - } - - final Map stateMap = new TreeMap<>(); - stateMap.put(obState.getKey().getLocalName(), obState); - stateMap.put(orState.getKey().getLocalName(), orState); - stateMap.put(decState.getKey().getLocalName(), decState); - stateMap.put(actState.getKey().getLocalName(), actState); - - return stateMap; - } - - /** - * Get a sample ECA policy model. - * - * @return the sample policy model - */ - public AxPolicyModel getECAPolicyModel() { - - final AxTasks tasks = new AxTasks(new AxArtifactKey("Tasks", "0.0.1")); - - final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE).setDefaultLogic("EvalTask_Logic"); - - final AxTask eTask = new AxTask(new AxArtifactKey("Task_Event_0", "0.0.1")); - eTask.duplicateInputFields(event0000.getParameterMap()); - eTask.duplicateOutputFields(event0001.getParameterMap()); - final AxTaskLogic eAxLogic = new AxTaskLogic(eTask.getKey(), "TaskLogic", (justOneLang == null ? "JYTHON" : justOneLang), logicReader); - eAxLogic.setLogic( - eAxLogic.getLogic().replaceAll("", "Event").replaceAll("", eTask.getKey().getName()).replaceAll("", "1")); - eTask.setTaskLogic(eAxLogic); - - final AxTask cTask = new AxTask(new AxArtifactKey("Task_Condition_0", "0.0.1")); - cTask.duplicateInputFields(event0001.getParameterMap()); - cTask.duplicateOutputFields(event0002.getParameterMap()); - final AxTaskLogic cAxLogic = new AxTaskLogic(cTask.getKey(), "TaskLogic", (justOneLang == null ? "JAVASCRIPT" : justOneLang), logicReader); - cAxLogic.setLogic(cAxLogic.getLogic().replaceAll("", "Condition").replaceAll("", cTask.getKey().getName()) - .replaceAll("", "2")); - cTask.setTaskLogic(cAxLogic); - - final AxTask aTask = new AxTask(new AxArtifactKey("Task_Action_0", "0.0.1")); - aTask.duplicateInputFields(event0002.getParameterMap()); - aTask.duplicateOutputFields(event0003.getParameterMap()); - final AxTaskLogic aAxLogic = new AxTaskLogic(aTask.getKey(), "TaskLogic", (justOneLang == null ? "JAVA" : justOneLang), logicReader); - aAxLogic.setLogic( - aAxLogic.getLogic().replaceAll("", "Action").replaceAll("", aTask.getKey().getName()).replaceAll("", "3")); - aTask.setTaskLogic(aAxLogic); - - tasks.getTaskMap().put(eTask.getKey(), eTask); - tasks.getTaskMap().put(cTask.getKey(), cTask); - tasks.getTaskMap().put(aTask.getKey(), aTask); - - final Set eventTasks = new TreeSet<>(); - final Set conditionTasks = new TreeSet<>(); - final Set actionTasks = new TreeSet<>(); - - for (final AxTask task : tasks.getTaskMap().values()) { - if (task.getKey().getName().contains("Event")) { - eventTasks.add(task.getKey()); - } - if (task.getKey().getName().contains("Condition")) { - conditionTasks.add(task.getKey()); - } - if (task.getKey().getName().contains("Action")) { - actionTasks.add(task.getKey()); - } - } - final List> taskReferenceList = new ArrayList<>(); - taskReferenceList.add(eventTasks); - taskReferenceList.add(conditionTasks); - taskReferenceList.add(actionTasks); - - final List p0InEventList = new ArrayList<>(); - p0InEventList.add(event0000.getKey()); - p0InEventList.add(event0001.getKey()); - p0InEventList.add(event0002.getKey()); - - final List p0OutEventList = new ArrayList<>(); - p0OutEventList.add(event0001.getKey()); - p0OutEventList.add(event0002.getKey()); - p0OutEventList.add(event0003.getKey()); - - final List p0defaultTaskList = new ArrayList<>(); - p0defaultTaskList.add(tasks.get("Task_Event_0").getKey()); - p0defaultTaskList.add(tasks.get("Task_Condition_0").getKey()); - p0defaultTaskList.add(tasks.get("Task_Action_0").getKey()); - - final AxPolicy policy0 = new AxPolicy(new AxArtifactKey("ECAPolicy_0", "0.0.1")); - final List axLogicExecutorTypeList = Arrays.asList((justOneLang == null ? "JAVASCRIPT" : justOneLang), - (justOneLang == null ? "MVEL" : justOneLang), (justOneLang == null ? "JYTHON" : justOneLang)); - policy0.setStateMap(getECAStateMap(policy0.getKey(), p0InEventList, p0OutEventList, axLogicExecutorTypeList, p0defaultTaskList, taskReferenceList)); - policy0.setFirstState(policy0.getStateMap().get("Event").getKey().getLocalName()); - - final AxPolicies policies = new AxPolicies(new AxArtifactKey("ECAPolicies", "0.0.1")); - policies.getPolicyMap().put(policy0.getKey(), policy0); - - final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInformation", "0.0.1")); - final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("EvaluationPolicyModel_ECA", "0.0.1")); - policyModel.setPolicies(policies); - policyModel.setEvents(events); - policyModel.setTasks(tasks); - policyModel.setAlbums(new AxContextAlbums(new AxArtifactKey("Albums", "0.0.1"))); - policyModel.setSchemas(schemas); - policyModel.setKeyInformation(keyInformation); - policyModel.getKeyInformation().generateKeyInfo(policyModel); - - final AxValidationResult result = policyModel.validate(new AxValidationResult()); - if (!result.isOk()) { - throw new ApexRuntimeException("model " + policyModel.getId() + " is not valid" + result); - } - return policyModel; - } - - /** - * Gets the ECA state map. - * - * @param policyKey the policy key - * @param inEventKeyList the in event key list - * @param outEventKeyList the out event key list - * @param axLogicExecutorTypeList the ax logic executor type list - * @param defaultTaskList the default task list - * @param taskKeySetList the task key set list - * @return the ECA state map - */ - private Map getECAStateMap(final AxArtifactKey policyKey, final List inEventKeyList, - final List outEventKeyList, final List axLogicExecutorTypeList, final List defaultTaskList, - final List> taskKeySetList) { - final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE).setDefaultLogic("EvalState_Logic"); - - final AxState actionState = new AxState(new AxReferenceKey(policyKey, "Action")); - actionState.setTrigger(inEventKeyList.get(2)); - final AxStateOutput action2Out = new AxStateOutput(actionState.getKey(), AxReferenceKey.getNullKey(), outEventKeyList.get(2)); - actionState.getStateOutputs().put(action2Out.getKey().getLocalName(), action2Out); - actionState.setTaskSelectionLogic(new AxTaskSelectionLogic(actionState.getKey(), "TaskSelectionLogic", axLogicExecutorTypeList.get(2), logicReader)); - actionState.setDefaultTask(defaultTaskList.get(2)); - for (final AxArtifactKey taskKey : taskKeySetList.get(2)) { - actionState.getTaskReferences().put(taskKey, - new AxStateTaskReference(new AxReferenceKey(actionState.getKey(), taskKey.getName()), AxStateTaskOutputType.DIRECT, action2Out.getKey())); - } - - final AxState conditionState = new AxState(new AxReferenceKey(policyKey, "Condition")); - conditionState.setTrigger(inEventKeyList.get(1)); - final AxStateOutput condition2Action = new AxStateOutput(conditionState.getKey(), actionState.getKey(), outEventKeyList.get(1)); - conditionState.getStateOutputs().put(condition2Action.getKey().getLocalName(), condition2Action); - conditionState - .setTaskSelectionLogic(new AxTaskSelectionLogic(conditionState.getKey(), "TaskSelectionLogic", axLogicExecutorTypeList.get(1), logicReader)); - conditionState.setDefaultTask(defaultTaskList.get(1)); - for (final AxArtifactKey taskKey : taskKeySetList.get(1)) { - conditionState.getTaskReferences().put(taskKey, new AxStateTaskReference(new AxReferenceKey(conditionState.getKey(), taskKey.getName()), - AxStateTaskOutputType.DIRECT, condition2Action.getKey())); - } - - final AxState eventState = new AxState(new AxReferenceKey(policyKey, "Event")); - eventState.setTrigger(inEventKeyList.get(0)); - final AxStateOutput event2Condition = new AxStateOutput(eventState.getKey(), conditionState.getKey(), outEventKeyList.get(0)); - eventState.getStateOutputs().put(event2Condition.getKey().getLocalName(), event2Condition); - eventState.setTaskSelectionLogic(new AxTaskSelectionLogic(eventState.getKey(), "TaskSelectionLogic", axLogicExecutorTypeList.get(0), logicReader)); - eventState.setDefaultTask(defaultTaskList.get(0)); - for (final AxArtifactKey taskKey : taskKeySetList.get(0)) { - eventState.getTaskReferences().put(taskKey, new AxStateTaskReference(new AxReferenceKey(eventState.getKey(), taskKey.getName()), - AxStateTaskOutputType.DIRECT, event2Condition.getKey())); - } - - final Map stateMap = new TreeMap<>(); - stateMap.put(eventState.getKey().getLocalName(), eventState); - stateMap.put(conditionState.getKey().getLocalName(), conditionState); - stateMap.put(actionState.getKey().getLocalName(), actionState); - - return stateMap; - } - -} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelFactory.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelFactory.java deleted file mode 100644 index 184529fa9..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelFactory.java +++ /dev/null @@ -1,717 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -package org.onap.policy.apex.test.common.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; - -import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum; -import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; -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.AxEvents; -import org.onap.policy.apex.model.eventmodel.concepts.AxField; -import org.onap.policy.apex.model.policymodel.concepts.AxLogicReader; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicies; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicy; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.model.policymodel.concepts.AxState; -import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput; -import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType; -import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference; -import org.onap.policy.apex.model.policymodel.concepts.AxTask; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter; -import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic; -import org.onap.policy.apex.model.policymodel.concepts.AxTasks; -import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader; - -/** - * This class creates sample Policy Models. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class SampleDomainModelFactory { - private static final int THIRD_ENTRY = 3; - - /** - * Get a sample policy model. - * - * @param axLogicExecutorType The type of logic executor, the scripting language being used - * @return the sample policy model - */ - // CHECKSTYLE:OFF: checkstyle:maximumMethodLength - public AxPolicyModel getSamplePolicyModel(final String axLogicExecutorType) { - AxContextSchema testSlogan = - new AxContextSchema(new AxArtifactKey("TestSlogan", "0.0.1"), "Java", "java.lang.String"); - AxContextSchema testCase = - new AxContextSchema(new AxArtifactKey("TestCase", "0.0.1"), "Java", "java.lang.Byte"); - AxContextSchema testTimestamp = - new AxContextSchema(new AxArtifactKey("TestTimestamp", "0.0.1"), "Java", "java.lang.Long"); - AxContextSchema testTemperature = - new AxContextSchema(new AxArtifactKey("TestTemperature", "0.0.1"), "Java", "java.lang.Double"); - - AxContextSchema testContextItem000 = new AxContextSchema(new AxArtifactKey("TestContextItem000", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem000"); - AxContextSchema testContextItem001 = new AxContextSchema(new AxArtifactKey("TestContextItem001", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem001"); - AxContextSchema testContextItem002 = new AxContextSchema(new AxArtifactKey("TestContextItem002", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem002"); - AxContextSchema testContextItem003 = new AxContextSchema(new AxArtifactKey("TestContextItem003", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem003"); - AxContextSchema testContextItem004 = new AxContextSchema(new AxArtifactKey("TestContextItem004", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem004"); - AxContextSchema testContextItem005 = new AxContextSchema(new AxArtifactKey("TestContextItem005", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem005"); - AxContextSchema testContextItem006 = new AxContextSchema(new AxArtifactKey("TestContextItem006", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem006"); - AxContextSchema testContextItem007 = new AxContextSchema(new AxArtifactKey("TestContextItem007", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem007"); - AxContextSchema testContextItem008 = new AxContextSchema(new AxArtifactKey("TestContextItem008", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem008"); - AxContextSchema testContextItem009 = new AxContextSchema(new AxArtifactKey("TestContextItem009", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem009"); - AxContextSchema testContextItem00A = new AxContextSchema(new AxArtifactKey("TestContextItem00A", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem00A"); - AxContextSchema testContextItem00B = new AxContextSchema(new AxArtifactKey("TestContextItem00B", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem00B"); - AxContextSchema testContextItem00C = new AxContextSchema(new AxArtifactKey("TestContextItem00C", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem00C"); - - AxContextSchema testPolicyContextItem = new AxContextSchema(new AxArtifactKey("TestPolicyContextItem", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestPolicyContextItem"); - AxContextSchema testGlobalContextItem = new AxContextSchema(new AxArtifactKey("TestGlobalContextItem", "0.0.1"), - "Java", "org.onap.policy.apex.context.test.concepts.TestGlobalContextItem"); - AxContextSchema testExternalContextItem = - new AxContextSchema(new AxArtifactKey("TestExternalContextItem", "0.0.1"), "Java", - "org.onap.policy.apex.context.test.concepts.TestExternalContextItem"); - - AxContextSchemas axContextSchemas = new AxContextSchemas(new AxArtifactKey("TestDatatypes", "0.0.1")); - axContextSchemas.getSchemasMap().put(testSlogan.getKey(), testSlogan); - axContextSchemas.getSchemasMap().put(testCase.getKey(), testCase); - axContextSchemas.getSchemasMap().put(testTimestamp.getKey(), testTimestamp); - axContextSchemas.getSchemasMap().put(testTemperature.getKey(), testTemperature); - - axContextSchemas.getSchemasMap().put(testContextItem000.getKey(), testContextItem000); - axContextSchemas.getSchemasMap().put(testContextItem001.getKey(), testContextItem001); - axContextSchemas.getSchemasMap().put(testContextItem002.getKey(), testContextItem002); - axContextSchemas.getSchemasMap().put(testContextItem003.getKey(), testContextItem003); - axContextSchemas.getSchemasMap().put(testContextItem004.getKey(), testContextItem004); - axContextSchemas.getSchemasMap().put(testContextItem005.getKey(), testContextItem005); - axContextSchemas.getSchemasMap().put(testContextItem006.getKey(), testContextItem006); - axContextSchemas.getSchemasMap().put(testContextItem007.getKey(), testContextItem007); - axContextSchemas.getSchemasMap().put(testContextItem008.getKey(), testContextItem008); - axContextSchemas.getSchemasMap().put(testContextItem009.getKey(), testContextItem009); - axContextSchemas.getSchemasMap().put(testContextItem00A.getKey(), testContextItem00A); - axContextSchemas.getSchemasMap().put(testContextItem00B.getKey(), testContextItem00B); - axContextSchemas.getSchemasMap().put(testContextItem00C.getKey(), testContextItem00C); - - axContextSchemas.getSchemasMap().put(testPolicyContextItem.getKey(), testPolicyContextItem); - axContextSchemas.getSchemasMap().put(testGlobalContextItem.getKey(), testGlobalContextItem); - axContextSchemas.getSchemasMap().put(testExternalContextItem.getKey(), testExternalContextItem); - - AxEvent event0000 = new AxEvent(new AxArtifactKey("Event0000", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0000.setSource("Outside"); - event0000.setTarget("Match"); - event0000.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0000.getKey(), "TestSlogan"), testSlogan.getKey())); - event0000.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0000.getKey(), "TestMatchCase"), testCase.getKey())); - event0000.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0000.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0000.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0000.getKey(), "TestTemperature"), testTemperature.getKey())); - - AxEvent event0001 = new AxEvent(new AxArtifactKey("Event0001", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0001.setSource("Match"); - event0001.setTarget("Establish"); - event0001.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0001.getKey(), "TestSlogan"), testSlogan.getKey())); - event0001.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0001.getKey(), "TestMatchCase"), testCase.getKey())); - event0001.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0001.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0001.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0001.getKey(), "TestTemperature"), testTemperature.getKey())); - event0001.getParameterMap().put("TestMatchCaseSelected", - new AxField(new AxReferenceKey(event0001.getKey(), "TestMatchCaseSelected"), testCase.getKey())); - event0001.getParameterMap().put("TestMatchStateTime", - new AxField(new AxReferenceKey(event0001.getKey(), "TestMatchStateTime"), testTimestamp.getKey())); - - AxEvent event0002 = new AxEvent(new AxArtifactKey("Event0002", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0002.setSource("Establish"); - event0002.setTarget("Decide"); - event0002.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0002.getKey(), "TestSlogan"), testSlogan.getKey())); - event0002.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0002.getKey(), "TestMatchCase"), testCase.getKey())); - event0002.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0002.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0002.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0002.getKey(), "TestTemperature"), testTemperature.getKey())); - event0002.getParameterMap().put("TestMatchCaseSelected", - new AxField(new AxReferenceKey(event0002.getKey(), "TestMatchCaseSelected"), testCase.getKey())); - event0002.getParameterMap().put("TestMatchStateTime", - new AxField(new AxReferenceKey(event0002.getKey(), "TestMatchStateTime"), testTimestamp.getKey())); - event0002.getParameterMap().put("TestEstablishCaseSelected", - new AxField(new AxReferenceKey(event0002.getKey(), "TestEstablishCaseSelected"), testCase.getKey())); - event0002.getParameterMap().put("TestEstablishStateTime", - new AxField(new AxReferenceKey(event0002.getKey(), "TestEstablishStateTime"), testTimestamp.getKey())); - - AxEvent event0003 = new AxEvent(new AxArtifactKey("Event0003", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0003.setSource("Decide"); - event0003.setTarget("Act"); - event0003.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0003.getKey(), "TestSlogan"), testSlogan.getKey())); - event0003.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0003.getKey(), "TestMatchCase"), testCase.getKey())); - event0003.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0003.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0003.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0003.getKey(), "TestTemperature"), testTemperature.getKey())); - event0003.getParameterMap().put("TestMatchCaseSelected", - new AxField(new AxReferenceKey(event0003.getKey(), "TestMatchCaseSelected"), testCase.getKey())); - event0003.getParameterMap().put("TestMatchStateTime", - new AxField(new AxReferenceKey(event0003.getKey(), "TestMatchStateTime"), testTimestamp.getKey())); - event0003.getParameterMap().put("TestEstablishCaseSelected", - new AxField(new AxReferenceKey(event0003.getKey(), "TestEstablishCaseSelected"), testCase.getKey())); - event0003.getParameterMap().put("TestEstablishStateTime", - new AxField(new AxReferenceKey(event0003.getKey(), "TestEstablishStateTime"), testTimestamp.getKey())); - event0003.getParameterMap().put("TestDecideCaseSelected", - new AxField(new AxReferenceKey(event0003.getKey(), "TestDecideCaseSelected"), testCase.getKey())); - event0003.getParameterMap().put("TestDecideStateTime", - new AxField(new AxReferenceKey(event0003.getKey(), "TestDecideStateTime"), testTimestamp.getKey())); - - AxEvent event0004 = new AxEvent(new AxArtifactKey("Event0004", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0004.setSource("Act"); - event0004.setTarget("Outside"); - event0004.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0004.getKey(), "TestSlogan"), testSlogan.getKey())); - event0004.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0004.getKey(), "TestMatchCase"), testCase.getKey())); - event0004.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0004.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0004.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0004.getKey(), "TestTemperature"), testTemperature.getKey())); - event0004.getParameterMap().put("TestMatchCaseSelected", - new AxField(new AxReferenceKey(event0004.getKey(), "TestMatchCaseSelected"), testCase.getKey())); - event0004.getParameterMap().put("TestMatchStateTime", - new AxField(new AxReferenceKey(event0004.getKey(), "TestMatchStateTime"), testTimestamp.getKey())); - event0004.getParameterMap().put("TestEstablishCaseSelected", - new AxField(new AxReferenceKey(event0004.getKey(), "TestEstablishCaseSelected"), testCase.getKey())); - event0004.getParameterMap().put("TestEstablishStateTime", - new AxField(new AxReferenceKey(event0004.getKey(), "TestEstablishStateTime"), testTimestamp.getKey())); - event0004.getParameterMap().put("TestDecideCaseSelected", - new AxField(new AxReferenceKey(event0004.getKey(), "TestDecideCaseSelected"), testCase.getKey())); - event0004.getParameterMap().put("TestDecideStateTime", - new AxField(new AxReferenceKey(event0004.getKey(), "TestDecideStateTime"), testTimestamp.getKey())); - event0004.getParameterMap().put("TestActCaseSelected", - new AxField(new AxReferenceKey(event0004.getKey(), "TestActCaseSelected"), testCase.getKey())); - event0004.getParameterMap().put("TestActStateTime", - new AxField(new AxReferenceKey(event0004.getKey(), "TestActStateTime"), testTimestamp.getKey())); - - AxEvent event0100 = new AxEvent(new AxArtifactKey("Event0100", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0100.setSource("Outside"); - event0100.setTarget("Match"); - event0100.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0100.getKey(), "TestSlogan"), testSlogan.getKey())); - event0100.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0100.getKey(), "TestMatchCase"), testCase.getKey())); - event0100.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0100.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0100.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0100.getKey(), "TestTemperature"), testTemperature.getKey())); - - AxEvent event0101 = new AxEvent(new AxArtifactKey("Event0101", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0101.setSource("Match"); - event0101.setTarget("Establish"); - event0101.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0101.getKey(), "TestSlogan"), testSlogan.getKey())); - event0101.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0101.getKey(), "TestMatchCase"), testCase.getKey())); - event0101.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0101.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0101.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0101.getKey(), "TestTemperature"), testTemperature.getKey())); - event0101.getParameterMap().put("TestMatchCaseSelected", - new AxField(new AxReferenceKey(event0101.getKey(), "TestMatchCaseSelected"), testCase.getKey())); - event0101.getParameterMap().put("TestMatchStateTime", - new AxField(new AxReferenceKey(event0101.getKey(), "TestMatchStateTime"), testTimestamp.getKey())); - - AxEvent event0102 = new AxEvent(new AxArtifactKey("Event0102", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0102.setSource("Establish"); - event0102.setTarget("Decide"); - event0102.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0102.getKey(), "TestSlogan"), testSlogan.getKey())); - event0102.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0102.getKey(), "TestMatchCase"), testCase.getKey())); - event0102.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0102.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0102.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0102.getKey(), "TestTemperature"), testTemperature.getKey())); - event0102.getParameterMap().put("TestMatchCaseSelected", - new AxField(new AxReferenceKey(event0102.getKey(), "TestMatchCaseSelected"), testCase.getKey())); - event0102.getParameterMap().put("TestMatchStateTime", - new AxField(new AxReferenceKey(event0102.getKey(), "TestMatchStateTime"), testTimestamp.getKey())); - event0102.getParameterMap().put("TestEstablishCaseSelected", - new AxField(new AxReferenceKey(event0102.getKey(), "TestEstablishCaseSelected"), testCase.getKey())); - event0102.getParameterMap().put("TestEstablishStateTime", - new AxField(new AxReferenceKey(event0102.getKey(), "TestEstablishStateTime"), testTimestamp.getKey())); - - AxEvent event0103 = new AxEvent(new AxArtifactKey("Event0103", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0103.setSource("Decide"); - event0103.setTarget("Act"); - event0103.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0103.getKey(), "TestSlogan"), testSlogan.getKey())); - event0103.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0103.getKey(), "TestMatchCase"), testCase.getKey())); - event0103.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0103.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0103.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0103.getKey(), "TestTemperature"), testTemperature.getKey())); - event0103.getParameterMap().put("TestMatchCaseSelected", - new AxField(new AxReferenceKey(event0103.getKey(), "TestMatchCaseSelected"), testCase.getKey())); - event0103.getParameterMap().put("TestMatchStateTime", - new AxField(new AxReferenceKey(event0103.getKey(), "TestMatchStateTime"), testTimestamp.getKey())); - event0103.getParameterMap().put("TestEstablishCaseSelected", - new AxField(new AxReferenceKey(event0103.getKey(), "TestEstablishCaseSelected"), testCase.getKey())); - event0103.getParameterMap().put("TestEstablishStateTime", - new AxField(new AxReferenceKey(event0103.getKey(), "TestEstablishStateTime"), testTimestamp.getKey())); - event0103.getParameterMap().put("TestDecideCaseSelected", - new AxField(new AxReferenceKey(event0103.getKey(), "TestDecideCaseSelected"), testCase.getKey())); - event0103.getParameterMap().put("TestDecideStateTime", - new AxField(new AxReferenceKey(event0103.getKey(), "TestDecideStateTime"), testTimestamp.getKey())); - - AxEvent event0104 = new AxEvent(new AxArtifactKey("Event0104", "0.0.1"), "org.onap.policy.apex.sample.events"); - event0104.setSource("Act"); - event0104.setTarget("Outside"); - event0104.getParameterMap().put("TestSlogan", - new AxField(new AxReferenceKey(event0104.getKey(), "TestSlogan"), testSlogan.getKey())); - event0104.getParameterMap().put("TestMatchCase", - new AxField(new AxReferenceKey(event0104.getKey(), "TestMatchCase"), testCase.getKey())); - event0104.getParameterMap().put("TestTimestamp", - new AxField(new AxReferenceKey(event0104.getKey(), "TestTimestamp"), testTimestamp.getKey())); - event0104.getParameterMap().put("TestTemperature", - new AxField(new AxReferenceKey(event0104.getKey(), "TestTemperature"), testTemperature.getKey())); - event0104.getParameterMap().put("TestMatchCaseSelected", - new AxField(new AxReferenceKey(event0104.getKey(), "TestMatchCaseSelected"), testCase.getKey())); - event0104.getParameterMap().put("TestMatchStateTime", - new AxField(new AxReferenceKey(event0104.getKey(), "TestMatchStateTime"), testTimestamp.getKey())); - event0104.getParameterMap().put("TestEstablishCaseSelected", - new AxField(new AxReferenceKey(event0104.getKey(), "TestEstablishCaseSelected"), testCase.getKey())); - event0104.getParameterMap().put("TestEstablishStateTime", - new AxField(new AxReferenceKey(event0104.getKey(), "TestEstablishStateTime"), testTimestamp.getKey())); - event0104.getParameterMap().put("TestDecideCaseSelected", - new AxField(new AxReferenceKey(event0104.getKey(), "TestDecideCaseSelected"), testCase.getKey())); - event0104.getParameterMap().put("TestDecideStateTime", - new AxField(new AxReferenceKey(event0104.getKey(), "TestDecideStateTime"), testTimestamp.getKey())); - event0104.getParameterMap().put("TestActCaseSelected", - new AxField(new AxReferenceKey(event0104.getKey(), "TestActCaseSelected"), testCase.getKey())); - event0104.getParameterMap().put("TestActStateTime", - new AxField(new AxReferenceKey(event0104.getKey(), "TestActStateTime"), testTimestamp.getKey())); - - AxEvents events = new AxEvents(new AxArtifactKey("Events", "0.0.1")); - events.getEventMap().put(event0000.getKey(), event0000); - events.getEventMap().put(event0001.getKey(), event0001); - events.getEventMap().put(event0002.getKey(), event0002); - events.getEventMap().put(event0003.getKey(), event0003); - events.getEventMap().put(event0004.getKey(), event0004); - events.getEventMap().put(event0100.getKey(), event0100); - events.getEventMap().put(event0101.getKey(), event0101); - events.getEventMap().put(event0102.getKey(), event0102); - events.getEventMap().put(event0103.getKey(), event0103); - events.getEventMap().put(event0104.getKey(), event0104); - - AxContextAlbum externalContextAlbum = new AxContextAlbum(new AxArtifactKey("ExternalContextAlbum", "0.0.1"), - "EXTERNAL", false, testExternalContextItem.getKey()); - AxContextAlbum globalContextAlbum = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"), - "GLOBAL", true, testGlobalContextItem.getKey()); - AxContextAlbum policy0ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy0ContextAlbum", "0.0.1"), - "APPLICATION", true, testPolicyContextItem.getKey()); - AxContextAlbum policy1ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy1ContextAlbum", "0.0.1"), - "APPLICATION", true, testPolicyContextItem.getKey()); - - AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("Context", "0.0.1")); - albums.getAlbumsMap().put(externalContextAlbum.getKey(), externalContextAlbum); - albums.getAlbumsMap().put(globalContextAlbum.getKey(), globalContextAlbum); - albums.getAlbumsMap().put(policy0ContextAlbum.getKey(), policy0ContextAlbum); - albums.getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum); - - Set referenceKeySet0 = new TreeSet(); - referenceKeySet0.add(policy0ContextAlbum.getKey()); - referenceKeySet0.add(policy1ContextAlbum.getKey()); - referenceKeySet0.add(globalContextAlbum.getKey()); - referenceKeySet0.add(externalContextAlbum.getKey()); - - Set referenceKeySet1 = new TreeSet(); - referenceKeySet1.add(policy0ContextAlbum.getKey()); - referenceKeySet1.add(globalContextAlbum.getKey()); - - Set referenceKeySet2 = new TreeSet(); - referenceKeySet2.add(policy1ContextAlbum.getKey()); - referenceKeySet2.add(globalContextAlbum.getKey()); - - Set referenceKeySet3 = new TreeSet(); - referenceKeySet3.add(globalContextAlbum.getKey()); - referenceKeySet3.add(externalContextAlbum.getKey()); - - List> referenceKeySetList = new ArrayList>(); - referenceKeySetList.add(referenceKeySet0); - referenceKeySetList.add(referenceKeySet1); - referenceKeySetList.add(referenceKeySet2); - referenceKeySetList.add(referenceKeySet3); - - AxTasks tasks = new AxTasks(new AxArtifactKey("Tasks", "0.0.1")); - tasks.getTaskMap().putAll(getTaskMap("Match", event0000.getParameterMap(), event0001.getParameterMap(), - referenceKeySetList, axLogicExecutorType)); - tasks.getTaskMap().putAll(getTaskMap("Establish", event0001.getParameterMap(), event0002.getParameterMap(), - referenceKeySetList, axLogicExecutorType)); - tasks.getTaskMap().putAll(getTaskMap("Decide", event0002.getParameterMap(), event0003.getParameterMap(), - referenceKeySetList, axLogicExecutorType)); - tasks.getTaskMap().putAll(getTaskMap("Act", event0003.getParameterMap(), event0004.getParameterMap(), - referenceKeySetList, axLogicExecutorType)); - - Set matchTasks = new TreeSet(); - Set establishTasks = new TreeSet(); - Set decideTasks = new TreeSet(); - Set actTasks = new TreeSet(); - for (AxTask task : tasks.getTaskMap().values()) { - if (task.getKey().getName().contains("Match")) { - matchTasks.add(task.getKey()); - } - if (task.getKey().getName().contains("Establish")) { - establishTasks.add(task.getKey()); - } - if (task.getKey().getName().contains("Decide")) { - decideTasks.add(task.getKey()); - } - if (task.getKey().getName().contains("Act")) { - actTasks.add(task.getKey()); - } - } - List> taskReferenceList = new ArrayList>(); - taskReferenceList.add(matchTasks); - taskReferenceList.add(establishTasks); - taskReferenceList.add(decideTasks); - taskReferenceList.add(actTasks); - - List p0InEventList = new ArrayList(); - p0InEventList.add(event0000.getKey()); - p0InEventList.add(event0001.getKey()); - p0InEventList.add(event0002.getKey()); - p0InEventList.add(event0003.getKey()); - - List p0OutEventList = new ArrayList(); - p0OutEventList.add(event0001.getKey()); - p0OutEventList.add(event0002.getKey()); - p0OutEventList.add(event0003.getKey()); - p0OutEventList.add(event0004.getKey()); - - List p0defaultTaskList = new ArrayList(); - p0defaultTaskList.add(tasks.get("Task_Match0").getKey()); - p0defaultTaskList.add(tasks.get("Task_Establish2").getKey()); - p0defaultTaskList.add(tasks.get("Task_Decide3").getKey()); - p0defaultTaskList.add(tasks.get("Task_Act1").getKey()); - - List p1InEventList = new ArrayList(); - p1InEventList.add(event0100.getKey()); - p1InEventList.add(event0101.getKey()); - p1InEventList.add(event0102.getKey()); - p1InEventList.add(event0103.getKey()); - - List p1OutEventList = new ArrayList(); - p1OutEventList.add(event0101.getKey()); - p1OutEventList.add(event0102.getKey()); - p1OutEventList.add(event0103.getKey()); - p1OutEventList.add(event0104.getKey()); - - List p1defaultTaskList = new ArrayList(); - p1defaultTaskList.add(tasks.get("Task_Match3").getKey()); - p1defaultTaskList.add(tasks.get("Task_Establish1").getKey()); - p1defaultTaskList.add(tasks.get("Task_Decide3").getKey()); - p1defaultTaskList.add(tasks.get("Task_Act0").getKey()); - - Set p0ReferenceKeySet0 = new TreeSet(); - p0ReferenceKeySet0.add(policy0ContextAlbum.getKey()); - p0ReferenceKeySet0.add(globalContextAlbum.getKey()); - - Set p0ReferenceKeySet1 = new TreeSet(); - p0ReferenceKeySet1.add(policy1ContextAlbum.getKey()); - p0ReferenceKeySet1.add(globalContextAlbum.getKey()); - p0ReferenceKeySet1.add(externalContextAlbum.getKey()); - - Set p0ReferenceKeySet2 = new TreeSet(); - p0ReferenceKeySet2.add(policy0ContextAlbum.getKey()); - p0ReferenceKeySet2.add(globalContextAlbum.getKey()); - p0ReferenceKeySet2.add(externalContextAlbum.getKey()); - - Set p0ReferenceKeySet3 = new TreeSet(); - p0ReferenceKeySet3.add(globalContextAlbum.getKey()); - - List> p0ReferenceKeySetList = new ArrayList>(); - p0ReferenceKeySetList.add(p0ReferenceKeySet0); - p0ReferenceKeySetList.add(p0ReferenceKeySet1); - p0ReferenceKeySetList.add(p0ReferenceKeySet2); - p0ReferenceKeySetList.add(p0ReferenceKeySet3); - - AxPolicy policy0 = new AxPolicy(new AxArtifactKey("Policy0", "0.0.1")); - policy0.setTemplate("MEDA"); - policy0.setStateMap(getStateMap(policy0.getKey(), p0InEventList, p0OutEventList, p0ReferenceKeySetList, - axLogicExecutorType, p0defaultTaskList, taskReferenceList)); - policy0.setFirstState(policy0.getStateMap().get("Match").getKey().getLocalName()); - - Set p1ReferenceKeySet0 = new TreeSet(); - p1ReferenceKeySet0.add(policy1ContextAlbum.getKey()); - p1ReferenceKeySet0.add(globalContextAlbum.getKey()); - p1ReferenceKeySet0.add(externalContextAlbum.getKey()); - - Set p1ReferenceKeySet1 = new TreeSet(); - p1ReferenceKeySet1.add(policy1ContextAlbum.getKey()); - p1ReferenceKeySet1.add(globalContextAlbum.getKey()); - p1ReferenceKeySet1.add(externalContextAlbum.getKey()); - - Set p1ReferenceKeySet2 = new TreeSet(); - p1ReferenceKeySet2.add(policy1ContextAlbum.getKey()); - p1ReferenceKeySet2.add(globalContextAlbum.getKey()); - p1ReferenceKeySet2.add(externalContextAlbum.getKey()); - - Set p1ReferenceKeySet3 = new TreeSet(); - p1ReferenceKeySet3.add(globalContextAlbum.getKey()); - - List> p1ReferenceKeySetList = new ArrayList>(); - p1ReferenceKeySetList.add(p1ReferenceKeySet0); - p1ReferenceKeySetList.add(p1ReferenceKeySet1); - p1ReferenceKeySetList.add(p1ReferenceKeySet2); - p1ReferenceKeySetList.add(p1ReferenceKeySet3); - - AxPolicy policy1 = new AxPolicy(new AxArtifactKey("Policy1", "0.0.1")); - policy1.setTemplate("MEDA"); - policy1.setStateMap(getStateMap(policy1.getKey(), p1InEventList, p1OutEventList, p1ReferenceKeySetList, - axLogicExecutorType, p1defaultTaskList, taskReferenceList)); - policy1.setFirstState(policy1.getStateMap().get("Match").getKey().getLocalName()); - - AxPolicies policies = new AxPolicies(new AxArtifactKey("Policies", "0.0.1")); - policies.getPolicyMap().put(policy0.getKey(), policy0); - policies.getPolicyMap().put(policy1.getKey(), policy1); - - AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInformation", "0.0.1")); - AxPolicyModel policyModel = - new AxPolicyModel(new AxArtifactKey("SamplePolicyModel" + axLogicExecutorType, "0.0.1")); - policyModel.setKeyInformation(keyInformation); - policyModel.setPolicies(policies); - policyModel.setEvents(events); - policyModel.setTasks(tasks); - policyModel.setAlbums(albums); - policyModel.setSchemas(axContextSchemas); - policyModel.getKeyInformation().generateKeyInfo(policyModel); - - AxValidationResult result = policyModel.validate(new AxValidationResult()); - if (!result.getValidationResult().equals(AxValidationResult.ValidationResult.VALID)) { - throw new ApexRuntimeException("model " + policyModel.getId() + " is not valid" + result); - } - return policyModel; - } - - /** - * Gets the state map. - * - * @param policyKey the policy key - * @param inEventKeyList the in event key list - * @param outEventKeyList the out event key list - * @param referenceKeySetList the reference key set list - * @param axLogicExecutorType the ax logic executor type - * @param defaultTaskList the default task list - * @param taskKeySetList the task key set list - * @return the state map - */ - private Map getStateMap(final AxArtifactKey policyKey, final List inEventKeyList, - final List outEventKeyList, final List> referenceKeySetList, - final String axLogicExecutorType, final List defaultTaskList, - final List> taskKeySetList) { - AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(this.getClass().getPackage().getName()) - .setDefaultLogic("DefaultState_Logic"); - - AxState actState = new AxState(new AxReferenceKey(policyKey, "Act")); - actState.setTrigger(inEventKeyList.get(3)); - AxStateOutput act2Out = - new AxStateOutput(actState.getKey(), AxReferenceKey.getNullKey(), outEventKeyList.get(3)); - actState.getStateOutputs().put(act2Out.getKey().getLocalName(), act2Out); - actState.setContextAlbumReferences(referenceKeySetList.get(3)); - actState.setTaskSelectionLogic( - new AxTaskSelectionLogic(actState.getKey(), "TaskSelectionLigic", axLogicExecutorType, logicReader)); - actState.setDefaultTask(defaultTaskList.get(3)); - for (AxArtifactKey taskKey : taskKeySetList.get(3)) { - actState.getTaskReferences().put(taskKey, new AxStateTaskReference(actState.getKey(), taskKey, - AxStateTaskOutputType.DIRECT, act2Out.getKey())); - } - - AxState decideState = new AxState(new AxReferenceKey(policyKey, "Decide")); - decideState.setTrigger(inEventKeyList.get(2)); - AxStateOutput decide2Act = new AxStateOutput(decideState.getKey(), actState.getKey(), outEventKeyList.get(2)); - decideState.getStateOutputs().put(decide2Act.getKey().getLocalName(), decide2Act); - decideState.setContextAlbumReferences(referenceKeySetList.get(2)); - decideState.setTaskSelectionLogic( - new AxTaskSelectionLogic(decideState.getKey(), "TaskSelectionLigic", axLogicExecutorType, logicReader)); - decideState.setDefaultTask(defaultTaskList.get(2)); - for (AxArtifactKey taskKey : taskKeySetList.get(2)) { - decideState.getTaskReferences().put(taskKey, new AxStateTaskReference(decideState.getKey(), taskKey, - AxStateTaskOutputType.DIRECT, decide2Act.getKey())); - } - - AxState establishState = new AxState(new AxReferenceKey(policyKey, "Establish")); - establishState.setTrigger(inEventKeyList.get(1)); - AxStateOutput establish2Decide = - new AxStateOutput(establishState.getKey(), decideState.getKey(), outEventKeyList.get(1)); - establishState.getStateOutputs().put(establish2Decide.getKey().getLocalName(), establish2Decide); - establishState.setContextAlbumReferences(referenceKeySetList.get(1)); - establishState.setTaskSelectionLogic(new AxTaskSelectionLogic(establishState.getKey(), "TaskSelectionLigic", - axLogicExecutorType, logicReader)); - establishState.setDefaultTask(defaultTaskList.get(1)); - for (AxArtifactKey taskKey : taskKeySetList.get(1)) { - establishState.getTaskReferences().put(taskKey, new AxStateTaskReference(establishState.getKey(), taskKey, - AxStateTaskOutputType.DIRECT, establish2Decide.getKey())); - } - - AxState matchState = new AxState(new AxReferenceKey(policyKey, "Match")); - matchState.setTrigger(inEventKeyList.get(0)); - AxStateOutput match2Establish = - new AxStateOutput(matchState.getKey(), establishState.getKey(), outEventKeyList.get(0)); - matchState.getStateOutputs().put(match2Establish.getKey().getLocalName(), match2Establish); - matchState.setContextAlbumReferences(referenceKeySetList.get(0)); - matchState.setTaskSelectionLogic( - new AxTaskSelectionLogic(matchState.getKey(), "TaskSelectionLigic", axLogicExecutorType, logicReader)); - matchState.setDefaultTask(defaultTaskList.get(0)); - for (AxArtifactKey taskKey : taskKeySetList.get(0)) { - matchState.getTaskReferences().put(taskKey, new AxStateTaskReference(matchState.getKey(), taskKey, - AxStateTaskOutputType.DIRECT, match2Establish.getKey())); - } - - Map stateMap = new TreeMap(); - stateMap.put(matchState.getKey().getLocalName(), matchState); - stateMap.put(establishState.getKey().getLocalName(), establishState); - stateMap.put(decideState.getKey().getLocalName(), decideState); - stateMap.put(actState.getKey().getLocalName(), actState); - - return stateMap; - } - // CHECKSTYLE:ON: checkstyle:maximumMethodLength - - /** - * Gets the task map. - * - * @param state the state - * @param inputFields the input fields - * @param outputFields the output fields - * @param referenceKeySetList the reference key set list - * @param axLogicExecutorType the ax logic executor type - * @return the task map - */ - private Map getTaskMap(final String state, final Map inputFields, - final Map outputFields, final List> referenceKeySetList, - final String axLogicExecutorType) { - AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(this.getClass().getPackage().getName()) - .setDefaultLogic("DefaultTask_Logic"); - - AxTask testTask0 = new AxTask(new AxArtifactKey("Task_" + state + "0", "0.0.1")); - testTask0.duplicateInputFields(inputFields); - testTask0.duplicateOutputFields(outputFields); - AxTaskParameter parameter00 = - new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), "Parameter0"), "DefaultValue0"); - AxTaskParameter parameter01 = - new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), "Parameter1"), "DefaultValue1"); - AxTaskParameter parameter02 = - new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), "Parameter2"), "DefaultValue2"); - testTask0.getTaskParameters().put(parameter00.getKey().getLocalName(), parameter00); - testTask0.getTaskParameters().put(parameter01.getKey().getLocalName(), parameter01); - testTask0.getTaskParameters().put(parameter02.getKey().getLocalName(), parameter02); - testTask0.setContextAlbumReferences(referenceKeySetList.get(0)); - testTask0.setTaskLogic(getTaskLogic(testTask0, logicReader, axLogicExecutorType, state, "2")); - - AxTask testTask1 = new AxTask(new AxArtifactKey("Task_" + state + "1", "0.0.1")); - testTask1.duplicateInputFields(inputFields); - testTask1.duplicateOutputFields(outputFields); - AxTaskParameter parameter10 = - new AxTaskParameter(new AxReferenceKey(testTask1.getKey(), "Parameter0"), "DefaultValue0"); - AxTaskParameter parameter11 = - new AxTaskParameter(new AxReferenceKey(testTask1.getKey(), "Parameter1"), "DefaultValue1"); - testTask1.getTaskParameters().put(parameter10.getKey().getLocalName(), parameter10); - testTask1.getTaskParameters().put(parameter11.getKey().getLocalName(), parameter11); - testTask1.setContextAlbumReferences(referenceKeySetList.get(1)); - testTask1.setTaskLogic(getTaskLogic(testTask1, logicReader, axLogicExecutorType, state, "3")); - - AxTask testTask2 = new AxTask(new AxArtifactKey("Task_" + state + "2", "0.0.1")); - testTask2.duplicateInputFields(inputFields); - testTask2.duplicateOutputFields(outputFields); - AxTaskParameter parameter20 = - new AxTaskParameter(new AxReferenceKey(testTask2.getKey(), "Parameter0"), "DefaultValue0"); - testTask2.getTaskParameters().put(parameter20.getKey().getLocalName(), parameter20); - testTask2.setContextAlbumReferences(referenceKeySetList.get(2)); - testTask2.setTaskLogic(getTaskLogic(testTask2, logicReader, axLogicExecutorType, state, "0")); - - AxTask testTask3 = new AxTask(new AxArtifactKey("Task_" + state + "3", "0.0.1")); - testTask3.duplicateInputFields(inputFields); - testTask3.duplicateOutputFields(outputFields); - AxTaskParameter parameter30 = - new AxTaskParameter(new AxReferenceKey(testTask3.getKey(), "Parameter0"), "DefaultValue0"); - testTask3.getTaskParameters().put(parameter30.getKey().getLocalName(), parameter30); - testTask3.setContextAlbumReferences(referenceKeySetList.get(THIRD_ENTRY)); - testTask3.setTaskLogic(getTaskLogic(testTask3, logicReader, axLogicExecutorType, state, "1")); - - Map taskMap = new TreeMap(); - taskMap.put(testTask0.getKey(), testTask0); - taskMap.put(testTask1.getKey(), testTask1); - taskMap.put(testTask2.getKey(), testTask2); - taskMap.put(testTask3.getKey(), testTask3); - - return taskMap; - } - - /** - * Gets the task logic. - * - * @param task the task - * @param logicReader the logic reader - * @param logicFlavour the logic flavour - * @param stateName the state name - * @param caseToUse the case to use - * @return the task logic - */ - private AxTaskLogic getTaskLogic(final AxTask task, final AxLogicReader logicReader, final String logicFlavour, - final String stateName, final String caseToUse) { - AxTaskLogic axLogic = - new AxTaskLogic(new AxReferenceKey(task.getKey(), "_TaskLogic"), logicFlavour, logicReader); - - axLogic.setLogic(axLogic.getLogic().replaceAll("", stateName) - .replaceAll("", task.getKey().getName()).replaceAll("", caseToUse)); - - return axLogic; - } -} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelSaver.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelSaver.java deleted file mode 100644 index 6ca644ff4..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelSaver.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -package org.onap.policy.apex.test.common.model; - -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; - -/** - * This class saves sample domain models to disk in XML and JSON format. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public final class SampleDomainModelSaver { - /** - * Private default constructor to prevent subclassing. - */ - private SampleDomainModelSaver() { - } - - /** - * Write the sample Models to args[0]. - * - * @param args Not used - * @throws ApexException the apex exception - */ - public static void main(final String[] args) throws ApexException { - if (args.length != 1) { - System.err.println("usage: " + SampleDomainModelSaver.class.getCanonicalName() + " modelDirectory"); - return; - } - - // Save Java model - final AxPolicyModel javaPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVA"); - final ApexModelSaver javaModelSaver = new ApexModelSaver(AxPolicyModel.class, javaPolicyModel, args[0]); - javaModelSaver.apexModelWriteJson(); - javaModelSaver.apexModelWriteXml(); - - // Save Javascript model - final AxPolicyModel javascriptPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT"); - final ApexModelSaver javascriptModelSaver = new ApexModelSaver(AxPolicyModel.class, javascriptPolicyModel, args[0]); - javascriptModelSaver.apexModelWriteJson(); - javascriptModelSaver.apexModelWriteXml(); - - // Save JRuby model - final AxPolicyModel jRubyPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JRUBY"); - final ApexModelSaver jRubyModelSaver = new ApexModelSaver(AxPolicyModel.class, jRubyPolicyModel, args[0]); - jRubyModelSaver.apexModelWriteJson(); - jRubyModelSaver.apexModelWriteXml(); - - // Save Jython model - final AxPolicyModel jythonPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JYTHON"); - final ApexModelSaver jythonModelSaver = new ApexModelSaver(AxPolicyModel.class, jythonPolicyModel, args[0]); - jythonModelSaver.apexModelWriteJson(); - jythonModelSaver.apexModelWriteXml(); - - // Save MVEL model - final AxPolicyModel mvelPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL"); - final ApexModelSaver mvelModelSaver = new ApexModelSaver(AxPolicyModel.class, mvelPolicyModel, args[0]); - mvelModelSaver.apexModelWriteJson(); - mvelModelSaver.apexModelWriteXml(); - } - -} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultState_Logic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultState_Logic.java deleted file mode 100644 index d970835d0..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultState_Logic.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -package org.onap.policy.apex.test.common.model.java; - -import org.onap.policy.apex.core.engine.executor.context.TaskSelectionExecutionContext; - -/** - * The Class DefaultState_Logic is default task selection logic in Java. - */ -// CHECKSTYLE:OFF: checkstyle:typeNames -public class DefaultState_Logic { - // CHECKSTYLE:ON: checkstyle:typeNames - /** - * Gets the task. - * - * @param executor the executor - * @return the task - */ - public boolean getTask(final TaskSelectionExecutionContext executor) { - executor.logger.debug(executor.subject.getId()); - executor.logger.debug(executor.getContextAlbum("GlobalContextAlbum").getName()); - executor.subject.getDefaultTaskKey().copyTo(executor.selectedTask); - return true; - } -} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultTask_Logic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultTask_Logic.java deleted file mode 100644 index b22f15d90..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultTask_Logic.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -package org.onap.policy.apex.test.common.model.java; - -import java.util.Date; -import java.util.Random; - -import org.onap.policy.apex.core.engine.executor.context.TaskExecutionContext; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; - -/** - * The Class DefaultTask_Logic is default task logic in Java. - */ -//CHECKSTYLE:OFF: checkstyle:typeNames -public class DefaultTask_Logic { -// CHECKSTYLE:ON: checkstyle:typeNames - private static final int BOUND_FOR_RANDOM_INT = 4; - - /** - * Gets the event. - * - * @param executor the executor - * @return the event - * @throws ApexException the apex exception - */ - public boolean getEvent(final TaskExecutionContext executor) throws ApexException { - executor.logger.debug(executor.subject.getId()); - executor.logger.debug(executor.getContextAlbum("GlobalContextAlbum").getName()); - executor.logger.debug(executor.inFields.toString()); - - final Date timeNow = new Date(); - final Random rand = new Random(); - - if (executor.inFields.containsKey("TestDecideCaseSelected")) { - executor.outFields.put("TestActCaseSelected", new Byte((byte) rand.nextInt(BOUND_FOR_RANDOM_INT))); - executor.outFields.put("TestActStateTime", timeNow.getTime()); - } - else if (executor.inFields.containsKey("TestEstablishCaseSelected")) { - executor.outFields.put("TestDecideCaseSelected", new Byte((byte) rand.nextInt(BOUND_FOR_RANDOM_INT))); - executor.outFields.put("TestDecideStateTime", timeNow.getTime()); - } - else if (executor.inFields.containsKey("TestMatchCaseSelected")) { - executor.outFields.put("TestEstablishCaseSelected", new Byte((byte) rand.nextInt(BOUND_FOR_RANDOM_INT))); - executor.outFields.put("TestEstablishStateTime", timeNow.getTime()); - } - else { - executor.outFields.put("TestMatchCaseSelected", new Byte((byte) rand.nextInt(BOUND_FOR_RANDOM_INT))); - executor.outFields.put("TestMatchStateTime", timeNow.getTime()); - } - - return true; - } -} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalState_Logic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalState_Logic.java deleted file mode 100644 index 2180936ed..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalState_Logic.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -package org.onap.policy.apex.test.common.model.java; - -import org.onap.policy.apex.core.engine.executor.context.TaskSelectionExecutionContext; - -/** - * The Class EvalState_Logic is default evaluation task selection logic in Java. - */ -//CHECKSTYLE:OFF: checkstyle:typeNames -public class EvalState_Logic { - // CHECKSTYLE:ON: checkstyle:typeNames - /** - * Gets the task. - * - * @param executor the executor - * @return the task - */ - public boolean getTask(final TaskSelectionExecutionContext executor) { - executor.logger.debug(executor.subject.getId()); - executor.subject.getDefaultTaskKey().copyTo(executor.selectedTask); - return true; - } -} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalTask_Logic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalTask_Logic.java deleted file mode 100644 index f4fa533f8..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalTask_Logic.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -package org.onap.policy.apex.test.common.model.java; - -import java.util.Date; - -import org.onap.policy.apex.core.engine.executor.context.TaskExecutionContext; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; - -/** - * The Class EvalTask_Logic is default evaluation task logic in Java. - */ -public class EvalTask_Logic { - - /** - * Gets the event. - * - * @param executor the executor - * @return the event - * @throws ApexException the apex exception - */ - public boolean getEvent(final TaskExecutionContext executor) throws ApexException { - executor.logger.debug(executor.subject.getId()); - executor.logger.debug(executor.inFields.toString()); - executor.outFields.putAll(executor.inFields); - - final Date timeNow = new Date(); - executor.outFields.put("State3Timestamp", timeNow.getTime()); - executor.logger.debug(executor.outFields.toString()); - return true; - } -} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/package-info.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/package-info.java deleted file mode 100644 index 70c8452b5..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -/** - * Contains the Javadomain specific logic for the test domain. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -package org.onap.policy.apex.test.common.model.java; diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/package-info.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/package-info.java deleted file mode 100644 index 9277bd43c..000000000 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -/** - * Executes tests using all the APEX executors on a test domain model. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -package org.onap.policy.apex.test.common.model; diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactory.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactory.java new file mode 100644 index 000000000..a36aa1030 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactory.java @@ -0,0 +1,585 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +package org.onap.policy.apex.testsuites.integration.common.model; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; +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.AxEvents; +import org.onap.policy.apex.model.eventmodel.concepts.AxField; +import org.onap.policy.apex.model.policymodel.concepts.AxLogicReader; +import org.onap.policy.apex.model.policymodel.concepts.AxPolicies; +import org.onap.policy.apex.model.policymodel.concepts.AxPolicy; +import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; +import org.onap.policy.apex.model.policymodel.concepts.AxState; +import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput; +import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType; +import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference; +import org.onap.policy.apex.model.policymodel.concepts.AxTask; +import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic; +import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic; +import org.onap.policy.apex.model.policymodel.concepts.AxTasks; +import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader; + +/** + * This class creates sample evaluation Policy Models. + * + * @author John Keeney (john.keeney@ericsson.com) + */ +public class EvalDomainModelFactory { + // Recurring string constants + private static final String ACTION = "Action"; + private static final String CONDITION = "Condition"; + private static final String EVENT = "Event"; + private static final String TASK_SELECTION_LOGIC = "TaskSelectionLogic"; + private static final String JYTHON = "JYTHON"; + private static final String ORIENT = "Orient"; + private static final String STATE_NAME = ""; + private static final String OBSERVE = "Observe"; + private static final String JAVASCRIPT = "JAVASCRIPT"; + private static final String TASK_NAME = ""; + private static final String TASK_LOGIC = "TaskLogic"; + private static final String STATE_NUMBER = ""; + private static final String STATE3_TIMESTAMP = "State3Timestamp"; + private static final String EVENT_NUMBER = "EventNumber"; + private static final String FIRST_EVENT_TIMESTAMP = "FirstEventTimestamp"; + private static final String STATE2_TIMESTAMP = "State2Timestamp"; + private static final String STATE1_TIMESTAMP = "State1Timestamp"; + private static final String TEST_TEMPERATURE = "TestTemperature"; + private static final String SENT_TIMESTAMP = "SentTimestamp"; + private static final String EVENT_TAG = ".events"; + private static final String DEFAULT_VERSION = "0.0.1"; + + private static final int THIRD_MEMBER = 3; + + private static final String PACKAGE = EvalDomainModelFactory.class.getPackage().getName(); + + private String justOneLang = null; + + private final AxContextSchema typeTimestamp; + private final AxContextSchema typeDouble; + private final AxContextSchema typeCounter; + private final AxContextSchemas schemas; + private final AxEvent event0000; + private final AxEvent event0001; + private final AxEvent event0002; + private final AxEvent event0003; + private final AxEvent event0004; + private final AxEvents events; + + /** + * The Constructor for the factory. + */ + public EvalDomainModelFactory() { + this(null); + } + + /** + * The Constructor for the factory that creates models for a single executor language flavour. + * + * @param justOneLang the just one lang + */ + public EvalDomainModelFactory(final String justOneLang) { + this.justOneLang = justOneLang; + + typeTimestamp = new AxContextSchema(new AxArtifactKey("TestTimestamp", DEFAULT_VERSION), "Java", + "java.lang.Long"); + typeDouble = new AxContextSchema(new AxArtifactKey(TEST_TEMPERATURE, DEFAULT_VERSION), "Java", + "java.lang.Double"); + typeCounter = new AxContextSchema(new AxArtifactKey("TestTimestamp", DEFAULT_VERSION), "Java", + "java.lang.Long"); + + schemas = new AxContextSchemas(new AxArtifactKey("TestDatatypes", DEFAULT_VERSION)); + schemas.getSchemasMap().put(typeTimestamp.getKey(), typeTimestamp); + schemas.getSchemasMap().put(typeDouble.getKey(), typeDouble); + schemas.getSchemasMap().put(typeCounter.getKey(), typeCounter); + + event0000 = new AxEvent(new AxArtifactKey("Event0000", DEFAULT_VERSION), PACKAGE + EVENT_TAG); + event0000.getParameterMap().put(SENT_TIMESTAMP, + new AxField(new AxReferenceKey(event0000.getKey(), SENT_TIMESTAMP), typeTimestamp.getKey())); + event0000.getParameterMap().put(TEST_TEMPERATURE, + new AxField(new AxReferenceKey(event0000.getKey(), TEST_TEMPERATURE), typeDouble.getKey())); + event0000.getParameterMap().put(FIRST_EVENT_TIMESTAMP, new AxField( + new AxReferenceKey(event0000.getKey(), FIRST_EVENT_TIMESTAMP), typeTimestamp.getKey())); + event0000.getParameterMap().put(EVENT_NUMBER, + new AxField(new AxReferenceKey(event0000.getKey(), EVENT_NUMBER), typeCounter.getKey())); + + event0001 = new AxEvent(new AxArtifactKey("Event0001", DEFAULT_VERSION), PACKAGE + EVENT_TAG); + event0001.getParameterMap().put(SENT_TIMESTAMP, + new AxField(new AxReferenceKey(event0001.getKey(), SENT_TIMESTAMP), typeTimestamp.getKey())); + event0001.getParameterMap().put(STATE1_TIMESTAMP, + new AxField(new AxReferenceKey(event0001.getKey(), STATE1_TIMESTAMP), typeTimestamp.getKey())); + event0001.getParameterMap().put(TEST_TEMPERATURE, + new AxField(new AxReferenceKey(event0001.getKey(), TEST_TEMPERATURE), typeDouble.getKey())); + event0001.getParameterMap().put(FIRST_EVENT_TIMESTAMP, new AxField( + new AxReferenceKey(event0001.getKey(), FIRST_EVENT_TIMESTAMP), typeTimestamp.getKey())); + event0001.getParameterMap().put(EVENT_NUMBER, + new AxField(new AxReferenceKey(event0001.getKey(), EVENT_NUMBER), typeCounter.getKey())); + + event0002 = new AxEvent(new AxArtifactKey("Event0002", DEFAULT_VERSION), PACKAGE + EVENT_TAG); + event0002.getParameterMap().put(SENT_TIMESTAMP, + new AxField(new AxReferenceKey(event0002.getKey(), SENT_TIMESTAMP), typeTimestamp.getKey())); + event0002.getParameterMap().put(STATE1_TIMESTAMP, + new AxField(new AxReferenceKey(event0002.getKey(), STATE1_TIMESTAMP), typeTimestamp.getKey())); + event0002.getParameterMap().put(STATE2_TIMESTAMP, + new AxField(new AxReferenceKey(event0002.getKey(), STATE2_TIMESTAMP), typeTimestamp.getKey())); + event0002.getParameterMap().put(TEST_TEMPERATURE, + new AxField(new AxReferenceKey(event0002.getKey(), TEST_TEMPERATURE), typeDouble.getKey())); + event0002.getParameterMap().put(FIRST_EVENT_TIMESTAMP, new AxField( + new AxReferenceKey(event0002.getKey(), FIRST_EVENT_TIMESTAMP), typeTimestamp.getKey())); + event0002.getParameterMap().put(EVENT_NUMBER, + new AxField(new AxReferenceKey(event0002.getKey(), EVENT_NUMBER), typeCounter.getKey())); + + event0003 = new AxEvent(new AxArtifactKey("Event0003", DEFAULT_VERSION), PACKAGE + EVENT_TAG); + event0003.getParameterMap().put(SENT_TIMESTAMP, + new AxField(new AxReferenceKey(event0003.getKey(), SENT_TIMESTAMP), typeTimestamp.getKey())); + event0003.getParameterMap().put(STATE1_TIMESTAMP, + new AxField(new AxReferenceKey(event0003.getKey(), STATE1_TIMESTAMP), typeTimestamp.getKey())); + event0003.getParameterMap().put(STATE2_TIMESTAMP, + new AxField(new AxReferenceKey(event0003.getKey(), STATE2_TIMESTAMP), typeTimestamp.getKey())); + event0003.getParameterMap().put(STATE3_TIMESTAMP, + new AxField(new AxReferenceKey(event0003.getKey(), STATE3_TIMESTAMP), typeTimestamp.getKey())); + event0003.getParameterMap().put(TEST_TEMPERATURE, + new AxField(new AxReferenceKey(event0003.getKey(), TEST_TEMPERATURE), typeDouble.getKey())); + event0003.getParameterMap().put(FIRST_EVENT_TIMESTAMP, new AxField( + new AxReferenceKey(event0003.getKey(), FIRST_EVENT_TIMESTAMP), typeTimestamp.getKey())); + event0003.getParameterMap().put(EVENT_NUMBER, + new AxField(new AxReferenceKey(event0003.getKey(), EVENT_NUMBER), typeCounter.getKey())); + + event0004 = new AxEvent(new AxArtifactKey("Event0004", DEFAULT_VERSION), PACKAGE + EVENT_TAG); + event0004.getParameterMap().put(SENT_TIMESTAMP, + new AxField(new AxReferenceKey(event0004.getKey(), SENT_TIMESTAMP), typeTimestamp.getKey())); + event0004.getParameterMap().put(STATE1_TIMESTAMP, + new AxField(new AxReferenceKey(event0004.getKey(), STATE1_TIMESTAMP), typeTimestamp.getKey())); + event0004.getParameterMap().put(STATE2_TIMESTAMP, + new AxField(new AxReferenceKey(event0004.getKey(), STATE2_TIMESTAMP), typeTimestamp.getKey())); + event0004.getParameterMap().put(STATE3_TIMESTAMP, + new AxField(new AxReferenceKey(event0004.getKey(), STATE3_TIMESTAMP), typeTimestamp.getKey())); + event0004.getParameterMap().put("State4Timestamp", + new AxField(new AxReferenceKey(event0004.getKey(), "State4Timestamp"), typeTimestamp.getKey())); + event0004.getParameterMap().put(TEST_TEMPERATURE, + new AxField(new AxReferenceKey(event0004.getKey(), TEST_TEMPERATURE), typeDouble.getKey())); + event0004.getParameterMap().put(FIRST_EVENT_TIMESTAMP, new AxField( + new AxReferenceKey(event0004.getKey(), FIRST_EVENT_TIMESTAMP), typeTimestamp.getKey())); + event0004.getParameterMap().put(EVENT_NUMBER, + new AxField(new AxReferenceKey(event0004.getKey(), EVENT_NUMBER), typeCounter.getKey())); + + events = new AxEvents(new AxArtifactKey("Events", DEFAULT_VERSION)); + events.getEventMap().put(event0000.getKey(), event0000); + events.getEventMap().put(event0001.getKey(), event0001); + events.getEventMap().put(event0002.getKey(), event0002); + events.getEventMap().put(event0003.getKey(), event0003); + events.getEventMap().put(event0004.getKey(), event0004); + } + + /** + * Get a sample OODA policy model. + * + * @return the sample policy model + */ + public AxPolicyModel getOodaPolicyModel() { + final AxTasks tasks = new AxTasks(new AxArtifactKey("Tasks", "0.0.1")); + + final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE) + .setDefaultLogic("EvalTask_Logic"); + + final AxTask obTask = new AxTask(new AxArtifactKey("Task_Observe_0", "0.0.1")); + obTask.duplicateInputFields(event0000.getParameterMap()); + obTask.duplicateOutputFields(event0001.getParameterMap()); + final AxTaskLogic obAxLogic = new AxTaskLogic(obTask.getKey(), TASK_LOGIC, + (justOneLang == null ? "JRUBY" : justOneLang), logicReader); + obAxLogic.setLogic(obAxLogic.getLogic().replaceAll(STATE_NAME, OBSERVE) + .replaceAll(TASK_NAME, obTask.getKey().getName()).replaceAll(STATE_NUMBER, "1")); + obTask.setTaskLogic(obAxLogic); + + final AxTask orTask = new AxTask(new AxArtifactKey("Task_Orient_0", "0.0.1")); + orTask.duplicateInputFields(event0001.getParameterMap()); + orTask.duplicateOutputFields(event0002.getParameterMap()); + final AxTaskLogic orAxLogic = new AxTaskLogic(orTask.getKey(), TASK_LOGIC, + (justOneLang == null ? JAVASCRIPT : justOneLang), logicReader); + orAxLogic.setLogic(orAxLogic.getLogic().replaceAll(STATE_NAME, ORIENT) + .replaceAll(TASK_NAME, orTask.getKey().getName()).replaceAll(STATE_NUMBER, "2")); + orTask.setTaskLogic(orAxLogic); + + final AxTask dTask = new AxTask(new AxArtifactKey("Task_Decide_0", "0.0.1")); + dTask.duplicateInputFields(event0002.getParameterMap()); + dTask.duplicateOutputFields(event0003.getParameterMap()); + final AxTaskLogic dAxLogic = new AxTaskLogic(dTask.getKey(), TASK_LOGIC, + (justOneLang == null ? "MVEL" : justOneLang), logicReader); + dAxLogic.setLogic(dAxLogic.getLogic().replaceAll(STATE_NAME, ORIENT) + .replaceAll(TASK_NAME, dTask.getKey().getName()).replaceAll(STATE_NUMBER, "3")); + dTask.setTaskLogic(dAxLogic); + + final AxTask aTask = new AxTask(new AxArtifactKey("Task_Act_0", "0.0.1")); + aTask.duplicateInputFields(event0003.getParameterMap()); + aTask.duplicateOutputFields(event0004.getParameterMap()); + final AxTaskLogic aAxLogic = new AxTaskLogic(aTask.getKey(), TASK_LOGIC, + (justOneLang == null ? "JAVA" : justOneLang), logicReader); + aAxLogic.setLogic(aAxLogic.getLogic().replaceAll(STATE_NAME, "Act") + .replaceAll(TASK_NAME, aTask.getKey().getName()).replaceAll(STATE_NUMBER, "4")); + aTask.setTaskLogic(aAxLogic); + + tasks.getTaskMap().put(obTask.getKey(), obTask); + tasks.getTaskMap().put(orTask.getKey(), orTask); + tasks.getTaskMap().put(dTask.getKey(), dTask); + tasks.getTaskMap().put(aTask.getKey(), aTask); + + final Set obTasks = new TreeSet<>(); + final Set orTasks = new TreeSet<>(); + final Set decTasks = new TreeSet<>(); + final Set actTasks = new TreeSet<>(); + + for (final AxTask task : tasks.getTaskMap().values()) { + if (task.getKey().getName().contains(OBSERVE)) { + obTasks.add(task.getKey()); + } + if (task.getKey().getName().contains(ORIENT)) { + orTasks.add(task.getKey()); + } + if (task.getKey().getName().contains("Decide")) { + decTasks.add(task.getKey()); + } + if (task.getKey().getName().contains("Act")) { + actTasks.add(task.getKey()); + } + } + final List> taskReferenceList = new ArrayList<>(); + taskReferenceList.add(obTasks); + taskReferenceList.add(orTasks); + taskReferenceList.add(decTasks); + taskReferenceList.add(actTasks); + + final List p0InEventList = new ArrayList<>(); + p0InEventList.add(event0000.getKey()); + p0InEventList.add(event0001.getKey()); + p0InEventList.add(event0002.getKey()); + p0InEventList.add(event0003.getKey()); + + final List p0OutEventList = new ArrayList<>(); + p0OutEventList.add(event0001.getKey()); + p0OutEventList.add(event0002.getKey()); + p0OutEventList.add(event0003.getKey()); + p0OutEventList.add(event0004.getKey()); + + final List p0defaultTaskList = new ArrayList<>(); + p0defaultTaskList.add(tasks.get("Task_Observe_0").getKey()); + p0defaultTaskList.add(tasks.get("Task_Orient_0").getKey()); + p0defaultTaskList.add(tasks.get("Task_Decide_0").getKey()); + p0defaultTaskList.add(tasks.get("Task_Act_0").getKey()); + + final AxPolicy policy0 = new AxPolicy(new AxArtifactKey("OODAPolicy_0", "0.0.1")); + final List axLogicExecutorTypeList = Arrays.asList((justOneLang == null ? JAVASCRIPT : justOneLang), + (justOneLang == null ? "MVEL" : justOneLang), (justOneLang == null ? JYTHON : justOneLang), + (justOneLang == null ? "JRUBY" : justOneLang)); + policy0.setStateMap(getOodaStateMap(policy0.getKey(), p0InEventList, p0OutEventList, axLogicExecutorTypeList, + p0defaultTaskList, taskReferenceList)); + policy0.setFirstState(policy0.getStateMap().get(OBSERVE).getKey().getLocalName()); + + final AxPolicies policies = new AxPolicies(new AxArtifactKey("OODAPolicies", "0.0.1")); + policies.getPolicyMap().put(policy0.getKey(), policy0); + + final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInformation", "0.0.1")); + final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("EvaluationPolicyModel_OODA", "0.0.1")); + policyModel.setPolicies(policies); + policyModel.setEvents(events); + policyModel.setTasks(tasks); + policyModel.setAlbums(new AxContextAlbums(new AxArtifactKey("Albums", "0.0.1"))); + policyModel.setSchemas(schemas); + policyModel.setKeyInformation(keyInformation); + policyModel.getKeyInformation().generateKeyInfo(policyModel); + + final AxValidationResult result = policyModel.validate(new AxValidationResult()); + if (!result.isOk()) { + throw new ApexRuntimeException("model " + policyModel.getId() + " is not valid" + result); + } + return policyModel; + } + + /** + * Gets the OODA state map. + * + * @param policyKey the policy key + * @param inEventKeyList the in event key list + * @param outEventKeyList the out event key list + * @param axLogicExecutorTypeList the ax logic executor type list + * @param defaultTaskList the default task list + * @param taskKeySetList the task key set list + * @return the OODA state map + */ + private Map getOodaStateMap(final AxArtifactKey policyKey, + final List inEventKeyList, final List outEventKeyList, + final List axLogicExecutorTypeList, final List defaultTaskList, + final List> taskKeySetList) { + final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE) + .setDefaultLogic("EvalState_Logic"); + + final AxState actState = new AxState(new AxReferenceKey(policyKey, "Act")); + actState.setTrigger(inEventKeyList.get(THIRD_MEMBER)); + final AxStateOutput act2Out = new AxStateOutput(new AxReferenceKey(actState.getKey(), "Act2Out"), + outEventKeyList.get(THIRD_MEMBER), AxReferenceKey.getNullKey()); + actState.getStateOutputs().put(act2Out.getKey().getLocalName(), act2Out); + actState.setTaskSelectionLogic(new AxTaskSelectionLogic(actState.getKey(), TASK_SELECTION_LOGIC, + axLogicExecutorTypeList.get(THIRD_MEMBER), logicReader)); + actState.setDefaultTask(defaultTaskList.get(THIRD_MEMBER)); + for (final AxArtifactKey taskKey : taskKeySetList.get(THIRD_MEMBER)) { + actState.getTaskReferences().put(taskKey, + new AxStateTaskReference(new AxReferenceKey(actState.getKey(), taskKey.getName()), + AxStateTaskOutputType.DIRECT, act2Out.getKey())); + } + + final AxState decState = new AxState(new AxReferenceKey(policyKey, "Decide")); + decState.setTrigger(inEventKeyList.get(2)); + final AxStateOutput dec2Act = new AxStateOutput(new AxReferenceKey(decState.getKey(), "Dec2Act"), + outEventKeyList.get(2), actState.getKey()); + decState.getStateOutputs().put(dec2Act.getKey().getLocalName(), dec2Act); + decState.setTaskSelectionLogic(new AxTaskSelectionLogic(decState.getKey(), TASK_SELECTION_LOGIC, + axLogicExecutorTypeList.get(2), logicReader)); + decState.setDefaultTask(defaultTaskList.get(2)); + for (final AxArtifactKey taskKey : taskKeySetList.get(2)) { + decState.getTaskReferences().put(taskKey, + new AxStateTaskReference(new AxReferenceKey(decState.getKey(), taskKey.getName()), + AxStateTaskOutputType.DIRECT, dec2Act.getKey())); + } + + final AxState orState = new AxState(new AxReferenceKey(policyKey, ORIENT)); + orState.setTrigger(inEventKeyList.get(1)); + final AxStateOutput or2Dec = new AxStateOutput(new AxReferenceKey(orState.getKey(), "Or2Dec"), + outEventKeyList.get(1), decState.getKey()); + orState.getStateOutputs().put(or2Dec.getKey().getLocalName(), or2Dec); + orState.setTaskSelectionLogic(new AxTaskSelectionLogic(orState.getKey(), TASK_SELECTION_LOGIC, + axLogicExecutorTypeList.get(1), logicReader)); + orState.setDefaultTask(defaultTaskList.get(1)); + for (final AxArtifactKey taskKey : taskKeySetList.get(1)) { + orState.getTaskReferences().put(taskKey, + new AxStateTaskReference(new AxReferenceKey(orState.getKey(), taskKey.getName()), + AxStateTaskOutputType.DIRECT, or2Dec.getKey())); + } + + final AxState obState = new AxState(new AxReferenceKey(policyKey, OBSERVE)); + obState.setTrigger(inEventKeyList.get(0)); + final AxStateOutput ob2Or = new AxStateOutput(new AxReferenceKey(obState.getKey(), "Ob2Or"), + outEventKeyList.get(0), orState.getKey()); + obState.getStateOutputs().put(ob2Or.getKey().getLocalName(), ob2Or); + obState.setTaskSelectionLogic(new AxTaskSelectionLogic(obState.getKey(), TASK_SELECTION_LOGIC, + axLogicExecutorTypeList.get(0), logicReader)); + obState.setDefaultTask(defaultTaskList.get(0)); + for (final AxArtifactKey taskKey : taskKeySetList.get(0)) { + obState.getTaskReferences().put(taskKey, + new AxStateTaskReference(new AxReferenceKey(obState.getKey(), taskKey.getName()), + AxStateTaskOutputType.DIRECT, ob2Or.getKey())); + } + + final Map stateMap = new TreeMap<>(); + stateMap.put(obState.getKey().getLocalName(), obState); + stateMap.put(orState.getKey().getLocalName(), orState); + stateMap.put(decState.getKey().getLocalName(), decState); + stateMap.put(actState.getKey().getLocalName(), actState); + + return stateMap; + } + + /** + * Get a sample ECA policy model. + * + * @return the sample policy model + */ + public AxPolicyModel getEcaPolicyModel() { + + final AxTasks tasks = new AxTasks(new AxArtifactKey("Tasks", "0.0.1")); + + final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE) + .setDefaultLogic("EvalTask_Logic"); + + final AxTask eTask = new AxTask(new AxArtifactKey("Task_Event_0", "0.0.1")); + eTask.duplicateInputFields(event0000.getParameterMap()); + eTask.duplicateOutputFields(event0001.getParameterMap()); + final AxTaskLogic eAxLogic = new AxTaskLogic(eTask.getKey(), TASK_LOGIC, + (justOneLang == null ? JYTHON : justOneLang), logicReader); + eAxLogic.setLogic(eAxLogic.getLogic().replaceAll(STATE_NAME, EVENT) + .replaceAll(TASK_NAME, eTask.getKey().getName()).replaceAll(STATE_NUMBER, "1")); + eTask.setTaskLogic(eAxLogic); + + final AxTask cTask = new AxTask(new AxArtifactKey("Task_Condition_0", "0.0.1")); + cTask.duplicateInputFields(event0001.getParameterMap()); + cTask.duplicateOutputFields(event0002.getParameterMap()); + final AxTaskLogic cAxLogic = new AxTaskLogic(cTask.getKey(), TASK_LOGIC, + (justOneLang == null ? JAVASCRIPT : justOneLang), logicReader); + cAxLogic.setLogic(cAxLogic.getLogic().replaceAll(STATE_NAME, CONDITION) + .replaceAll(TASK_NAME, cTask.getKey().getName()).replaceAll(STATE_NUMBER, "2")); + cTask.setTaskLogic(cAxLogic); + + final AxTask aTask = new AxTask(new AxArtifactKey("Task_Action_0", "0.0.1")); + aTask.duplicateInputFields(event0002.getParameterMap()); + aTask.duplicateOutputFields(event0003.getParameterMap()); + final AxTaskLogic aAxLogic = new AxTaskLogic(aTask.getKey(), TASK_LOGIC, + (justOneLang == null ? "JAVA" : justOneLang), logicReader); + aAxLogic.setLogic(aAxLogic.getLogic().replaceAll(STATE_NAME, ACTION) + .replaceAll(TASK_NAME, aTask.getKey().getName()).replaceAll(STATE_NUMBER, "3")); + aTask.setTaskLogic(aAxLogic); + + tasks.getTaskMap().put(eTask.getKey(), eTask); + tasks.getTaskMap().put(cTask.getKey(), cTask); + tasks.getTaskMap().put(aTask.getKey(), aTask); + + final Set eventTasks = new TreeSet<>(); + final Set conditionTasks = new TreeSet<>(); + final Set actionTasks = new TreeSet<>(); + + for (final AxTask task : tasks.getTaskMap().values()) { + if (task.getKey().getName().contains(EVENT)) { + eventTasks.add(task.getKey()); + } + if (task.getKey().getName().contains(CONDITION)) { + conditionTasks.add(task.getKey()); + } + if (task.getKey().getName().contains(ACTION)) { + actionTasks.add(task.getKey()); + } + } + final List> taskReferenceList = new ArrayList<>(); + taskReferenceList.add(eventTasks); + taskReferenceList.add(conditionTasks); + taskReferenceList.add(actionTasks); + + final List p0InEventList = new ArrayList<>(); + p0InEventList.add(event0000.getKey()); + p0InEventList.add(event0001.getKey()); + p0InEventList.add(event0002.getKey()); + + final List p0OutEventList = new ArrayList<>(); + p0OutEventList.add(event0001.getKey()); + p0OutEventList.add(event0002.getKey()); + p0OutEventList.add(event0003.getKey()); + + final List p0defaultTaskList = new ArrayList<>(); + p0defaultTaskList.add(tasks.get("Task_Event_0").getKey()); + p0defaultTaskList.add(tasks.get("Task_Condition_0").getKey()); + p0defaultTaskList.add(tasks.get("Task_Action_0").getKey()); + + final AxPolicy policy0 = new AxPolicy(new AxArtifactKey("ECAPolicy_0", "0.0.1")); + final List axLogicExecutorTypeList = Arrays.asList((justOneLang == null ? JAVASCRIPT : justOneLang), + (justOneLang == null ? "MVEL" : justOneLang), (justOneLang == null ? JYTHON : justOneLang)); + policy0.setStateMap(getEcaStateMap(policy0.getKey(), p0InEventList, p0OutEventList, axLogicExecutorTypeList, + p0defaultTaskList, taskReferenceList)); + policy0.setFirstState(policy0.getStateMap().get(EVENT).getKey().getLocalName()); + + final AxPolicies policies = new AxPolicies(new AxArtifactKey("ECAPolicies", "0.0.1")); + policies.getPolicyMap().put(policy0.getKey(), policy0); + + final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInformation", "0.0.1")); + final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("EvaluationPolicyModel_ECA", "0.0.1")); + policyModel.setPolicies(policies); + policyModel.setEvents(events); + policyModel.setTasks(tasks); + policyModel.setAlbums(new AxContextAlbums(new AxArtifactKey("Albums", "0.0.1"))); + policyModel.setSchemas(schemas); + policyModel.setKeyInformation(keyInformation); + policyModel.getKeyInformation().generateKeyInfo(policyModel); + + final AxValidationResult result = policyModel.validate(new AxValidationResult()); + if (!result.isOk()) { + throw new ApexRuntimeException("model " + policyModel.getId() + " is not valid" + result); + } + return policyModel; + } + + /** + * Gets the ECA state map. + * + * @param policyKey the policy key + * @param inEventKeyList the in event key list + * @param outEventKeyList the out event key list + * @param axLogicExecutorTypeList the ax logic executor type list + * @param defaultTaskList the default task list + * @param taskKeySetList the task key set list + * @return the ECA state map + */ + private Map getEcaStateMap(final AxArtifactKey policyKey, final List inEventKeyList, + final List outEventKeyList, final List axLogicExecutorTypeList, + final List defaultTaskList, final List> taskKeySetList) { + final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE) + .setDefaultLogic("EvalState_Logic"); + + final AxState actionState = new AxState(new AxReferenceKey(policyKey, ACTION)); + actionState.setTrigger(inEventKeyList.get(2)); + final AxStateOutput action2Out = new AxStateOutput(actionState.getKey(), AxReferenceKey.getNullKey(), + outEventKeyList.get(2)); + actionState.getStateOutputs().put(action2Out.getKey().getLocalName(), action2Out); + actionState.setTaskSelectionLogic(new AxTaskSelectionLogic(actionState.getKey(), TASK_SELECTION_LOGIC, + axLogicExecutorTypeList.get(2), logicReader)); + actionState.setDefaultTask(defaultTaskList.get(2)); + for (final AxArtifactKey taskKey : taskKeySetList.get(2)) { + actionState.getTaskReferences().put(taskKey, + new AxStateTaskReference(new AxReferenceKey(actionState.getKey(), taskKey.getName()), + AxStateTaskOutputType.DIRECT, action2Out.getKey())); + } + + final AxState conditionState = new AxState(new AxReferenceKey(policyKey, CONDITION)); + conditionState.setTrigger(inEventKeyList.get(1)); + final AxStateOutput condition2Action = new AxStateOutput(conditionState.getKey(), actionState.getKey(), + outEventKeyList.get(1)); + conditionState.getStateOutputs().put(condition2Action.getKey().getLocalName(), condition2Action); + conditionState.setTaskSelectionLogic(new AxTaskSelectionLogic(conditionState.getKey(), TASK_SELECTION_LOGIC, + axLogicExecutorTypeList.get(1), logicReader)); + conditionState.setDefaultTask(defaultTaskList.get(1)); + for (final AxArtifactKey taskKey : taskKeySetList.get(1)) { + conditionState.getTaskReferences().put(taskKey, + new AxStateTaskReference(new AxReferenceKey(conditionState.getKey(), taskKey.getName()), + AxStateTaskOutputType.DIRECT, condition2Action.getKey())); + } + + final AxState eventState = new AxState(new AxReferenceKey(policyKey, EVENT)); + eventState.setTrigger(inEventKeyList.get(0)); + final AxStateOutput event2Condition = new AxStateOutput(eventState.getKey(), conditionState.getKey(), + outEventKeyList.get(0)); + eventState.getStateOutputs().put(event2Condition.getKey().getLocalName(), event2Condition); + eventState.setTaskSelectionLogic(new AxTaskSelectionLogic(eventState.getKey(), TASK_SELECTION_LOGIC, + axLogicExecutorTypeList.get(0), logicReader)); + eventState.setDefaultTask(defaultTaskList.get(0)); + for (final AxArtifactKey taskKey : taskKeySetList.get(0)) { + eventState.getTaskReferences().put(taskKey, + new AxStateTaskReference(new AxReferenceKey(eventState.getKey(), taskKey.getName()), + AxStateTaskOutputType.DIRECT, event2Condition.getKey())); + } + + final Map stateMap = new TreeMap<>(); + stateMap.put(eventState.getKey().getLocalName(), eventState); + stateMap.put(conditionState.getKey().getLocalName(), conditionState); + stateMap.put(actionState.getKey().getLocalName(), actionState); + + return stateMap; + } + +} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactory.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactory.java new file mode 100644 index 000000000..5e9958ff0 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactory.java @@ -0,0 +1,776 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +package org.onap.policy.apex.testsuites.integration.common.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum; +import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; +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.AxEvents; +import org.onap.policy.apex.model.eventmodel.concepts.AxField; +import org.onap.policy.apex.model.policymodel.concepts.AxLogicReader; +import org.onap.policy.apex.model.policymodel.concepts.AxPolicies; +import org.onap.policy.apex.model.policymodel.concepts.AxPolicy; +import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; +import org.onap.policy.apex.model.policymodel.concepts.AxState; +import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput; +import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType; +import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference; +import org.onap.policy.apex.model.policymodel.concepts.AxTask; +import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic; +import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter; +import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic; +import org.onap.policy.apex.model.policymodel.concepts.AxTasks; +import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader; + +/** + * This class creates sample Policy Models. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class SampleDomainModelFactory { + // Recurring string constants + private static final String TASK = "Task_"; + private static final String PARAMETER2 = "Parameter2"; + private static final String PARAMETER1 = "Parameter1"; + private static final String DEFAULT_VALUE2 = "DefaultValue2"; + private static final String DEFAULT_VALUE1 = "DefaultValue1"; + private static final String PARAMETER0 = "Parameter0"; + private static final String DEFAULT_VALUE0 = "DefaultValue0"; + private static final String TASK_SELECTION_LIGIC = "TaskSelectionLigic"; + private static final String TEST_ACT_STATE_TIME = "TestActStateTime"; + private static final String TEST_ACT_CASE_SELECTED = "TestActCaseSelected"; + private static final String TEST_DECIDE_STATE_TIME = "TestDecideStateTime"; + private static final String TEST_DECIDE_CASE_SELECTED = "TestDecideCaseSelected"; + private static final String TEST_ESTABLISH_STATE_TIME = "TestEstablishStateTime"; + private static final String TEST_ESTABLISH_CASE_SELECTED = "TestEstablishCaseSelected"; + private static final String DECIDE = "Decide"; + private static final String TEST_MATCH_STATE_TIME = "TestMatchStateTime"; + private static final String TEST_MATCH_CASE_SELECTED = "TestMatchCaseSelected"; + private static final String ESTABLISH = "Establish"; + private static final String TEST_MATCH_CASE = "TestMatchCase"; + private static final String MATCH = "Match"; + private static final String DEFAULT_SOURCE = "Outside"; + private static final String DEFAULT_NAMESPACE = "org.onap.policy.apex.sample.events"; + private static final String TEST_TEMPERATURE = "TestTemperature"; + private static final String TEST_TIMESTAMP = "TestTimestamp"; + private static final String TEST_SLOGAN = "TestSlogan"; + private static final String DEFAULT_VERSION = "0.0.1"; + + private static final int THIRD_ENTRY = 3; + + /** + * Get a sample policy model. + * + * @param axLogicExecutorType The type of logic executor, the scripting language being used + * @return the sample policy model + */ + // CHECKSTYLE:OFF: checkstyle:maximumMethodLength + public AxPolicyModel getSamplePolicyModel(final String axLogicExecutorType) { + AxContextSchema testSlogan = new AxContextSchema(new AxArtifactKey(TEST_SLOGAN, DEFAULT_VERSION), "Java", + "java.lang.String"); + AxContextSchema testCase = new AxContextSchema(new AxArtifactKey("TestCase", DEFAULT_VERSION), "Java", + "java.lang.Byte"); + AxContextSchema testTimestamp = new AxContextSchema(new AxArtifactKey(TEST_TIMESTAMP, DEFAULT_VERSION), "Java", + "java.lang.Long"); + AxContextSchema testTemperature = new AxContextSchema(new AxArtifactKey(TEST_TEMPERATURE, DEFAULT_VERSION), + "Java", "java.lang.Double"); + + AxContextSchema testContextItem000 = new AxContextSchema( + new AxArtifactKey("TestContextItem000", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem000"); + AxContextSchema testContextItem001 = new AxContextSchema( + new AxArtifactKey("TestContextItem001", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem001"); + AxContextSchema testContextItem002 = new AxContextSchema( + new AxArtifactKey("TestContextItem002", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem002"); + AxContextSchema testContextItem003 = new AxContextSchema( + new AxArtifactKey("TestContextItem003", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem003"); + AxContextSchema testContextItem004 = new AxContextSchema( + new AxArtifactKey("TestContextItem004", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem004"); + AxContextSchema testContextItem005 = new AxContextSchema( + new AxArtifactKey("TestContextItem005", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem005"); + AxContextSchema testContextItem006 = new AxContextSchema( + new AxArtifactKey("TestContextItem006", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem006"); + AxContextSchema testContextItem007 = new AxContextSchema( + new AxArtifactKey("TestContextItem007", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem007"); + AxContextSchema testContextItem008 = new AxContextSchema( + new AxArtifactKey("TestContextItem008", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem008"); + AxContextSchema testContextItem009 = new AxContextSchema( + new AxArtifactKey("TestContextItem009", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem009"); + AxContextSchema testContextItem00A = new AxContextSchema( + new AxArtifactKey("TestContextItem00A", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem00A"); + AxContextSchema testContextItem00B = new AxContextSchema( + new AxArtifactKey("TestContextItem00B", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem00B"); + AxContextSchema testContextItem00C = new AxContextSchema( + new AxArtifactKey("TestContextItem00C", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestContextItem00C"); + + AxContextSchema testPolicyContextItem = new AxContextSchema( + new AxArtifactKey("TestPolicyContextItem", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestPolicyContextItem"); + AxContextSchema testGlobalContextItem = new AxContextSchema( + new AxArtifactKey("TestGlobalContextItem", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestGlobalContextItem"); + AxContextSchema testExternalContextItem = new AxContextSchema( + new AxArtifactKey("TestExternalContextItem", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.context.test.concepts.TestExternalContextItem"); + + AxContextSchemas axContextSchemas = new AxContextSchemas(new AxArtifactKey("TestDatatypes", DEFAULT_VERSION)); + axContextSchemas.getSchemasMap().put(testSlogan.getKey(), testSlogan); + axContextSchemas.getSchemasMap().put(testCase.getKey(), testCase); + axContextSchemas.getSchemasMap().put(testTimestamp.getKey(), testTimestamp); + axContextSchemas.getSchemasMap().put(testTemperature.getKey(), testTemperature); + + axContextSchemas.getSchemasMap().put(testContextItem000.getKey(), testContextItem000); + axContextSchemas.getSchemasMap().put(testContextItem001.getKey(), testContextItem001); + axContextSchemas.getSchemasMap().put(testContextItem002.getKey(), testContextItem002); + axContextSchemas.getSchemasMap().put(testContextItem003.getKey(), testContextItem003); + axContextSchemas.getSchemasMap().put(testContextItem004.getKey(), testContextItem004); + axContextSchemas.getSchemasMap().put(testContextItem005.getKey(), testContextItem005); + axContextSchemas.getSchemasMap().put(testContextItem006.getKey(), testContextItem006); + axContextSchemas.getSchemasMap().put(testContextItem007.getKey(), testContextItem007); + axContextSchemas.getSchemasMap().put(testContextItem008.getKey(), testContextItem008); + axContextSchemas.getSchemasMap().put(testContextItem009.getKey(), testContextItem009); + axContextSchemas.getSchemasMap().put(testContextItem00A.getKey(), testContextItem00A); + axContextSchemas.getSchemasMap().put(testContextItem00B.getKey(), testContextItem00B); + axContextSchemas.getSchemasMap().put(testContextItem00C.getKey(), testContextItem00C); + + axContextSchemas.getSchemasMap().put(testPolicyContextItem.getKey(), testPolicyContextItem); + axContextSchemas.getSchemasMap().put(testGlobalContextItem.getKey(), testGlobalContextItem); + axContextSchemas.getSchemasMap().put(testExternalContextItem.getKey(), testExternalContextItem); + + AxEvent event0000 = new AxEvent(new AxArtifactKey("Event0000", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0000.setSource(DEFAULT_SOURCE); + event0000.setTarget(MATCH); + event0000.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0000.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0000.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0000.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0000.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0000.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0000.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0000.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + + AxEvent event0001 = new AxEvent(new AxArtifactKey("Event0001", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0001.setSource(MATCH); + event0001.setTarget(ESTABLISH); + event0001.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0001.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0001.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0001.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0001.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0001.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0001.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0001.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + event0001.getParameterMap().put(TEST_MATCH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0001.getKey(), TEST_MATCH_CASE_SELECTED), testCase.getKey())); + event0001.getParameterMap().put(TEST_MATCH_STATE_TIME, new AxField( + new AxReferenceKey(event0001.getKey(), TEST_MATCH_STATE_TIME), testTimestamp.getKey())); + + AxEvent event0002 = new AxEvent(new AxArtifactKey("Event0002", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0002.setSource(ESTABLISH); + event0002.setTarget(DECIDE); + event0002.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0002.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0002.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0002.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0002.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0002.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0002.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0002.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + event0002.getParameterMap().put(TEST_MATCH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0002.getKey(), TEST_MATCH_CASE_SELECTED), testCase.getKey())); + event0002.getParameterMap().put(TEST_MATCH_STATE_TIME, new AxField( + new AxReferenceKey(event0002.getKey(), TEST_MATCH_STATE_TIME), testTimestamp.getKey())); + event0002.getParameterMap().put(TEST_ESTABLISH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0002.getKey(), TEST_ESTABLISH_CASE_SELECTED), testCase.getKey())); + event0002.getParameterMap().put(TEST_ESTABLISH_STATE_TIME, new AxField( + new AxReferenceKey(event0002.getKey(), TEST_ESTABLISH_STATE_TIME), testTimestamp.getKey())); + + AxEvent event0003 = new AxEvent(new AxArtifactKey("Event0003", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0003.setSource(DECIDE); + event0003.setTarget("Act"); + event0003.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0003.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0003.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0003.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0003.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0003.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0003.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0003.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + event0003.getParameterMap().put(TEST_MATCH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0003.getKey(), TEST_MATCH_CASE_SELECTED), testCase.getKey())); + event0003.getParameterMap().put(TEST_MATCH_STATE_TIME, new AxField( + new AxReferenceKey(event0003.getKey(), TEST_MATCH_STATE_TIME), testTimestamp.getKey())); + event0003.getParameterMap().put(TEST_ESTABLISH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0003.getKey(), TEST_ESTABLISH_CASE_SELECTED), testCase.getKey())); + event0003.getParameterMap().put(TEST_ESTABLISH_STATE_TIME, new AxField( + new AxReferenceKey(event0003.getKey(), TEST_ESTABLISH_STATE_TIME), testTimestamp.getKey())); + event0003.getParameterMap().put(TEST_DECIDE_CASE_SELECTED, new AxField( + new AxReferenceKey(event0003.getKey(), TEST_DECIDE_CASE_SELECTED), testCase.getKey())); + event0003.getParameterMap().put(TEST_DECIDE_STATE_TIME, new AxField( + new AxReferenceKey(event0003.getKey(), TEST_DECIDE_STATE_TIME), testTimestamp.getKey())); + + AxEvent event0004 = new AxEvent(new AxArtifactKey("Event0004", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0004.setSource("Act"); + event0004.setTarget(DEFAULT_SOURCE); + event0004.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0004.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0004.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0004.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0004.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0004.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0004.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0004.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + event0004.getParameterMap().put(TEST_MATCH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0004.getKey(), TEST_MATCH_CASE_SELECTED), testCase.getKey())); + event0004.getParameterMap().put(TEST_MATCH_STATE_TIME, new AxField( + new AxReferenceKey(event0004.getKey(), TEST_MATCH_STATE_TIME), testTimestamp.getKey())); + event0004.getParameterMap().put(TEST_ESTABLISH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0004.getKey(), TEST_ESTABLISH_CASE_SELECTED), testCase.getKey())); + event0004.getParameterMap().put(TEST_ESTABLISH_STATE_TIME, new AxField( + new AxReferenceKey(event0004.getKey(), TEST_ESTABLISH_STATE_TIME), testTimestamp.getKey())); + event0004.getParameterMap().put(TEST_DECIDE_CASE_SELECTED, new AxField( + new AxReferenceKey(event0004.getKey(), TEST_DECIDE_CASE_SELECTED), testCase.getKey())); + event0004.getParameterMap().put(TEST_DECIDE_STATE_TIME, new AxField( + new AxReferenceKey(event0004.getKey(), TEST_DECIDE_STATE_TIME), testTimestamp.getKey())); + event0004.getParameterMap().put(TEST_ACT_CASE_SELECTED, + new AxField(new AxReferenceKey(event0004.getKey(), TEST_ACT_CASE_SELECTED), testCase.getKey())); + event0004.getParameterMap().put(TEST_ACT_STATE_TIME, new AxField( + new AxReferenceKey(event0004.getKey(), TEST_ACT_STATE_TIME), testTimestamp.getKey())); + + AxEvent event0100 = new AxEvent(new AxArtifactKey("Event0100", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0100.setSource(DEFAULT_SOURCE); + event0100.setTarget(MATCH); + event0100.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0100.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0100.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0100.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0100.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0100.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0100.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0100.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + + AxEvent event0101 = new AxEvent(new AxArtifactKey("Event0101", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0101.setSource(MATCH); + event0101.setTarget(ESTABLISH); + event0101.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0101.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0101.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0101.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0101.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0101.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0101.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0101.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + event0101.getParameterMap().put(TEST_MATCH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0101.getKey(), TEST_MATCH_CASE_SELECTED), testCase.getKey())); + event0101.getParameterMap().put(TEST_MATCH_STATE_TIME, new AxField( + new AxReferenceKey(event0101.getKey(), TEST_MATCH_STATE_TIME), testTimestamp.getKey())); + + AxEvent event0102 = new AxEvent(new AxArtifactKey("Event0102", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0102.setSource(ESTABLISH); + event0102.setTarget(DECIDE); + event0102.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0102.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0102.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0102.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0102.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0102.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0102.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0102.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + event0102.getParameterMap().put(TEST_MATCH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0102.getKey(), TEST_MATCH_CASE_SELECTED), testCase.getKey())); + event0102.getParameterMap().put(TEST_MATCH_STATE_TIME, new AxField( + new AxReferenceKey(event0102.getKey(), TEST_MATCH_STATE_TIME), testTimestamp.getKey())); + event0102.getParameterMap().put(TEST_ESTABLISH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0102.getKey(), TEST_ESTABLISH_CASE_SELECTED), testCase.getKey())); + event0102.getParameterMap().put(TEST_ESTABLISH_STATE_TIME, new AxField( + new AxReferenceKey(event0102.getKey(), TEST_ESTABLISH_STATE_TIME), testTimestamp.getKey())); + + AxEvent event0103 = new AxEvent(new AxArtifactKey("Event0103", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0103.setSource(DECIDE); + event0103.setTarget("Act"); + event0103.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0103.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0103.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0103.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0103.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0103.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0103.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0103.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + event0103.getParameterMap().put(TEST_MATCH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0103.getKey(), TEST_MATCH_CASE_SELECTED), testCase.getKey())); + event0103.getParameterMap().put(TEST_MATCH_STATE_TIME, new AxField( + new AxReferenceKey(event0103.getKey(), TEST_MATCH_STATE_TIME), testTimestamp.getKey())); + event0103.getParameterMap().put(TEST_ESTABLISH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0103.getKey(), TEST_ESTABLISH_CASE_SELECTED), testCase.getKey())); + event0103.getParameterMap().put(TEST_ESTABLISH_STATE_TIME, new AxField( + new AxReferenceKey(event0103.getKey(), TEST_ESTABLISH_STATE_TIME), testTimestamp.getKey())); + event0103.getParameterMap().put(TEST_DECIDE_CASE_SELECTED, new AxField( + new AxReferenceKey(event0103.getKey(), TEST_DECIDE_CASE_SELECTED), testCase.getKey())); + event0103.getParameterMap().put(TEST_DECIDE_STATE_TIME, new AxField( + new AxReferenceKey(event0103.getKey(), TEST_DECIDE_STATE_TIME), testTimestamp.getKey())); + + AxEvent event0104 = new AxEvent(new AxArtifactKey("Event0104", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + event0104.setSource("Act"); + event0104.setTarget(DEFAULT_SOURCE); + event0104.getParameterMap().put(TEST_SLOGAN, + new AxField(new AxReferenceKey(event0104.getKey(), TEST_SLOGAN), testSlogan.getKey())); + event0104.getParameterMap().put(TEST_MATCH_CASE, + new AxField(new AxReferenceKey(event0104.getKey(), TEST_MATCH_CASE), testCase.getKey())); + event0104.getParameterMap().put(TEST_TIMESTAMP, + new AxField(new AxReferenceKey(event0104.getKey(), TEST_TIMESTAMP), testTimestamp.getKey())); + event0104.getParameterMap().put(TEST_TEMPERATURE, new AxField( + new AxReferenceKey(event0104.getKey(), TEST_TEMPERATURE), testTemperature.getKey())); + event0104.getParameterMap().put(TEST_MATCH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0104.getKey(), TEST_MATCH_CASE_SELECTED), testCase.getKey())); + event0104.getParameterMap().put(TEST_MATCH_STATE_TIME, new AxField( + new AxReferenceKey(event0104.getKey(), TEST_MATCH_STATE_TIME), testTimestamp.getKey())); + event0104.getParameterMap().put(TEST_ESTABLISH_CASE_SELECTED, new AxField( + new AxReferenceKey(event0104.getKey(), TEST_ESTABLISH_CASE_SELECTED), testCase.getKey())); + event0104.getParameterMap().put(TEST_ESTABLISH_STATE_TIME, new AxField( + new AxReferenceKey(event0104.getKey(), TEST_ESTABLISH_STATE_TIME), testTimestamp.getKey())); + event0104.getParameterMap().put(TEST_DECIDE_CASE_SELECTED, new AxField( + new AxReferenceKey(event0104.getKey(), TEST_DECIDE_CASE_SELECTED), testCase.getKey())); + event0104.getParameterMap().put(TEST_DECIDE_STATE_TIME, new AxField( + new AxReferenceKey(event0104.getKey(), TEST_DECIDE_STATE_TIME), testTimestamp.getKey())); + event0104.getParameterMap().put(TEST_ACT_CASE_SELECTED, + new AxField(new AxReferenceKey(event0104.getKey(), TEST_ACT_CASE_SELECTED), testCase.getKey())); + event0104.getParameterMap().put(TEST_ACT_STATE_TIME, new AxField( + new AxReferenceKey(event0104.getKey(), TEST_ACT_STATE_TIME), testTimestamp.getKey())); + + AxEvents events = new AxEvents(new AxArtifactKey("Events", DEFAULT_VERSION)); + events.getEventMap().put(event0000.getKey(), event0000); + events.getEventMap().put(event0001.getKey(), event0001); + events.getEventMap().put(event0002.getKey(), event0002); + events.getEventMap().put(event0003.getKey(), event0003); + events.getEventMap().put(event0004.getKey(), event0004); + events.getEventMap().put(event0100.getKey(), event0100); + events.getEventMap().put(event0101.getKey(), event0101); + events.getEventMap().put(event0102.getKey(), event0102); + events.getEventMap().put(event0103.getKey(), event0103); + events.getEventMap().put(event0104.getKey(), event0104); + + AxContextAlbum externalContextAlbum = new AxContextAlbum( + new AxArtifactKey("ExternalContextAlbum", DEFAULT_VERSION), "EXTERNAL", false, + testExternalContextItem.getKey()); + AxContextAlbum globalContextAlbum = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", DEFAULT_VERSION), + "GLOBAL", true, testGlobalContextItem.getKey()); + AxContextAlbum policy0ContextAlbum = new AxContextAlbum( + new AxArtifactKey("Policy0ContextAlbum", DEFAULT_VERSION), "APPLICATION", true, + testPolicyContextItem.getKey()); + AxContextAlbum policy1ContextAlbum = new AxContextAlbum( + new AxArtifactKey("Policy1ContextAlbum", DEFAULT_VERSION), "APPLICATION", true, + testPolicyContextItem.getKey()); + + AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("Context", DEFAULT_VERSION)); + albums.getAlbumsMap().put(externalContextAlbum.getKey(), externalContextAlbum); + albums.getAlbumsMap().put(globalContextAlbum.getKey(), globalContextAlbum); + albums.getAlbumsMap().put(policy0ContextAlbum.getKey(), policy0ContextAlbum); + albums.getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum); + + Set referenceKeySet0 = new TreeSet<>(); + referenceKeySet0.add(policy0ContextAlbum.getKey()); + referenceKeySet0.add(policy1ContextAlbum.getKey()); + referenceKeySet0.add(globalContextAlbum.getKey()); + referenceKeySet0.add(externalContextAlbum.getKey()); + + Set referenceKeySet1 = new TreeSet<>(); + referenceKeySet1.add(policy0ContextAlbum.getKey()); + referenceKeySet1.add(globalContextAlbum.getKey()); + + Set referenceKeySet2 = new TreeSet<>(); + referenceKeySet2.add(policy1ContextAlbum.getKey()); + referenceKeySet2.add(globalContextAlbum.getKey()); + + Set referenceKeySet3 = new TreeSet<>(); + referenceKeySet3.add(globalContextAlbum.getKey()); + referenceKeySet3.add(externalContextAlbum.getKey()); + + List> referenceKeySetList = new ArrayList<>(); + referenceKeySetList.add(referenceKeySet0); + referenceKeySetList.add(referenceKeySet1); + referenceKeySetList.add(referenceKeySet2); + referenceKeySetList.add(referenceKeySet3); + + AxTasks tasks = new AxTasks(new AxArtifactKey("Tasks", DEFAULT_VERSION)); + tasks.getTaskMap().putAll(getTaskMap(MATCH, event0000.getParameterMap(), event0001.getParameterMap(), + referenceKeySetList, axLogicExecutorType)); + tasks.getTaskMap().putAll(getTaskMap(ESTABLISH, event0001.getParameterMap(), event0002.getParameterMap(), + referenceKeySetList, axLogicExecutorType)); + tasks.getTaskMap().putAll(getTaskMap(DECIDE, event0002.getParameterMap(), event0003.getParameterMap(), + referenceKeySetList, axLogicExecutorType)); + tasks.getTaskMap().putAll(getTaskMap("Act", event0003.getParameterMap(), event0004.getParameterMap(), + referenceKeySetList, axLogicExecutorType)); + + Set matchTasks = new TreeSet<>(); + Set establishTasks = new TreeSet<>(); + Set decideTasks = new TreeSet<>(); + Set actTasks = new TreeSet<>(); + for (AxTask task : tasks.getTaskMap().values()) { + if (task.getKey().getName().contains(MATCH)) { + matchTasks.add(task.getKey()); + } + if (task.getKey().getName().contains(ESTABLISH)) { + establishTasks.add(task.getKey()); + } + if (task.getKey().getName().contains(DECIDE)) { + decideTasks.add(task.getKey()); + } + if (task.getKey().getName().contains("Act")) { + actTasks.add(task.getKey()); + } + } + List> taskReferenceList = new ArrayList<>(); + taskReferenceList.add(matchTasks); + taskReferenceList.add(establishTasks); + taskReferenceList.add(decideTasks); + taskReferenceList.add(actTasks); + + List p0InEventList = new ArrayList<>(); + p0InEventList.add(event0000.getKey()); + p0InEventList.add(event0001.getKey()); + p0InEventList.add(event0002.getKey()); + p0InEventList.add(event0003.getKey()); + + List p0OutEventList = new ArrayList<>(); + p0OutEventList.add(event0001.getKey()); + p0OutEventList.add(event0002.getKey()); + p0OutEventList.add(event0003.getKey()); + p0OutEventList.add(event0004.getKey()); + + List p0defaultTaskList = new ArrayList<>(); + p0defaultTaskList.add(tasks.get("Task_Match0").getKey()); + p0defaultTaskList.add(tasks.get("Task_Establish2").getKey()); + p0defaultTaskList.add(tasks.get("Task_Decide3").getKey()); + p0defaultTaskList.add(tasks.get("Task_Act1").getKey()); + + List p1InEventList = new ArrayList<>(); + p1InEventList.add(event0100.getKey()); + p1InEventList.add(event0101.getKey()); + p1InEventList.add(event0102.getKey()); + p1InEventList.add(event0103.getKey()); + + List p1OutEventList = new ArrayList<>(); + p1OutEventList.add(event0101.getKey()); + p1OutEventList.add(event0102.getKey()); + p1OutEventList.add(event0103.getKey()); + p1OutEventList.add(event0104.getKey()); + + List p1defaultTaskList = new ArrayList<>(); + p1defaultTaskList.add(tasks.get("Task_Match3").getKey()); + p1defaultTaskList.add(tasks.get("Task_Establish1").getKey()); + p1defaultTaskList.add(tasks.get("Task_Decide3").getKey()); + p1defaultTaskList.add(tasks.get("Task_Act0").getKey()); + + Set p0ReferenceKeySet0 = new TreeSet<>(); + p0ReferenceKeySet0.add(policy0ContextAlbum.getKey()); + p0ReferenceKeySet0.add(globalContextAlbum.getKey()); + + Set p0ReferenceKeySet1 = new TreeSet<>(); + p0ReferenceKeySet1.add(policy1ContextAlbum.getKey()); + p0ReferenceKeySet1.add(globalContextAlbum.getKey()); + p0ReferenceKeySet1.add(externalContextAlbum.getKey()); + + Set p0ReferenceKeySet2 = new TreeSet<>(); + p0ReferenceKeySet2.add(policy0ContextAlbum.getKey()); + p0ReferenceKeySet2.add(globalContextAlbum.getKey()); + p0ReferenceKeySet2.add(externalContextAlbum.getKey()); + + Set p0ReferenceKeySet3 = new TreeSet<>(); + p0ReferenceKeySet3.add(globalContextAlbum.getKey()); + + List> p0ReferenceKeySetList = new ArrayList<>(); + p0ReferenceKeySetList.add(p0ReferenceKeySet0); + p0ReferenceKeySetList.add(p0ReferenceKeySet1); + p0ReferenceKeySetList.add(p0ReferenceKeySet2); + p0ReferenceKeySetList.add(p0ReferenceKeySet3); + + AxPolicy policy0 = new AxPolicy(new AxArtifactKey("Policy0", DEFAULT_VERSION)); + policy0.setTemplate("MEDA"); + policy0.setStateMap(getStateMap(policy0.getKey(), p0InEventList, p0OutEventList, p0ReferenceKeySetList, + axLogicExecutorType, p0defaultTaskList, taskReferenceList)); + policy0.setFirstState(policy0.getStateMap().get(MATCH).getKey().getLocalName()); + + Set p1ReferenceKeySet0 = new TreeSet<>(); + p1ReferenceKeySet0.add(policy1ContextAlbum.getKey()); + p1ReferenceKeySet0.add(globalContextAlbum.getKey()); + p1ReferenceKeySet0.add(externalContextAlbum.getKey()); + + Set p1ReferenceKeySet1 = new TreeSet<>(); + p1ReferenceKeySet1.add(policy1ContextAlbum.getKey()); + p1ReferenceKeySet1.add(globalContextAlbum.getKey()); + p1ReferenceKeySet1.add(externalContextAlbum.getKey()); + + Set p1ReferenceKeySet2 = new TreeSet<>(); + p1ReferenceKeySet2.add(policy1ContextAlbum.getKey()); + p1ReferenceKeySet2.add(globalContextAlbum.getKey()); + p1ReferenceKeySet2.add(externalContextAlbum.getKey()); + + Set p1ReferenceKeySet3 = new TreeSet<>(); + p1ReferenceKeySet3.add(globalContextAlbum.getKey()); + + List> p1ReferenceKeySetList = new ArrayList<>(); + p1ReferenceKeySetList.add(p1ReferenceKeySet0); + p1ReferenceKeySetList.add(p1ReferenceKeySet1); + p1ReferenceKeySetList.add(p1ReferenceKeySet2); + p1ReferenceKeySetList.add(p1ReferenceKeySet3); + + AxPolicy policy1 = new AxPolicy(new AxArtifactKey("Policy1", DEFAULT_VERSION)); + policy1.setTemplate("MEDA"); + policy1.setStateMap(getStateMap(policy1.getKey(), p1InEventList, p1OutEventList, p1ReferenceKeySetList, + axLogicExecutorType, p1defaultTaskList, taskReferenceList)); + policy1.setFirstState(policy1.getStateMap().get(MATCH).getKey().getLocalName()); + + AxPolicies policies = new AxPolicies(new AxArtifactKey("Policies", DEFAULT_VERSION)); + policies.getPolicyMap().put(policy0.getKey(), policy0); + policies.getPolicyMap().put(policy1.getKey(), policy1); + + AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInformation", DEFAULT_VERSION)); + AxPolicyModel policyModel = new AxPolicyModel( + new AxArtifactKey("SamplePolicyModel" + axLogicExecutorType, DEFAULT_VERSION)); + policyModel.setKeyInformation(keyInformation); + policyModel.setPolicies(policies); + policyModel.setEvents(events); + policyModel.setTasks(tasks); + policyModel.setAlbums(albums); + policyModel.setSchemas(axContextSchemas); + policyModel.getKeyInformation().generateKeyInfo(policyModel); + + AxValidationResult result = policyModel.validate(new AxValidationResult()); + if (!result.getValidationResult().equals(AxValidationResult.ValidationResult.VALID)) { + throw new ApexRuntimeException("model " + policyModel.getId() + " is not valid" + result); + } + return policyModel; + } + + /** + * Gets the state map. + * + * @param policyKey the policy key + * @param inEventKeyList the in event key list + * @param outEventKeyList the out event key list + * @param referenceKeySetList the reference key set list + * @param axLogicExecutorType the ax logic executor type + * @param defaultTaskList the default task list + * @param taskKeySetList the task key set list + * @return the state map + */ + private Map getStateMap(final AxArtifactKey policyKey, final List inEventKeyList, + final List outEventKeyList, final List> referenceKeySetList, + final String axLogicExecutorType, final List defaultTaskList, + final List> taskKeySetList) { + + AxState actState = new AxState(new AxReferenceKey(policyKey, "Act")); + actState.setTrigger(inEventKeyList.get(3)); + AxStateOutput act2Out = new AxStateOutput(actState.getKey(), AxReferenceKey.getNullKey(), + outEventKeyList.get(3)); + actState.getStateOutputs().put(act2Out.getKey().getLocalName(), act2Out); + actState.setContextAlbumReferences(referenceKeySetList.get(3)); + + AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(this.getClass().getPackage().getName()) + .setDefaultLogic("DefaultStateLogic"); + actState.setTaskSelectionLogic(new AxTaskSelectionLogic(actState.getKey(), TASK_SELECTION_LIGIC, + axLogicExecutorType, logicReader)); + actState.setDefaultTask(defaultTaskList.get(3)); + for (AxArtifactKey taskKey : taskKeySetList.get(3)) { + actState.getTaskReferences().put(taskKey, new AxStateTaskReference(actState.getKey(), taskKey, + AxStateTaskOutputType.DIRECT, act2Out.getKey())); + } + + AxState decideState = new AxState(new AxReferenceKey(policyKey, DECIDE)); + decideState.setTrigger(inEventKeyList.get(2)); + AxStateOutput decide2Act = new AxStateOutput(decideState.getKey(), actState.getKey(), outEventKeyList.get(2)); + decideState.getStateOutputs().put(decide2Act.getKey().getLocalName(), decide2Act); + decideState.setContextAlbumReferences(referenceKeySetList.get(2)); + decideState.setTaskSelectionLogic(new AxTaskSelectionLogic(decideState.getKey(), TASK_SELECTION_LIGIC, + axLogicExecutorType, logicReader)); + decideState.setDefaultTask(defaultTaskList.get(2)); + for (AxArtifactKey taskKey : taskKeySetList.get(2)) { + decideState.getTaskReferences().put(taskKey, new AxStateTaskReference(decideState.getKey(), taskKey, + AxStateTaskOutputType.DIRECT, decide2Act.getKey())); + } + + AxState establishState = new AxState(new AxReferenceKey(policyKey, ESTABLISH)); + establishState.setTrigger(inEventKeyList.get(1)); + AxStateOutput establish2Decide = new AxStateOutput(establishState.getKey(), decideState.getKey(), + outEventKeyList.get(1)); + establishState.getStateOutputs().put(establish2Decide.getKey().getLocalName(), establish2Decide); + establishState.setContextAlbumReferences(referenceKeySetList.get(1)); + establishState.setTaskSelectionLogic(new AxTaskSelectionLogic(establishState.getKey(), TASK_SELECTION_LIGIC, + axLogicExecutorType, logicReader)); + establishState.setDefaultTask(defaultTaskList.get(1)); + for (AxArtifactKey taskKey : taskKeySetList.get(1)) { + establishState.getTaskReferences().put(taskKey, new AxStateTaskReference(establishState.getKey(), taskKey, + AxStateTaskOutputType.DIRECT, establish2Decide.getKey())); + } + + AxState matchState = new AxState(new AxReferenceKey(policyKey, MATCH)); + matchState.setTrigger(inEventKeyList.get(0)); + AxStateOutput match2Establish = new AxStateOutput(matchState.getKey(), establishState.getKey(), + outEventKeyList.get(0)); + matchState.getStateOutputs().put(match2Establish.getKey().getLocalName(), match2Establish); + matchState.setContextAlbumReferences(referenceKeySetList.get(0)); + matchState.setTaskSelectionLogic(new AxTaskSelectionLogic(matchState.getKey(), TASK_SELECTION_LIGIC, + axLogicExecutorType, logicReader)); + matchState.setDefaultTask(defaultTaskList.get(0)); + for (AxArtifactKey taskKey : taskKeySetList.get(0)) { + matchState.getTaskReferences().put(taskKey, new AxStateTaskReference(matchState.getKey(), taskKey, + AxStateTaskOutputType.DIRECT, match2Establish.getKey())); + } + + Map stateMap = new TreeMap<>(); + stateMap.put(matchState.getKey().getLocalName(), matchState); + stateMap.put(establishState.getKey().getLocalName(), establishState); + stateMap.put(decideState.getKey().getLocalName(), decideState); + stateMap.put(actState.getKey().getLocalName(), actState); + + return stateMap; + } + // CHECKSTYLE:ON: checkstyle:maximumMethodLength + + /** + * Gets the task map. + * + * @param state the state + * @param inputFields the input fields + * @param outputFields the output fields + * @param referenceKeySetList the reference key set list + * @param axLogicExecutorType the ax logic executor type + * @return the task map + */ + private Map getTaskMap(final String state, final Map inputFields, + final Map outputFields, final List> referenceKeySetList, + final String axLogicExecutorType) { + + AxTask testTask0 = new AxTask(new AxArtifactKey(TASK + state + "0", DEFAULT_VERSION)); + testTask0.duplicateInputFields(inputFields); + testTask0.duplicateOutputFields(outputFields); + AxTaskParameter parameter00 = new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), PARAMETER0), + DEFAULT_VALUE0); + AxTaskParameter parameter01 = new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), PARAMETER1), + DEFAULT_VALUE1); + AxTaskParameter parameter02 = new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), PARAMETER2), + DEFAULT_VALUE2); + testTask0.getTaskParameters().put(parameter00.getKey().getLocalName(), parameter00); + testTask0.getTaskParameters().put(parameter01.getKey().getLocalName(), parameter01); + testTask0.getTaskParameters().put(parameter02.getKey().getLocalName(), parameter02); + testTask0.setContextAlbumReferences(referenceKeySetList.get(0)); + + AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(this.getClass().getPackage().getName()) + .setDefaultLogic("DefaultTaskLogic"); + testTask0.setTaskLogic(getTaskLogic(testTask0, logicReader, axLogicExecutorType, state, "2")); + + AxTask testTask1 = new AxTask(new AxArtifactKey(TASK + state + "1", DEFAULT_VERSION)); + testTask1.duplicateInputFields(inputFields); + testTask1.duplicateOutputFields(outputFields); + AxTaskParameter parameter10 = new AxTaskParameter(new AxReferenceKey(testTask1.getKey(), PARAMETER0), + DEFAULT_VALUE0); + AxTaskParameter parameter11 = new AxTaskParameter(new AxReferenceKey(testTask1.getKey(), PARAMETER1), + DEFAULT_VALUE1); + testTask1.getTaskParameters().put(parameter10.getKey().getLocalName(), parameter10); + testTask1.getTaskParameters().put(parameter11.getKey().getLocalName(), parameter11); + testTask1.setContextAlbumReferences(referenceKeySetList.get(1)); + testTask1.setTaskLogic(getTaskLogic(testTask1, logicReader, axLogicExecutorType, state, "3")); + + AxTask testTask2 = new AxTask(new AxArtifactKey(TASK + state + "2", DEFAULT_VERSION)); + testTask2.duplicateInputFields(inputFields); + testTask2.duplicateOutputFields(outputFields); + AxTaskParameter parameter20 = new AxTaskParameter(new AxReferenceKey(testTask2.getKey(), PARAMETER0), + DEFAULT_VALUE0); + testTask2.getTaskParameters().put(parameter20.getKey().getLocalName(), parameter20); + testTask2.setContextAlbumReferences(referenceKeySetList.get(2)); + testTask2.setTaskLogic(getTaskLogic(testTask2, logicReader, axLogicExecutorType, state, "0")); + + AxTask testTask3 = new AxTask(new AxArtifactKey(TASK + state + "3", DEFAULT_VERSION)); + testTask3.duplicateInputFields(inputFields); + testTask3.duplicateOutputFields(outputFields); + AxTaskParameter parameter30 = new AxTaskParameter(new AxReferenceKey(testTask3.getKey(), PARAMETER0), + DEFAULT_VALUE0); + testTask3.getTaskParameters().put(parameter30.getKey().getLocalName(), parameter30); + testTask3.setContextAlbumReferences(referenceKeySetList.get(THIRD_ENTRY)); + testTask3.setTaskLogic(getTaskLogic(testTask3, logicReader, axLogicExecutorType, state, "1")); + + Map taskMap = new TreeMap<>(); + taskMap.put(testTask0.getKey(), testTask0); + taskMap.put(testTask1.getKey(), testTask1); + taskMap.put(testTask2.getKey(), testTask2); + taskMap.put(testTask3.getKey(), testTask3); + + return taskMap; + } + + /** + * Gets the task logic. + * + * @param task the task + * @param logicReader the logic reader + * @param logicFlavour the logic flavour + * @param stateName the state name + * @param caseToUse the case to use + * @return the task logic + */ + private AxTaskLogic getTaskLogic(final AxTask task, final AxLogicReader logicReader, final String logicFlavour, + final String stateName, final String caseToUse) { + AxTaskLogic axLogic = new AxTaskLogic(new AxReferenceKey(task.getKey(), "_TaskLogic"), logicFlavour, + logicReader); + + axLogic.setLogic(axLogic.getLogic().replaceAll("", stateName) + .replaceAll("", task.getKey().getName()) + .replaceAll("", caseToUse)); + + return axLogic; + } +} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaver.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaver.java new file mode 100644 index 000000000..8eb885759 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaver.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +package org.onap.policy.apex.testsuites.integration.common.model; + +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver; +import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * This class saves sample domain models to disk in XML and JSON format. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public final class SampleDomainModelSaver { + // Logger for this class + private static final XLogger LOGGER = XLoggerFactory.getXLogger(SampleDomainModelSaver.class); + + /** + * Private default constructor to prevent subclassing. + */ + private SampleDomainModelSaver() { + } + + /** + * Write the sample Models to args[0]. + * + * @param args Not used + * @throws ApexException the apex exception + */ + public static void main(final String[] args) throws ApexException { + if (args.length != 1) { + LOGGER.error("usage: " + SampleDomainModelSaver.class.getCanonicalName() + " modelDirectory"); + return; + } + + // Save Java model + final AxPolicyModel javaPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVA"); + final ApexModelSaver javaModelSaver = new ApexModelSaver<>(AxPolicyModel.class, + javaPolicyModel, args[0]); + javaModelSaver.apexModelWriteJson(); + javaModelSaver.apexModelWriteXml(); + + // Save Javascript model + final AxPolicyModel javascriptPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT"); + final ApexModelSaver javascriptModelSaver = new ApexModelSaver<>( + AxPolicyModel.class, javascriptPolicyModel, args[0]); + javascriptModelSaver.apexModelWriteJson(); + javascriptModelSaver.apexModelWriteXml(); + + // Save JRuby model + final AxPolicyModel jRubyPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JRUBY"); + final ApexModelSaver jRubyModelSaver = new ApexModelSaver<>(AxPolicyModel.class, + jRubyPolicyModel, args[0]); + jRubyModelSaver.apexModelWriteJson(); + jRubyModelSaver.apexModelWriteXml(); + + // Save Jython model + final AxPolicyModel jythonPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JYTHON"); + final ApexModelSaver jythonModelSaver = new ApexModelSaver<>(AxPolicyModel.class, + jythonPolicyModel, args[0]); + jythonModelSaver.apexModelWriteJson(); + jythonModelSaver.apexModelWriteXml(); + + // Save MVEL model + final AxPolicyModel mvelPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL"); + final ApexModelSaver mvelModelSaver = new ApexModelSaver<>(AxPolicyModel.class, + mvelPolicyModel, args[0]); + mvelModelSaver.apexModelWriteJson(); + mvelModelSaver.apexModelWriteXml(); + } + +} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultStateLogic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultStateLogic.java new file mode 100644 index 000000000..2669e70d7 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultStateLogic.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +package org.onap.policy.apex.testsuites.integration.common.model.java; + +import org.onap.policy.apex.core.engine.executor.context.TaskSelectionExecutionContext; + +/** + * The Class DefaultState_Logic is default task selection logic in Java. + */ +public class DefaultStateLogic { + /** + * Gets the task. + * + * @param executor the executor + * @return the task + */ + public boolean getTask(final TaskSelectionExecutionContext executor) { + executor.logger.debug(executor.subject.getId()); + executor.logger.debug(executor.getContextAlbum("GlobalContextAlbum").getName()); + executor.subject.getDefaultTaskKey().copyTo(executor.selectedTask); + return true; + } +} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java new file mode 100644 index 000000000..86dac6638 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +package org.onap.policy.apex.testsuites.integration.common.model.java; + +import java.util.Date; +import java.util.Random; + +import org.onap.policy.apex.core.engine.executor.context.TaskExecutionContext; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; + +/** + * The Class DefaultTask_Logic is default task logic in Java. + */ +public class DefaultTaskLogic { + private static final int BOUND_FOR_RANDOM_INT = 4; + + /** + * Gets the event. + * + * @param executor the executor + * @return the event + * @throws ApexException the apex exception + */ + public boolean getEvent(final TaskExecutionContext executor) throws ApexException { + String idString = executor.subject.getId(); + executor.logger.debug(idString); + + String albumNameString = executor.getContextAlbum("GlobalContextAlbum").getName(); + executor.logger.debug(albumNameString); + + String inFieldsString = executor.inFields.toString(); + executor.logger.debug(inFieldsString); + + final Date timeNow = new Date(); + final Random rand = new Random(); + + if (executor.inFields.containsKey("TestDecideCaseSelected")) { + executor.outFields.put("TestActCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); + executor.outFields.put("TestActStateTime", timeNow.getTime()); + } + else if (executor.inFields.containsKey("TestEstablishCaseSelected")) { + executor.outFields.put("TestDecideCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); + executor.outFields.put("TestDecideStateTime", timeNow.getTime()); + } + else if (executor.inFields.containsKey("TestMatchCaseSelected")) { + executor.outFields.put("TestEstablishCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); + executor.outFields.put("TestEstablishStateTime", timeNow.getTime()); + } + else { + executor.outFields.put("TestMatchCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); + executor.outFields.put("TestMatchStateTime", timeNow.getTime()); + } + + return true; + } +} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalStateLogic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalStateLogic.java new file mode 100644 index 000000000..49fccd75d --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalStateLogic.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +package org.onap.policy.apex.testsuites.integration.common.model.java; + +import org.onap.policy.apex.core.engine.executor.context.TaskSelectionExecutionContext; + +/** + * The Class EvalState_Logic is default evaluation task selection logic in Java. + */ +public class EvalStateLogic { + /** + * Gets the task. + * + * @param executor the executor + * @return the task + */ + public boolean getTask(final TaskSelectionExecutionContext executor) { + executor.logger.debug(executor.subject.getId()); + executor.subject.getDefaultTaskKey().copyTo(executor.selectedTask); + return true; + } +} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalTaskLogic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalTaskLogic.java new file mode 100644 index 000000000..4c37e4d89 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalTaskLogic.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +package org.onap.policy.apex.testsuites.integration.common.model.java; + +import java.util.Date; + +import org.onap.policy.apex.core.engine.executor.context.TaskExecutionContext; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; + +/** + * The Class EvalTask_Logic is default evaluation task logic in Java. + */ +public class EvalTaskLogic { + + /** + * Gets the event. + * + * @param executor the executor + * @return the event + * @throws ApexException the apex exception + */ + public boolean getEvent(final TaskExecutionContext executor) throws ApexException { + String idString = executor.subject.getId(); + executor.logger.debug(idString); + + String inFieldString = executor.inFields.toString(); + executor.logger.debug(inFieldString); + + executor.outFields.putAll(executor.inFields); + + final Date timeNow = new Date(); + executor.outFields.put("State3Timestamp", timeNow.getTime()); + + String outFieldString = executor.outFields.toString(); + executor.logger.debug(outFieldString); + return true; + } +} diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/package-info.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/package-info.java new file mode 100644 index 000000000..fb5f414d8 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/package-info.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +/** + * Contains the Javadomain specific logic for the test domain. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +package org.onap.policy.apex.testsuites.integration.common.model.java; diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/package-info.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/package-info.java new file mode 100644 index 000000000..e508444c9 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/package-info.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +/** + * Executes tests using all the APEX executors on a test domain model. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +package org.onap.policy.apex.testsuites.integration.common.model; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/DefaultState_Logic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/DefaultState_Logic.javascript deleted file mode 100644 index e25cb9c6e..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/DefaultState_Logic.javascript +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -executor.logger.debug(executor.subject.id); -var gc = executor.getContextAlbum("GlobalContextAlbum"); -executor.logger.debug(gc.name); -executor.subject.defaultTaskKey.copyTo(executor.selectedTask) - -var returnValue = executor.isTrue; - diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/DefaultTask_Logic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/DefaultTask_Logic.javascript deleted file mode 100644 index f98e16555..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/DefaultTask_Logic.javascript +++ /dev/null @@ -1,34 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -executor.logger.debug(executor.subject.id); -var gc = executor.getContextAlbum("GlobalContextAlbum"); -executor.logger.debug(gc.name); -executor.logger.debug(executor.inFields); - -var caseSelectedType = Java.type("java.lang.Byte"); -executor.outFields.put("TestCaseSelected", new caseSelectedType()); - -var JavaDate = Java.type("java.util.Date"); -timeNow = new JavaDate(); -executor.outFields.put("TestStateTime", timeNow.getTime()); -executor.logger.debug(executor.eo); - -var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/EvalState_Logic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/EvalState_Logic.javascript deleted file mode 100644 index 535cad595..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/EvalState_Logic.javascript +++ /dev/null @@ -1,25 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -executor.logger.debug(executor.subject.id); -executor.subject.defaultTaskKey.copyTo(executor.selectedTask); - -var returnValue = executor.isTrue; - diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/EvalTask_Logic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/EvalTask_Logic.javascript deleted file mode 100644 index b0756504c..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/javascript/EvalTask_Logic.javascript +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -executor.logger.debug(executor.subject.id); -executor.logger.debug(executor.inFields); - -var JavaDate = Java.type("java.util.Date"); -timeNow = new JavaDate(); -executor.outFields.put("StateTimestamp", timeNow.getTime()); -executor.logger.debug(executor.outFields); - -var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/DefaultState_Logic.jruby b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/DefaultState_Logic.jruby deleted file mode 100644 index 2965476a8..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/DefaultState_Logic.jruby +++ /dev/null @@ -1,24 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2016-2018 Ericsson. 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. -# 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========================================================= -#------------------------------------------------------------------------------- - -executor.logger.debug("id: " + executor.subject.id) -executor.logger.debug("ctxt name: " + executor.getContextAlbum("GlobalContextAlbum").name) -executor.subject.defaultTaskKey.copyTo(executor.selectedTask) -return true diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/DefaultTask_Logic.jruby b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/DefaultTask_Logic.jruby deleted file mode 100644 index 4ad39f57e..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/DefaultTask_Logic.jruby +++ /dev/null @@ -1,33 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2016-2018 Ericsson. 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. -# 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========================================================= -#------------------------------------------------------------------------------- - -require 'java' - -executor.logger.debug("id: " + executor.subject.id) -executor.logger.debug("ctxt name: " + executor.getContextAlbum("GlobalContextAlbum").name) -executor.logger.debug("inFields: " + executor.inFields.toString()) - -executor.outFields.put("TestCaseSelected", .to_java(:byte)) - -timeNow = java.util.Date.new() -executor.outFields.put("TestStateTime", timeNow.getTime()) -executor.logger.debug("outFields: " + executor.outFields.toString()) - -return true diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/EvalState_Logic.jruby b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/EvalState_Logic.jruby deleted file mode 100644 index e57a62c8b..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/EvalState_Logic.jruby +++ /dev/null @@ -1,23 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2016-2018 Ericsson. 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. -# 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========================================================= -#------------------------------------------------------------------------------- - -executor.logger.debug("id: " + executor.subject.id); -executor.subject.defaultTaskKey.copyTo(executor.selectedTask); -return true; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/EvalTask_Logic.jruby b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/EvalTask_Logic.jruby deleted file mode 100644 index 72a4ee607..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jruby/EvalTask_Logic.jruby +++ /dev/null @@ -1,32 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2016-2018 Ericsson. 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. -# 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========================================================= -#------------------------------------------------------------------------------- - -require 'java'; - -executor.logger.debug("id: " + executor.subject.id); -executor.logger.debug("inFields: " + executor.inFields.toString()); - -executor.outFields.putAll(executor.inFields); - -timeNow = java.util.Date.new(); -executor.outFields.put("StateTimestamp", timeNow.getTime()); -executor.logger.debug("outFields: " + executor.outFields.toString()); - -return true; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/DefaultState_Logic.jython b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/DefaultState_Logic.jython deleted file mode 100644 index 9752f057d..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/DefaultState_Logic.jython +++ /dev/null @@ -1,27 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2016-2018 Ericsson. 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. -# 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========================================================= -#------------------------------------------------------------------------------- - -from java.lang import Boolean -executor.logger.debug('id: ' + executor.subject.id) - -executor.logger.debug('ctxt name: ' + executor.getContextAlbum("GlobalContextAlbum").name) -executor.subject.defaultTaskKey.copyTo(executor.selectedTask) - -returnValue = executor.isTrue diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/DefaultTask_Logic.jython b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/DefaultTask_Logic.jython deleted file mode 100644 index f57ce3f0a..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/DefaultTask_Logic.jython +++ /dev/null @@ -1,35 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2016-2018 Ericsson. 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. -# 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========================================================= -#------------------------------------------------------------------------------- - -from java.lang import Byte -from java.lang import Long -from java.util import Date - -executor.logger.debug('id: ' + executor.subject.id) - -executor.logger.debug('ctxt name: ' + executor.getContextAlbum("GlobalContextAlbum").name) -executor.logger.debug('inFields: ' + executor.inFields.toString()) - -executor.outFields["TestCaseSelected"] = Byte("") - -timeValue = Long(Date().getTime()); -executor.outFields["TestStateTime"] = timeValue -executor.logger.debug('outFields: ' + executor.outFields.toString()) -returnValue = executor.isTrue diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/EvalState_Logic.jython b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/EvalState_Logic.jython deleted file mode 100644 index 94f90b258..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/EvalState_Logic.jython +++ /dev/null @@ -1,25 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2016-2018 Ericsson. 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. -# 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========================================================= -#------------------------------------------------------------------------------- - -executor.logger.debug('id: ' + executor.subject.id); - -executor.subject.defaultTaskKey.copyTo(executor.selectedTask); - -returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/EvalTask_Logic.jython b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/EvalTask_Logic.jython deleted file mode 100644 index aa6525673..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/jython/EvalTask_Logic.jython +++ /dev/null @@ -1,32 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START======================================================= -# Copyright (C) 2016-2018 Ericsson. 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. -# 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========================================================= -#------------------------------------------------------------------------------- - -from java.lang import Boolean -from java.lang import Long -from java.util import Date - -executor.logger.debug('id: ' + executor.subject.id) - -executor.logger.debug('inFields: ' + executor.inFields.toString()) -executor.outFields.putAll(executor.inFields) - -executor.outFields["StateTimestamp"] = Long(Date().getTime()) -executor.logger.debug('outFields: ' + executor.outFields.toString()) -returnValue = Boolean.TRUE diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/DefaultState_Logic.mvel b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/DefaultState_Logic.mvel deleted file mode 100644 index 1620c6cd5..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/DefaultState_Logic.mvel +++ /dev/null @@ -1,23 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -logger.debug(subject.id + ":" + subject.stateName); -subject.defaultTaskKey.copyTo(selectedTask); -return true; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/DefaultTask_Logic.mvel b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/DefaultTask_Logic.mvel deleted file mode 100644 index 9a1a4bad1..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/DefaultTask_Logic.mvel +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -import java.util.Date; -logger.debug(subject.id); -gc = getContextAlbum("GlobalContextAlbum"); -logger.debug(gc); -logger.debug(inFields); -outFields["TestCaseSelected"] = (byte); -timeNow = new Date(); -outFields["TestStateTime"] = timeNow.getTime(); -logger.debug(outFields); -return true; \ No newline at end of file diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/EvalState_Logic.mvel b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/EvalState_Logic.mvel deleted file mode 100644 index 1620c6cd5..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/EvalState_Logic.mvel +++ /dev/null @@ -1,23 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -logger.debug(subject.id + ":" + subject.stateName); -subject.defaultTaskKey.copyTo(selectedTask); -return true; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/EvalTask_Logic.mvel b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/EvalTask_Logic.mvel deleted file mode 100644 index e15a4beec..000000000 --- a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/test/common/model/mvel/EvalTask_Logic.mvel +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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========================================================= - */ - -import java.util.Date; -logger.debug(subject.id); -logger.debug(inFields); -timeNow = new Date(); -outFields["StateTimestamp"] = timeNow.getTime(); -return true; \ No newline at end of file diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultStateLogic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultStateLogic.javascript new file mode 100644 index 000000000..e25cb9c6e --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultStateLogic.javascript @@ -0,0 +1,27 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +executor.logger.debug(executor.subject.id); +var gc = executor.getContextAlbum("GlobalContextAlbum"); +executor.logger.debug(gc.name); +executor.subject.defaultTaskKey.copyTo(executor.selectedTask) + +var returnValue = executor.isTrue; + diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultTaskLogic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultTaskLogic.javascript new file mode 100644 index 000000000..f98e16555 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/DefaultTaskLogic.javascript @@ -0,0 +1,34 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +executor.logger.debug(executor.subject.id); +var gc = executor.getContextAlbum("GlobalContextAlbum"); +executor.logger.debug(gc.name); +executor.logger.debug(executor.inFields); + +var caseSelectedType = Java.type("java.lang.Byte"); +executor.outFields.put("TestCaseSelected", new caseSelectedType()); + +var JavaDate = Java.type("java.util.Date"); +timeNow = new JavaDate(); +executor.outFields.put("TestStateTime", timeNow.getTime()); +executor.logger.debug(executor.eo); + +var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalStateLogic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalStateLogic.javascript new file mode 100644 index 000000000..535cad595 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalStateLogic.javascript @@ -0,0 +1,25 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +executor.logger.debug(executor.subject.id); +executor.subject.defaultTaskKey.copyTo(executor.selectedTask); + +var returnValue = executor.isTrue; + diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalTaskLogic.javascript b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalTaskLogic.javascript new file mode 100644 index 000000000..b0756504c --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/javascript/EvalTaskLogic.javascript @@ -0,0 +1,29 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +executor.logger.debug(executor.subject.id); +executor.logger.debug(executor.inFields); + +var JavaDate = Java.type("java.util.Date"); +timeNow = new JavaDate(); +executor.outFields.put("StateTimestamp", timeNow.getTime()); +executor.logger.debug(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/DefaultStateLogic.jruby b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/DefaultStateLogic.jruby new file mode 100644 index 000000000..2965476a8 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/DefaultStateLogic.jruby @@ -0,0 +1,24 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. 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. +# 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========================================================= +#------------------------------------------------------------------------------- + +executor.logger.debug("id: " + executor.subject.id) +executor.logger.debug("ctxt name: " + executor.getContextAlbum("GlobalContextAlbum").name) +executor.subject.defaultTaskKey.copyTo(executor.selectedTask) +return true diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/DefaultTaskLogic.jruby b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/DefaultTaskLogic.jruby new file mode 100644 index 000000000..4ad39f57e --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/DefaultTaskLogic.jruby @@ -0,0 +1,33 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. 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. +# 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========================================================= +#------------------------------------------------------------------------------- + +require 'java' + +executor.logger.debug("id: " + executor.subject.id) +executor.logger.debug("ctxt name: " + executor.getContextAlbum("GlobalContextAlbum").name) +executor.logger.debug("inFields: " + executor.inFields.toString()) + +executor.outFields.put("TestCaseSelected", .to_java(:byte)) + +timeNow = java.util.Date.new() +executor.outFields.put("TestStateTime", timeNow.getTime()) +executor.logger.debug("outFields: " + executor.outFields.toString()) + +return true diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/EvalStateLogic.jruby b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/EvalStateLogic.jruby new file mode 100644 index 000000000..e57a62c8b --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/EvalStateLogic.jruby @@ -0,0 +1,23 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. 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. +# 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========================================================= +#------------------------------------------------------------------------------- + +executor.logger.debug("id: " + executor.subject.id); +executor.subject.defaultTaskKey.copyTo(executor.selectedTask); +return true; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/EvalTaskLogic.jruby b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/EvalTaskLogic.jruby new file mode 100644 index 000000000..72a4ee607 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jruby/EvalTaskLogic.jruby @@ -0,0 +1,32 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. 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. +# 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========================================================= +#------------------------------------------------------------------------------- + +require 'java'; + +executor.logger.debug("id: " + executor.subject.id); +executor.logger.debug("inFields: " + executor.inFields.toString()); + +executor.outFields.putAll(executor.inFields); + +timeNow = java.util.Date.new(); +executor.outFields.put("StateTimestamp", timeNow.getTime()); +executor.logger.debug("outFields: " + executor.outFields.toString()); + +return true; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/DefaultStateLogic.jython b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/DefaultStateLogic.jython new file mode 100644 index 000000000..9752f057d --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/DefaultStateLogic.jython @@ -0,0 +1,27 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. 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. +# 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========================================================= +#------------------------------------------------------------------------------- + +from java.lang import Boolean +executor.logger.debug('id: ' + executor.subject.id) + +executor.logger.debug('ctxt name: ' + executor.getContextAlbum("GlobalContextAlbum").name) +executor.subject.defaultTaskKey.copyTo(executor.selectedTask) + +returnValue = executor.isTrue diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/DefaultTaskLogic.jython b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/DefaultTaskLogic.jython new file mode 100644 index 000000000..f57ce3f0a --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/DefaultTaskLogic.jython @@ -0,0 +1,35 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. 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. +# 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========================================================= +#------------------------------------------------------------------------------- + +from java.lang import Byte +from java.lang import Long +from java.util import Date + +executor.logger.debug('id: ' + executor.subject.id) + +executor.logger.debug('ctxt name: ' + executor.getContextAlbum("GlobalContextAlbum").name) +executor.logger.debug('inFields: ' + executor.inFields.toString()) + +executor.outFields["TestCaseSelected"] = Byte("") + +timeValue = Long(Date().getTime()); +executor.outFields["TestStateTime"] = timeValue +executor.logger.debug('outFields: ' + executor.outFields.toString()) +returnValue = executor.isTrue diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/EvalStateLogic.jython b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/EvalStateLogic.jython new file mode 100644 index 000000000..94f90b258 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/EvalStateLogic.jython @@ -0,0 +1,25 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. 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. +# 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========================================================= +#------------------------------------------------------------------------------- + +executor.logger.debug('id: ' + executor.subject.id); + +executor.subject.defaultTaskKey.copyTo(executor.selectedTask); + +returnValue = executor.isTrue; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/EvalTaskLogic.jython b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/EvalTaskLogic.jython new file mode 100644 index 000000000..aa6525673 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/jython/EvalTaskLogic.jython @@ -0,0 +1,32 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. 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. +# 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========================================================= +#------------------------------------------------------------------------------- + +from java.lang import Boolean +from java.lang import Long +from java.util import Date + +executor.logger.debug('id: ' + executor.subject.id) + +executor.logger.debug('inFields: ' + executor.inFields.toString()) +executor.outFields.putAll(executor.inFields) + +executor.outFields["StateTimestamp"] = Long(Date().getTime()) +executor.logger.debug('outFields: ' + executor.outFields.toString()) +returnValue = Boolean.TRUE diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/DefaultStateLogic.mvel b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/DefaultStateLogic.mvel new file mode 100644 index 000000000..1620c6cd5 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/DefaultStateLogic.mvel @@ -0,0 +1,23 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +logger.debug(subject.id + ":" + subject.stateName); +subject.defaultTaskKey.copyTo(selectedTask); +return true; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/DefaultTaskLogic.mvel b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/DefaultTaskLogic.mvel new file mode 100644 index 000000000..9a1a4bad1 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/DefaultTaskLogic.mvel @@ -0,0 +1,30 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +import java.util.Date; +logger.debug(subject.id); +gc = getContextAlbum("GlobalContextAlbum"); +logger.debug(gc); +logger.debug(inFields); +outFields["TestCaseSelected"] = (byte); +timeNow = new Date(); +outFields["TestStateTime"] = timeNow.getTime(); +logger.debug(outFields); +return true; \ No newline at end of file diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/EvalStateLogic.mvel b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/EvalStateLogic.mvel new file mode 100644 index 000000000..1620c6cd5 --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/EvalStateLogic.mvel @@ -0,0 +1,23 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +logger.debug(subject.id + ":" + subject.stateName); +subject.defaultTaskKey.copyTo(selectedTask); +return true; diff --git a/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/EvalTaskLogic.mvel b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/EvalTaskLogic.mvel new file mode 100644 index 000000000..e15a4beec --- /dev/null +++ b/testsuites/integration/integration-common/src/main/resources/org/onap/policy/apex/testsuites/integration/common/model/mvel/EvalTaskLogic.mvel @@ -0,0 +1,26 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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========================================================= + */ + +import java.util.Date; +logger.debug(subject.id); +logger.debug(inFields); +timeNow = new Date(); +outFields["StateTimestamp"] = timeNow.getTime(); +return true; \ No newline at end of file -- cgit 1.2.3-korg