aboutsummaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-common/src/main/java/org
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-13 23:48:50 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-13 23:49:32 +0100
commitcd68fc9bae7d6258f77ff59c1431e4f925f61a4c (patch)
tree53054a7c8e8738644785039c3a200c6b23d4b3ed /testsuites/integration/integration-common/src/main/java/org
parent4cfa2e2d98f6877d54da304ef17f096284430908 (diff)
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 <liam.fallon@ericsson.com>
Diffstat (limited to 'testsuites/integration/integration-common/src/main/java/org')
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelFactory.java717
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactory.java (renamed from testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/EvalDomainModelFactory.java)340
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactory.java776
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaver.java (renamed from testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/SampleDomainModelSaver.java)24
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultStateLogic.java (renamed from testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultState_Logic.java)6
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java (renamed from testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/DefaultTask_Logic.java)27
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalStateLogic.java (renamed from testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalState_Logic.java)6
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/EvalTaskLogic.java (renamed from testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/EvalTask_Logic.java)16
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/package-info.java (renamed from testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/java/package-info.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/package-info.java (renamed from testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/test/common/model/package-info.java)2
10 files changed, 1037 insertions, 879 deletions
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<AxArtifactKey> referenceKeySet0 = new TreeSet<AxArtifactKey>();
- referenceKeySet0.add(policy0ContextAlbum.getKey());
- referenceKeySet0.add(policy1ContextAlbum.getKey());
- referenceKeySet0.add(globalContextAlbum.getKey());
- referenceKeySet0.add(externalContextAlbum.getKey());
-
- Set<AxArtifactKey> referenceKeySet1 = new TreeSet<AxArtifactKey>();
- referenceKeySet1.add(policy0ContextAlbum.getKey());
- referenceKeySet1.add(globalContextAlbum.getKey());
-
- Set<AxArtifactKey> referenceKeySet2 = new TreeSet<AxArtifactKey>();
- referenceKeySet2.add(policy1ContextAlbum.getKey());
- referenceKeySet2.add(globalContextAlbum.getKey());
-
- Set<AxArtifactKey> referenceKeySet3 = new TreeSet<AxArtifactKey>();
- referenceKeySet3.add(globalContextAlbum.getKey());
- referenceKeySet3.add(externalContextAlbum.getKey());
-
- List<Set<AxArtifactKey>> referenceKeySetList = new ArrayList<Set<AxArtifactKey>>();
- 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<AxArtifactKey> matchTasks = new TreeSet<AxArtifactKey>();
- Set<AxArtifactKey> establishTasks = new TreeSet<AxArtifactKey>();
- Set<AxArtifactKey> decideTasks = new TreeSet<AxArtifactKey>();
- Set<AxArtifactKey> actTasks = new TreeSet<AxArtifactKey>();
- 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<Set<AxArtifactKey>> taskReferenceList = new ArrayList<Set<AxArtifactKey>>();
- taskReferenceList.add(matchTasks);
- taskReferenceList.add(establishTasks);
- taskReferenceList.add(decideTasks);
- taskReferenceList.add(actTasks);
-
- List<AxArtifactKey> p0InEventList = new ArrayList<AxArtifactKey>();
- p0InEventList.add(event0000.getKey());
- p0InEventList.add(event0001.getKey());
- p0InEventList.add(event0002.getKey());
- p0InEventList.add(event0003.getKey());
-
- List<AxArtifactKey> p0OutEventList = new ArrayList<AxArtifactKey>();
- p0OutEventList.add(event0001.getKey());
- p0OutEventList.add(event0002.getKey());
- p0OutEventList.add(event0003.getKey());
- p0OutEventList.add(event0004.getKey());
-
- List<AxArtifactKey> p0defaultTaskList = new ArrayList<AxArtifactKey>();
- 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<AxArtifactKey> p1InEventList = new ArrayList<AxArtifactKey>();
- p1InEventList.add(event0100.getKey());
- p1InEventList.add(event0101.getKey());
- p1InEventList.add(event0102.getKey());
- p1InEventList.add(event0103.getKey());
-
- List<AxArtifactKey> p1OutEventList = new ArrayList<AxArtifactKey>();
- p1OutEventList.add(event0101.getKey());
- p1OutEventList.add(event0102.getKey());
- p1OutEventList.add(event0103.getKey());
- p1OutEventList.add(event0104.getKey());
-
- List<AxArtifactKey> p1defaultTaskList = new ArrayList<AxArtifactKey>();
- 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<AxArtifactKey> p0ReferenceKeySet0 = new TreeSet<AxArtifactKey>();
- p0ReferenceKeySet0.add(policy0ContextAlbum.getKey());
- p0ReferenceKeySet0.add(globalContextAlbum.getKey());
-
- Set<AxArtifactKey> p0ReferenceKeySet1 = new TreeSet<AxArtifactKey>();
- p0ReferenceKeySet1.add(policy1ContextAlbum.getKey());
- p0ReferenceKeySet1.add(globalContextAlbum.getKey());
- p0ReferenceKeySet1.add(externalContextAlbum.getKey());
-
- Set<AxArtifactKey> p0ReferenceKeySet2 = new TreeSet<AxArtifactKey>();
- p0ReferenceKeySet2.add(policy0ContextAlbum.getKey());
- p0ReferenceKeySet2.add(globalContextAlbum.getKey());
- p0ReferenceKeySet2.add(externalContextAlbum.getKey());
-
- Set<AxArtifactKey> p0ReferenceKeySet3 = new TreeSet<AxArtifactKey>();
- p0ReferenceKeySet3.add(globalContextAlbum.getKey());
-
- List<Set<AxArtifactKey>> p0ReferenceKeySetList = new ArrayList<Set<AxArtifactKey>>();
- 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<AxArtifactKey> p1ReferenceKeySet0 = new TreeSet<AxArtifactKey>();
- p1ReferenceKeySet0.add(policy1ContextAlbum.getKey());
- p1ReferenceKeySet0.add(globalContextAlbum.getKey());
- p1ReferenceKeySet0.add(externalContextAlbum.getKey());
-
- Set<AxArtifactKey> p1ReferenceKeySet1 = new TreeSet<AxArtifactKey>();
- p1ReferenceKeySet1.add(policy1ContextAlbum.getKey());
- p1ReferenceKeySet1.add(globalContextAlbum.getKey());
- p1ReferenceKeySet1.add(externalContextAlbum.getKey());
-
- Set<AxArtifactKey> p1ReferenceKeySet2 = new TreeSet<AxArtifactKey>();
- p1ReferenceKeySet2.add(policy1ContextAlbum.getKey());
- p1ReferenceKeySet2.add(globalContextAlbum.getKey());
- p1ReferenceKeySet2.add(externalContextAlbum.getKey());
-
- Set<AxArtifactKey> p1ReferenceKeySet3 = new TreeSet<AxArtifactKey>();
- p1ReferenceKeySet3.add(globalContextAlbum.getKey());
-
- List<Set<AxArtifactKey>> p1ReferenceKeySetList = new ArrayList<Set<AxArtifactKey>>();
- 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<String, AxState> getStateMap(final AxArtifactKey policyKey, final List<AxArtifactKey> inEventKeyList,
- final List<AxArtifactKey> outEventKeyList, final List<Set<AxArtifactKey>> referenceKeySetList,
- final String axLogicExecutorType, final List<AxArtifactKey> defaultTaskList,
- final List<Set<AxArtifactKey>> 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<String, AxState> stateMap = new TreeMap<String, AxState>();
- 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<AxArtifactKey, AxTask> getTaskMap(final String state, final Map<String, AxField> inputFields,
- final Map<String, AxField> outputFields, final List<Set<AxArtifactKey>> 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<AxArtifactKey, AxTask> taskMap = new TreeMap<AxArtifactKey, AxTask>();
- 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("<STATE_NAME>", stateName)
- .replaceAll("<TASK_NAME>", task.getKey().getName()).replaceAll("<RANDOM_BYTE_VALUE>", caseToUse));
-
- return axLogic;
- }
-}
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/testsuites/integration/common/model/EvalDomainModelFactory.java
index a3f626f48..a36aa1030 100644
--- 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/testsuites/integration/common/model/EvalDomainModelFactory.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.test.common.model;
+package org.onap.policy.apex.testsuites.integration.common.model;
import java.util.ArrayList;
import java.util.Arrays;
@@ -59,6 +59,29 @@ import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader;
* @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 = "<STATE_NAME>";
+ private static final String OBSERVE = "Observe";
+ private static final String JAVASCRIPT = "JAVASCRIPT";
+ private static final String TASK_NAME = "<TASK_NAME>";
+ private static final String TASK_LOGIC = "TaskLogic";
+ private static final String STATE_NUMBER = "<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();
@@ -91,61 +114,89 @@ public class EvalDomainModelFactory {
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");
+ 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", "0.0.1"));
+ 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", "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"));
+ 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);
@@ -158,41 +209,46 @@ public class EvalDomainModelFactory {
*
* @return the sample policy model
*/
- public AxPolicyModel getOODAPolicyModel() {
+ 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 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("<STATE_NAME>", "Observe").replaceAll("<TASK_NAME>", obTask.getKey().getName())
- .replaceAll("<STATE_NUMBER>", "1"));
+ 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(), "TaskLogic", (justOneLang == null ? "JAVASCRIPT" : justOneLang), logicReader);
- orAxLogic.setLogic(orAxLogic.getLogic().replaceAll("<STATE_NAME>", "Orient").replaceAll("<TASK_NAME>", orTask.getKey().getName())
- .replaceAll("<STATE_NUMBER>", "2"));
+ 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(), "TaskLogic", (justOneLang == null ? "MVEL" : justOneLang), logicReader);
- dAxLogic.setLogic(
- dAxLogic.getLogic().replaceAll("<STATE_NAME>", "Orient").replaceAll("<TASK_NAME>", dTask.getKey().getName()).replaceAll("<STATE_NUMBER>", "3"));
+ 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(), "TaskLogic", (justOneLang == null ? "JAVA" : justOneLang), logicReader);
- aAxLogic.setLogic(
- aAxLogic.getLogic().replaceAll("<STATE_NAME>", "Act").replaceAll("<TASK_NAME>", aTask.getKey().getName()).replaceAll("<STATE_NUMBER>", "4"));
+ 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);
@@ -206,10 +262,10 @@ public class EvalDomainModelFactory {
final Set<AxArtifactKey> actTasks = new TreeSet<>();
for (final AxTask task : tasks.getTaskMap().values()) {
- if (task.getKey().getName().contains("Observe")) {
+ if (task.getKey().getName().contains(OBSERVE)) {
obTasks.add(task.getKey());
}
- if (task.getKey().getName().contains("Orient")) {
+ if (task.getKey().getName().contains(ORIENT)) {
orTasks.add(task.getKey());
}
if (task.getKey().getName().contains("Decide")) {
@@ -244,10 +300,12 @@ public class EvalDomainModelFactory {
p0defaultTaskList.add(tasks.get("Task_Act_0").getKey());
final AxPolicy policy0 = new AxPolicy(new AxArtifactKey("OODAPolicy_0", "0.0.1"));
- final List<String> 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 List<String> 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);
@@ -280,55 +338,67 @@ public class EvalDomainModelFactory {
* @param taskKeySetList the task key set list
* @return the OODA state map
*/
- private Map<String, AxState> getOODAStateMap(final AxArtifactKey policyKey, final List<AxArtifactKey> inEventKeyList,
- final List<AxArtifactKey> outEventKeyList, final List<String> axLogicExecutorTypeList, final List<AxArtifactKey> defaultTaskList,
- final List<Set<AxArtifactKey>> taskKeySetList) {
- final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE).setDefaultLogic("EvalState_Logic");
+ private Map<String, AxState> getOodaStateMap(final AxArtifactKey policyKey,
+ final List<AxArtifactKey> inEventKeyList, final List<AxArtifactKey> outEventKeyList,
+ final List<String> axLogicExecutorTypeList, final List<AxArtifactKey> defaultTaskList,
+ final List<Set<AxArtifactKey>> 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());
+ 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.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()));
+ 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());
+ 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.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()));
+ new AxStateTaskReference(new AxReferenceKey(decState.getKey(), taskKey.getName()),
+ AxStateTaskOutputType.DIRECT, dec2Act.getKey()));
}
- final AxState orState = new AxState(new AxReferenceKey(policyKey, "Orient"));
+ 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());
+ 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.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()));
+ new AxStateTaskReference(new AxReferenceKey(orState.getKey(), taskKey.getName()),
+ AxStateTaskOutputType.DIRECT, or2Dec.getKey()));
}
- final AxState obState = new AxState(new AxReferenceKey(policyKey, "Observe"));
+ 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());
+ 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.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()));
+ new AxStateTaskReference(new AxReferenceKey(obState.getKey(), taskKey.getName()),
+ AxStateTaskOutputType.DIRECT, ob2Or.getKey()));
}
final Map<String, AxState> stateMap = new TreeMap<>();
@@ -345,34 +415,38 @@ public class EvalDomainModelFactory {
*
* @return the sample policy model
*/
- public AxPolicyModel getECAPolicyModel() {
+ 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 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("<STATE_NAME>", "Event").replaceAll("<TASK_NAME>", eTask.getKey().getName()).replaceAll("<STATE_NUMBER>", "1"));
+ 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(), "TaskLogic", (justOneLang == null ? "JAVASCRIPT" : justOneLang), logicReader);
- cAxLogic.setLogic(cAxLogic.getLogic().replaceAll("<STATE_NAME>", "Condition").replaceAll("<TASK_NAME>", cTask.getKey().getName())
- .replaceAll("<STATE_NUMBER>", "2"));
+ 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(), "TaskLogic", (justOneLang == null ? "JAVA" : justOneLang), logicReader);
- aAxLogic.setLogic(
- aAxLogic.getLogic().replaceAll("<STATE_NAME>", "Action").replaceAll("<TASK_NAME>", aTask.getKey().getName()).replaceAll("<STATE_NUMBER>", "3"));
+ 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);
@@ -384,13 +458,13 @@ public class EvalDomainModelFactory {
final Set<AxArtifactKey> actionTasks = new TreeSet<>();
for (final AxTask task : tasks.getTaskMap().values()) {
- if (task.getKey().getName().contains("Event")) {
+ if (task.getKey().getName().contains(EVENT)) {
eventTasks.add(task.getKey());
}
- if (task.getKey().getName().contains("Condition")) {
+ if (task.getKey().getName().contains(CONDITION)) {
conditionTasks.add(task.getKey());
}
- if (task.getKey().getName().contains("Action")) {
+ if (task.getKey().getName().contains(ACTION)) {
actionTasks.add(task.getKey());
}
}
@@ -415,10 +489,11 @@ public class EvalDomainModelFactory {
p0defaultTaskList.add(tasks.get("Task_Action_0").getKey());
final AxPolicy policy0 = new AxPolicy(new AxArtifactKey("ECAPolicy_0", "0.0.1"));
- final List<String> 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 List<String> 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);
@@ -451,43 +526,52 @@ public class EvalDomainModelFactory {
* @param taskKeySetList the task key set list
* @return the ECA state map
*/
- private Map<String, AxState> getECAStateMap(final AxArtifactKey policyKey, final List<AxArtifactKey> inEventKeyList,
- final List<AxArtifactKey> outEventKeyList, final List<String> axLogicExecutorTypeList, final List<AxArtifactKey> defaultTaskList,
- final List<Set<AxArtifactKey>> taskKeySetList) {
- final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE).setDefaultLogic("EvalState_Logic");
+ private Map<String, AxState> getEcaStateMap(final AxArtifactKey policyKey, final List<AxArtifactKey> inEventKeyList,
+ final List<AxArtifactKey> outEventKeyList, final List<String> axLogicExecutorTypeList,
+ final List<AxArtifactKey> defaultTaskList, final List<Set<AxArtifactKey>> taskKeySetList) {
+ final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE)
+ .setDefaultLogic("EvalState_Logic");
- final AxState actionState = new AxState(new AxReferenceKey(policyKey, "Action"));
+ 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));
+ 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.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()));
+ new AxStateTaskReference(new AxReferenceKey(actionState.getKey(), taskKey.getName()),
+ AxStateTaskOutputType.DIRECT, action2Out.getKey()));
}
- final AxState conditionState = new AxState(new AxReferenceKey(policyKey, "Condition"));
+ 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));
+ 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.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()));
+ 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"));
+ 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));
+ 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.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()));
+ eventState.getTaskReferences().put(taskKey,
+ new AxStateTaskReference(new AxReferenceKey(eventState.getKey(), taskKey.getName()),
+ AxStateTaskOutputType.DIRECT, event2Condition.getKey()));
}
final Map<String, AxState> stateMap = new TreeMap<>();
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<AxArtifactKey> referenceKeySet0 = new TreeSet<>();
+ referenceKeySet0.add(policy0ContextAlbum.getKey());
+ referenceKeySet0.add(policy1ContextAlbum.getKey());
+ referenceKeySet0.add(globalContextAlbum.getKey());
+ referenceKeySet0.add(externalContextAlbum.getKey());
+
+ Set<AxArtifactKey> referenceKeySet1 = new TreeSet<>();
+ referenceKeySet1.add(policy0ContextAlbum.getKey());
+ referenceKeySet1.add(globalContextAlbum.getKey());
+
+ Set<AxArtifactKey> referenceKeySet2 = new TreeSet<>();
+ referenceKeySet2.add(policy1ContextAlbum.getKey());
+ referenceKeySet2.add(globalContextAlbum.getKey());
+
+ Set<AxArtifactKey> referenceKeySet3 = new TreeSet<>();
+ referenceKeySet3.add(globalContextAlbum.getKey());
+ referenceKeySet3.add(externalContextAlbum.getKey());
+
+ List<Set<AxArtifactKey>> 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<AxArtifactKey> matchTasks = new TreeSet<>();
+ Set<AxArtifactKey> establishTasks = new TreeSet<>();
+ Set<AxArtifactKey> decideTasks = new TreeSet<>();
+ Set<AxArtifactKey> 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<Set<AxArtifactKey>> taskReferenceList = new ArrayList<>();
+ taskReferenceList.add(matchTasks);
+ taskReferenceList.add(establishTasks);
+ taskReferenceList.add(decideTasks);
+ taskReferenceList.add(actTasks);
+
+ List<AxArtifactKey> p0InEventList = new ArrayList<>();
+ p0InEventList.add(event0000.getKey());
+ p0InEventList.add(event0001.getKey());
+ p0InEventList.add(event0002.getKey());
+ p0InEventList.add(event0003.getKey());
+
+ List<AxArtifactKey> p0OutEventList = new ArrayList<>();
+ p0OutEventList.add(event0001.getKey());
+ p0OutEventList.add(event0002.getKey());
+ p0OutEventList.add(event0003.getKey());
+ p0OutEventList.add(event0004.getKey());
+
+ List<AxArtifactKey> 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<AxArtifactKey> p1InEventList = new ArrayList<>();
+ p1InEventList.add(event0100.getKey());
+ p1InEventList.add(event0101.getKey());
+ p1InEventList.add(event0102.getKey());
+ p1InEventList.add(event0103.getKey());
+
+ List<AxArtifactKey> p1OutEventList = new ArrayList<>();
+ p1OutEventList.add(event0101.getKey());
+ p1OutEventList.add(event0102.getKey());
+ p1OutEventList.add(event0103.getKey());
+ p1OutEventList.add(event0104.getKey());
+
+ List<AxArtifactKey> 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<AxArtifactKey> p0ReferenceKeySet0 = new TreeSet<>();
+ p0ReferenceKeySet0.add(policy0ContextAlbum.getKey());
+ p0ReferenceKeySet0.add(globalContextAlbum.getKey());
+
+ Set<AxArtifactKey> p0ReferenceKeySet1 = new TreeSet<>();
+ p0ReferenceKeySet1.add(policy1ContextAlbum.getKey());
+ p0ReferenceKeySet1.add(globalContextAlbum.getKey());
+ p0ReferenceKeySet1.add(externalContextAlbum.getKey());
+
+ Set<AxArtifactKey> p0ReferenceKeySet2 = new TreeSet<>();
+ p0ReferenceKeySet2.add(policy0ContextAlbum.getKey());
+ p0ReferenceKeySet2.add(globalContextAlbum.getKey());
+ p0ReferenceKeySet2.add(externalContextAlbum.getKey());
+
+ Set<AxArtifactKey> p0ReferenceKeySet3 = new TreeSet<>();
+ p0ReferenceKeySet3.add(globalContextAlbum.getKey());
+
+ List<Set<AxArtifactKey>> 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<AxArtifactKey> p1ReferenceKeySet0 = new TreeSet<>();
+ p1ReferenceKeySet0.add(policy1ContextAlbum.getKey());
+ p1ReferenceKeySet0.add(globalContextAlbum.getKey());
+ p1ReferenceKeySet0.add(externalContextAlbum.getKey());
+
+ Set<AxArtifactKey> p1ReferenceKeySet1 = new TreeSet<>();
+ p1ReferenceKeySet1.add(policy1ContextAlbum.getKey());
+ p1ReferenceKeySet1.add(globalContextAlbum.getKey());
+ p1ReferenceKeySet1.add(externalContextAlbum.getKey());
+
+ Set<AxArtifactKey> p1ReferenceKeySet2 = new TreeSet<>();
+ p1ReferenceKeySet2.add(policy1ContextAlbum.getKey());
+ p1ReferenceKeySet2.add(globalContextAlbum.getKey());
+ p1ReferenceKeySet2.add(externalContextAlbum.getKey());
+
+ Set<AxArtifactKey> p1ReferenceKeySet3 = new TreeSet<>();
+ p1ReferenceKeySet3.add(globalContextAlbum.getKey());
+
+ List<Set<AxArtifactKey>> 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<String, AxState> getStateMap(final AxArtifactKey policyKey, final List<AxArtifactKey> inEventKeyList,
+ final List<AxArtifactKey> outEventKeyList, final List<Set<AxArtifactKey>> referenceKeySetList,
+ final String axLogicExecutorType, final List<AxArtifactKey> defaultTaskList,
+ final List<Set<AxArtifactKey>> 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<String, AxState> 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<AxArtifactKey, AxTask> getTaskMap(final String state, final Map<String, AxField> inputFields,
+ final Map<String, AxField> outputFields, final List<Set<AxArtifactKey>> 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<AxArtifactKey, AxTask> 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("<STATE_NAME>", stateName)
+ .replaceAll("<TASK_NAME>", task.getKey().getName())
+ .replaceAll("<RANDOM_BYTE_VALUE>", 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/testsuites/integration/common/model/SampleDomainModelSaver.java
index 6ca644ff4..8eb885759 100644
--- 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/testsuites/integration/common/model/SampleDomainModelSaver.java
@@ -18,11 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.test.common.model;
+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.
@@ -30,6 +32,9 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
* @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.
*/
@@ -44,37 +49,42 @@ public final class SampleDomainModelSaver {
*/
public static void main(final String[] args) throws ApexException {
if (args.length != 1) {
- System.err.println("usage: " + SampleDomainModelSaver.class.getCanonicalName() + " modelDirectory");
+ LOGGER.error("usage: " + SampleDomainModelSaver.class.getCanonicalName() + " modelDirectory");
return;
}
// Save Java model
final AxPolicyModel javaPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVA");
- final ApexModelSaver<AxPolicyModel> javaModelSaver = new ApexModelSaver<AxPolicyModel>(AxPolicyModel.class, javaPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> javaModelSaver = new ApexModelSaver<>(AxPolicyModel.class,
+ javaPolicyModel, args[0]);
javaModelSaver.apexModelWriteJson();
javaModelSaver.apexModelWriteXml();
// Save Javascript model
final AxPolicyModel javascriptPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
- final ApexModelSaver<AxPolicyModel> javascriptModelSaver = new ApexModelSaver<AxPolicyModel>(AxPolicyModel.class, javascriptPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> javascriptModelSaver = new ApexModelSaver<>(
+ AxPolicyModel.class, javascriptPolicyModel, args[0]);
javascriptModelSaver.apexModelWriteJson();
javascriptModelSaver.apexModelWriteXml();
// Save JRuby model
final AxPolicyModel jRubyPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JRUBY");
- final ApexModelSaver<AxPolicyModel> jRubyModelSaver = new ApexModelSaver<AxPolicyModel>(AxPolicyModel.class, jRubyPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> jRubyModelSaver = new ApexModelSaver<>(AxPolicyModel.class,
+ jRubyPolicyModel, args[0]);
jRubyModelSaver.apexModelWriteJson();
jRubyModelSaver.apexModelWriteXml();
// Save Jython model
final AxPolicyModel jythonPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JYTHON");
- final ApexModelSaver<AxPolicyModel> jythonModelSaver = new ApexModelSaver<AxPolicyModel>(AxPolicyModel.class, jythonPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> jythonModelSaver = new ApexModelSaver<>(AxPolicyModel.class,
+ jythonPolicyModel, args[0]);
jythonModelSaver.apexModelWriteJson();
jythonModelSaver.apexModelWriteXml();
// Save MVEL model
final AxPolicyModel mvelPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
- final ApexModelSaver<AxPolicyModel> mvelModelSaver = new ApexModelSaver<AxPolicyModel>(AxPolicyModel.class, mvelPolicyModel, args[0]);
+ final ApexModelSaver<AxPolicyModel> 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/testsuites/integration/common/model/java/DefaultStateLogic.java
index d970835d0..2669e70d7 100644
--- 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/testsuites/integration/common/model/java/DefaultStateLogic.java
@@ -18,16 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.test.common.model.java;
+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.
*/
-// CHECKSTYLE:OFF: checkstyle:typeNames
-public class DefaultState_Logic {
- // CHECKSTYLE:ON: checkstyle:typeNames
+public class DefaultStateLogic {
/**
* Gets the task.
*
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/testsuites/integration/common/model/java/DefaultTaskLogic.java
index b22f15d90..86dac6638 100644
--- 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/testsuites/integration/common/model/java/DefaultTaskLogic.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.test.common.model.java;
+package org.onap.policy.apex.testsuites.integration.common.model.java;
import java.util.Date;
import java.util.Random;
@@ -29,12 +29,10 @@ 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
+public class DefaultTaskLogic {
private static final int BOUND_FOR_RANDOM_INT = 4;
- /**
+ /**
* Gets the event.
*
* @param executor the executor
@@ -42,27 +40,32 @@ public class DefaultTask_Logic {
* @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());
+ 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", new Byte((byte) rand.nextInt(BOUND_FOR_RANDOM_INT)));
+ 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", new Byte((byte) rand.nextInt(BOUND_FOR_RANDOM_INT)));
+ 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", new Byte((byte) rand.nextInt(BOUND_FOR_RANDOM_INT)));
+ executor.outFields.put("TestEstablishCaseSelected", (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("TestMatchCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
executor.outFields.put("TestMatchStateTime", timeNow.getTime());
}
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/testsuites/integration/common/model/java/EvalStateLogic.java
index 2180936ed..49fccd75d 100644
--- 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/testsuites/integration/common/model/java/EvalStateLogic.java
@@ -18,16 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.test.common.model.java;
+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.
*/
-//CHECKSTYLE:OFF: checkstyle:typeNames
-public class EvalState_Logic {
- // CHECKSTYLE:ON: checkstyle:typeNames
+public class EvalStateLogic {
/**
* Gets the task.
*
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/testsuites/integration/common/model/java/EvalTaskLogic.java
index f4fa533f8..4c37e4d89 100644
--- 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/testsuites/integration/common/model/java/EvalTaskLogic.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.test.common.model.java;
+package org.onap.policy.apex.testsuites.integration.common.model.java;
import java.util.Date;
@@ -28,7 +28,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
/**
* The Class EvalTask_Logic is default evaluation task logic in Java.
*/
-public class EvalTask_Logic {
+public class EvalTaskLogic {
/**
* Gets the event.
@@ -38,13 +38,19 @@ public class EvalTask_Logic {
* @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());
+ 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());
- executor.logger.debug(executor.outFields.toString());
+
+ 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/test/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
index 70c8452b5..fb5f414d8 100644
--- 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/testsuites/integration/common/model/java/package-info.java
@@ -23,4 +23,4 @@
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.policy.apex.test.common.model.java;
+package org.onap.policy.apex.testsuites.integration.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/testsuites/integration/common/model/package-info.java
index 9277bd43c..e508444c9 100644
--- 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/testsuites/integration/common/model/package-info.java
@@ -23,4 +23,4 @@
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.policy.apex.test.common.model;
+package org.onap.policy.apex.testsuites.integration.common.model;