184529fa95b10d9648e8384a77b3ce8182c828f1
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.test.common.model;
22
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.Set;
27 import java.util.TreeMap;
28 import java.util.TreeSet;
29
30 import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
31 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
32 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
33 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
34 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
35 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
36 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
37 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
38 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
39 import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
40 import org.onap.policy.apex.model.eventmodel.concepts.AxEvents;
41 import org.onap.policy.apex.model.eventmodel.concepts.AxField;
42 import org.onap.policy.apex.model.policymodel.concepts.AxLogicReader;
43 import org.onap.policy.apex.model.policymodel.concepts.AxPolicies;
44 import org.onap.policy.apex.model.policymodel.concepts.AxPolicy;
45 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
46 import org.onap.policy.apex.model.policymodel.concepts.AxState;
47 import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput;
48 import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType;
49 import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference;
50 import org.onap.policy.apex.model.policymodel.concepts.AxTask;
51 import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic;
52 import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter;
53 import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic;
54 import org.onap.policy.apex.model.policymodel.concepts.AxTasks;
55 import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader;
56
57 /**
58  * This class creates sample Policy Models.
59  *
60  * @author Liam Fallon (liam.fallon@ericsson.com)
61  */
62 public class SampleDomainModelFactory {
63     private static final int THIRD_ENTRY = 3;
64
65     /**
66      * Get a sample policy model.
67      *
68      * @param axLogicExecutorType The type of logic executor, the scripting language being used
69      * @return the sample policy model
70      */
71     // CHECKSTYLE:OFF: checkstyle:maximumMethodLength
72     public AxPolicyModel getSamplePolicyModel(final String axLogicExecutorType) {
73         AxContextSchema testSlogan =
74                 new AxContextSchema(new AxArtifactKey("TestSlogan", "0.0.1"), "Java", "java.lang.String");
75         AxContextSchema testCase =
76                 new AxContextSchema(new AxArtifactKey("TestCase", "0.0.1"), "Java", "java.lang.Byte");
77         AxContextSchema testTimestamp =
78                 new AxContextSchema(new AxArtifactKey("TestTimestamp", "0.0.1"), "Java", "java.lang.Long");
79         AxContextSchema testTemperature =
80                 new AxContextSchema(new AxArtifactKey("TestTemperature", "0.0.1"), "Java", "java.lang.Double");
81
82         AxContextSchema testContextItem000 = new AxContextSchema(new AxArtifactKey("TestContextItem000", "0.0.1"),
83                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem000");
84         AxContextSchema testContextItem001 = new AxContextSchema(new AxArtifactKey("TestContextItem001", "0.0.1"),
85                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem001");
86         AxContextSchema testContextItem002 = new AxContextSchema(new AxArtifactKey("TestContextItem002", "0.0.1"),
87                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem002");
88         AxContextSchema testContextItem003 = new AxContextSchema(new AxArtifactKey("TestContextItem003", "0.0.1"),
89                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem003");
90         AxContextSchema testContextItem004 = new AxContextSchema(new AxArtifactKey("TestContextItem004", "0.0.1"),
91                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem004");
92         AxContextSchema testContextItem005 = new AxContextSchema(new AxArtifactKey("TestContextItem005", "0.0.1"),
93                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem005");
94         AxContextSchema testContextItem006 = new AxContextSchema(new AxArtifactKey("TestContextItem006", "0.0.1"),
95                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem006");
96         AxContextSchema testContextItem007 = new AxContextSchema(new AxArtifactKey("TestContextItem007", "0.0.1"),
97                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem007");
98         AxContextSchema testContextItem008 = new AxContextSchema(new AxArtifactKey("TestContextItem008", "0.0.1"),
99                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem008");
100         AxContextSchema testContextItem009 = new AxContextSchema(new AxArtifactKey("TestContextItem009", "0.0.1"),
101                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem009");
102         AxContextSchema testContextItem00A = new AxContextSchema(new AxArtifactKey("TestContextItem00A", "0.0.1"),
103                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem00A");
104         AxContextSchema testContextItem00B = new AxContextSchema(new AxArtifactKey("TestContextItem00B", "0.0.1"),
105                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem00B");
106         AxContextSchema testContextItem00C = new AxContextSchema(new AxArtifactKey("TestContextItem00C", "0.0.1"),
107                 "Java", "org.onap.policy.apex.context.test.concepts.TestContextItem00C");
108
109         AxContextSchema testPolicyContextItem = new AxContextSchema(new AxArtifactKey("TestPolicyContextItem", "0.0.1"),
110                 "Java", "org.onap.policy.apex.context.test.concepts.TestPolicyContextItem");
111         AxContextSchema testGlobalContextItem = new AxContextSchema(new AxArtifactKey("TestGlobalContextItem", "0.0.1"),
112                 "Java", "org.onap.policy.apex.context.test.concepts.TestGlobalContextItem");
113         AxContextSchema testExternalContextItem =
114                 new AxContextSchema(new AxArtifactKey("TestExternalContextItem", "0.0.1"), "Java",
115                         "org.onap.policy.apex.context.test.concepts.TestExternalContextItem");
116
117         AxContextSchemas axContextSchemas = new AxContextSchemas(new AxArtifactKey("TestDatatypes", "0.0.1"));
118         axContextSchemas.getSchemasMap().put(testSlogan.getKey(), testSlogan);
119         axContextSchemas.getSchemasMap().put(testCase.getKey(), testCase);
120         axContextSchemas.getSchemasMap().put(testTimestamp.getKey(), testTimestamp);
121         axContextSchemas.getSchemasMap().put(testTemperature.getKey(), testTemperature);
122
123         axContextSchemas.getSchemasMap().put(testContextItem000.getKey(), testContextItem000);
124         axContextSchemas.getSchemasMap().put(testContextItem001.getKey(), testContextItem001);
125         axContextSchemas.getSchemasMap().put(testContextItem002.getKey(), testContextItem002);
126         axContextSchemas.getSchemasMap().put(testContextItem003.getKey(), testContextItem003);
127         axContextSchemas.getSchemasMap().put(testContextItem004.getKey(), testContextItem004);
128         axContextSchemas.getSchemasMap().put(testContextItem005.getKey(), testContextItem005);
129         axContextSchemas.getSchemasMap().put(testContextItem006.getKey(), testContextItem006);
130         axContextSchemas.getSchemasMap().put(testContextItem007.getKey(), testContextItem007);
131         axContextSchemas.getSchemasMap().put(testContextItem008.getKey(), testContextItem008);
132         axContextSchemas.getSchemasMap().put(testContextItem009.getKey(), testContextItem009);
133         axContextSchemas.getSchemasMap().put(testContextItem00A.getKey(), testContextItem00A);
134         axContextSchemas.getSchemasMap().put(testContextItem00B.getKey(), testContextItem00B);
135         axContextSchemas.getSchemasMap().put(testContextItem00C.getKey(), testContextItem00C);
136
137         axContextSchemas.getSchemasMap().put(testPolicyContextItem.getKey(), testPolicyContextItem);
138         axContextSchemas.getSchemasMap().put(testGlobalContextItem.getKey(), testGlobalContextItem);
139         axContextSchemas.getSchemasMap().put(testExternalContextItem.getKey(), testExternalContextItem);
140
141         AxEvent event0000 = new AxEvent(new AxArtifactKey("Event0000", "0.0.1"), "org.onap.policy.apex.sample.events");
142         event0000.setSource("Outside");
143         event0000.setTarget("Match");
144         event0000.getParameterMap().put("TestSlogan",
145                 new AxField(new AxReferenceKey(event0000.getKey(), "TestSlogan"), testSlogan.getKey()));
146         event0000.getParameterMap().put("TestMatchCase",
147                 new AxField(new AxReferenceKey(event0000.getKey(), "TestMatchCase"), testCase.getKey()));
148         event0000.getParameterMap().put("TestTimestamp",
149                 new AxField(new AxReferenceKey(event0000.getKey(), "TestTimestamp"), testTimestamp.getKey()));
150         event0000.getParameterMap().put("TestTemperature",
151                 new AxField(new AxReferenceKey(event0000.getKey(), "TestTemperature"), testTemperature.getKey()));
152
153         AxEvent event0001 = new AxEvent(new AxArtifactKey("Event0001", "0.0.1"), "org.onap.policy.apex.sample.events");
154         event0001.setSource("Match");
155         event0001.setTarget("Establish");
156         event0001.getParameterMap().put("TestSlogan",
157                 new AxField(new AxReferenceKey(event0001.getKey(), "TestSlogan"), testSlogan.getKey()));
158         event0001.getParameterMap().put("TestMatchCase",
159                 new AxField(new AxReferenceKey(event0001.getKey(), "TestMatchCase"), testCase.getKey()));
160         event0001.getParameterMap().put("TestTimestamp",
161                 new AxField(new AxReferenceKey(event0001.getKey(), "TestTimestamp"), testTimestamp.getKey()));
162         event0001.getParameterMap().put("TestTemperature",
163                 new AxField(new AxReferenceKey(event0001.getKey(), "TestTemperature"), testTemperature.getKey()));
164         event0001.getParameterMap().put("TestMatchCaseSelected",
165                 new AxField(new AxReferenceKey(event0001.getKey(), "TestMatchCaseSelected"), testCase.getKey()));
166         event0001.getParameterMap().put("TestMatchStateTime",
167                 new AxField(new AxReferenceKey(event0001.getKey(), "TestMatchStateTime"), testTimestamp.getKey()));
168
169         AxEvent event0002 = new AxEvent(new AxArtifactKey("Event0002", "0.0.1"), "org.onap.policy.apex.sample.events");
170         event0002.setSource("Establish");
171         event0002.setTarget("Decide");
172         event0002.getParameterMap().put("TestSlogan",
173                 new AxField(new AxReferenceKey(event0002.getKey(), "TestSlogan"), testSlogan.getKey()));
174         event0002.getParameterMap().put("TestMatchCase",
175                 new AxField(new AxReferenceKey(event0002.getKey(), "TestMatchCase"), testCase.getKey()));
176         event0002.getParameterMap().put("TestTimestamp",
177                 new AxField(new AxReferenceKey(event0002.getKey(), "TestTimestamp"), testTimestamp.getKey()));
178         event0002.getParameterMap().put("TestTemperature",
179                 new AxField(new AxReferenceKey(event0002.getKey(), "TestTemperature"), testTemperature.getKey()));
180         event0002.getParameterMap().put("TestMatchCaseSelected",
181                 new AxField(new AxReferenceKey(event0002.getKey(), "TestMatchCaseSelected"), testCase.getKey()));
182         event0002.getParameterMap().put("TestMatchStateTime",
183                 new AxField(new AxReferenceKey(event0002.getKey(), "TestMatchStateTime"), testTimestamp.getKey()));
184         event0002.getParameterMap().put("TestEstablishCaseSelected",
185                 new AxField(new AxReferenceKey(event0002.getKey(), "TestEstablishCaseSelected"), testCase.getKey()));
186         event0002.getParameterMap().put("TestEstablishStateTime",
187                 new AxField(new AxReferenceKey(event0002.getKey(), "TestEstablishStateTime"), testTimestamp.getKey()));
188
189         AxEvent event0003 = new AxEvent(new AxArtifactKey("Event0003", "0.0.1"), "org.onap.policy.apex.sample.events");
190         event0003.setSource("Decide");
191         event0003.setTarget("Act");
192         event0003.getParameterMap().put("TestSlogan",
193                 new AxField(new AxReferenceKey(event0003.getKey(), "TestSlogan"), testSlogan.getKey()));
194         event0003.getParameterMap().put("TestMatchCase",
195                 new AxField(new AxReferenceKey(event0003.getKey(), "TestMatchCase"), testCase.getKey()));
196         event0003.getParameterMap().put("TestTimestamp",
197                 new AxField(new AxReferenceKey(event0003.getKey(), "TestTimestamp"), testTimestamp.getKey()));
198         event0003.getParameterMap().put("TestTemperature",
199                 new AxField(new AxReferenceKey(event0003.getKey(), "TestTemperature"), testTemperature.getKey()));
200         event0003.getParameterMap().put("TestMatchCaseSelected",
201                 new AxField(new AxReferenceKey(event0003.getKey(), "TestMatchCaseSelected"), testCase.getKey()));
202         event0003.getParameterMap().put("TestMatchStateTime",
203                 new AxField(new AxReferenceKey(event0003.getKey(), "TestMatchStateTime"), testTimestamp.getKey()));
204         event0003.getParameterMap().put("TestEstablishCaseSelected",
205                 new AxField(new AxReferenceKey(event0003.getKey(), "TestEstablishCaseSelected"), testCase.getKey()));
206         event0003.getParameterMap().put("TestEstablishStateTime",
207                 new AxField(new AxReferenceKey(event0003.getKey(), "TestEstablishStateTime"), testTimestamp.getKey()));
208         event0003.getParameterMap().put("TestDecideCaseSelected",
209                 new AxField(new AxReferenceKey(event0003.getKey(), "TestDecideCaseSelected"), testCase.getKey()));
210         event0003.getParameterMap().put("TestDecideStateTime",
211                 new AxField(new AxReferenceKey(event0003.getKey(), "TestDecideStateTime"), testTimestamp.getKey()));
212
213         AxEvent event0004 = new AxEvent(new AxArtifactKey("Event0004", "0.0.1"), "org.onap.policy.apex.sample.events");
214         event0004.setSource("Act");
215         event0004.setTarget("Outside");
216         event0004.getParameterMap().put("TestSlogan",
217                 new AxField(new AxReferenceKey(event0004.getKey(), "TestSlogan"), testSlogan.getKey()));
218         event0004.getParameterMap().put("TestMatchCase",
219                 new AxField(new AxReferenceKey(event0004.getKey(), "TestMatchCase"), testCase.getKey()));
220         event0004.getParameterMap().put("TestTimestamp",
221                 new AxField(new AxReferenceKey(event0004.getKey(), "TestTimestamp"), testTimestamp.getKey()));
222         event0004.getParameterMap().put("TestTemperature",
223                 new AxField(new AxReferenceKey(event0004.getKey(), "TestTemperature"), testTemperature.getKey()));
224         event0004.getParameterMap().put("TestMatchCaseSelected",
225                 new AxField(new AxReferenceKey(event0004.getKey(), "TestMatchCaseSelected"), testCase.getKey()));
226         event0004.getParameterMap().put("TestMatchStateTime",
227                 new AxField(new AxReferenceKey(event0004.getKey(), "TestMatchStateTime"), testTimestamp.getKey()));
228         event0004.getParameterMap().put("TestEstablishCaseSelected",
229                 new AxField(new AxReferenceKey(event0004.getKey(), "TestEstablishCaseSelected"), testCase.getKey()));
230         event0004.getParameterMap().put("TestEstablishStateTime",
231                 new AxField(new AxReferenceKey(event0004.getKey(), "TestEstablishStateTime"), testTimestamp.getKey()));
232         event0004.getParameterMap().put("TestDecideCaseSelected",
233                 new AxField(new AxReferenceKey(event0004.getKey(), "TestDecideCaseSelected"), testCase.getKey()));
234         event0004.getParameterMap().put("TestDecideStateTime",
235                 new AxField(new AxReferenceKey(event0004.getKey(), "TestDecideStateTime"), testTimestamp.getKey()));
236         event0004.getParameterMap().put("TestActCaseSelected",
237                 new AxField(new AxReferenceKey(event0004.getKey(), "TestActCaseSelected"), testCase.getKey()));
238         event0004.getParameterMap().put("TestActStateTime",
239                 new AxField(new AxReferenceKey(event0004.getKey(), "TestActStateTime"), testTimestamp.getKey()));
240
241         AxEvent event0100 = new AxEvent(new AxArtifactKey("Event0100", "0.0.1"), "org.onap.policy.apex.sample.events");
242         event0100.setSource("Outside");
243         event0100.setTarget("Match");
244         event0100.getParameterMap().put("TestSlogan",
245                 new AxField(new AxReferenceKey(event0100.getKey(), "TestSlogan"), testSlogan.getKey()));
246         event0100.getParameterMap().put("TestMatchCase",
247                 new AxField(new AxReferenceKey(event0100.getKey(), "TestMatchCase"), testCase.getKey()));
248         event0100.getParameterMap().put("TestTimestamp",
249                 new AxField(new AxReferenceKey(event0100.getKey(), "TestTimestamp"), testTimestamp.getKey()));
250         event0100.getParameterMap().put("TestTemperature",
251                 new AxField(new AxReferenceKey(event0100.getKey(), "TestTemperature"), testTemperature.getKey()));
252
253         AxEvent event0101 = new AxEvent(new AxArtifactKey("Event0101", "0.0.1"), "org.onap.policy.apex.sample.events");
254         event0101.setSource("Match");
255         event0101.setTarget("Establish");
256         event0101.getParameterMap().put("TestSlogan",
257                 new AxField(new AxReferenceKey(event0101.getKey(), "TestSlogan"), testSlogan.getKey()));
258         event0101.getParameterMap().put("TestMatchCase",
259                 new AxField(new AxReferenceKey(event0101.getKey(), "TestMatchCase"), testCase.getKey()));
260         event0101.getParameterMap().put("TestTimestamp",
261                 new AxField(new AxReferenceKey(event0101.getKey(), "TestTimestamp"), testTimestamp.getKey()));
262         event0101.getParameterMap().put("TestTemperature",
263                 new AxField(new AxReferenceKey(event0101.getKey(), "TestTemperature"), testTemperature.getKey()));
264         event0101.getParameterMap().put("TestMatchCaseSelected",
265                 new AxField(new AxReferenceKey(event0101.getKey(), "TestMatchCaseSelected"), testCase.getKey()));
266         event0101.getParameterMap().put("TestMatchStateTime",
267                 new AxField(new AxReferenceKey(event0101.getKey(), "TestMatchStateTime"), testTimestamp.getKey()));
268
269         AxEvent event0102 = new AxEvent(new AxArtifactKey("Event0102", "0.0.1"), "org.onap.policy.apex.sample.events");
270         event0102.setSource("Establish");
271         event0102.setTarget("Decide");
272         event0102.getParameterMap().put("TestSlogan",
273                 new AxField(new AxReferenceKey(event0102.getKey(), "TestSlogan"), testSlogan.getKey()));
274         event0102.getParameterMap().put("TestMatchCase",
275                 new AxField(new AxReferenceKey(event0102.getKey(), "TestMatchCase"), testCase.getKey()));
276         event0102.getParameterMap().put("TestTimestamp",
277                 new AxField(new AxReferenceKey(event0102.getKey(), "TestTimestamp"), testTimestamp.getKey()));
278         event0102.getParameterMap().put("TestTemperature",
279                 new AxField(new AxReferenceKey(event0102.getKey(), "TestTemperature"), testTemperature.getKey()));
280         event0102.getParameterMap().put("TestMatchCaseSelected",
281                 new AxField(new AxReferenceKey(event0102.getKey(), "TestMatchCaseSelected"), testCase.getKey()));
282         event0102.getParameterMap().put("TestMatchStateTime",
283                 new AxField(new AxReferenceKey(event0102.getKey(), "TestMatchStateTime"), testTimestamp.getKey()));
284         event0102.getParameterMap().put("TestEstablishCaseSelected",
285                 new AxField(new AxReferenceKey(event0102.getKey(), "TestEstablishCaseSelected"), testCase.getKey()));
286         event0102.getParameterMap().put("TestEstablishStateTime",
287                 new AxField(new AxReferenceKey(event0102.getKey(), "TestEstablishStateTime"), testTimestamp.getKey()));
288
289         AxEvent event0103 = new AxEvent(new AxArtifactKey("Event0103", "0.0.1"), "org.onap.policy.apex.sample.events");
290         event0103.setSource("Decide");
291         event0103.setTarget("Act");
292         event0103.getParameterMap().put("TestSlogan",
293                 new AxField(new AxReferenceKey(event0103.getKey(), "TestSlogan"), testSlogan.getKey()));
294         event0103.getParameterMap().put("TestMatchCase",
295                 new AxField(new AxReferenceKey(event0103.getKey(), "TestMatchCase"), testCase.getKey()));
296         event0103.getParameterMap().put("TestTimestamp",
297                 new AxField(new AxReferenceKey(event0103.getKey(), "TestTimestamp"), testTimestamp.getKey()));
298         event0103.getParameterMap().put("TestTemperature",
299                 new AxField(new AxReferenceKey(event0103.getKey(), "TestTemperature"), testTemperature.getKey()));
300         event0103.getParameterMap().put("TestMatchCaseSelected",
301                 new AxField(new AxReferenceKey(event0103.getKey(), "TestMatchCaseSelected"), testCase.getKey()));
302         event0103.getParameterMap().put("TestMatchStateTime",
303                 new AxField(new AxReferenceKey(event0103.getKey(), "TestMatchStateTime"), testTimestamp.getKey()));
304         event0103.getParameterMap().put("TestEstablishCaseSelected",
305                 new AxField(new AxReferenceKey(event0103.getKey(), "TestEstablishCaseSelected"), testCase.getKey()));
306         event0103.getParameterMap().put("TestEstablishStateTime",
307                 new AxField(new AxReferenceKey(event0103.getKey(), "TestEstablishStateTime"), testTimestamp.getKey()));
308         event0103.getParameterMap().put("TestDecideCaseSelected",
309                 new AxField(new AxReferenceKey(event0103.getKey(), "TestDecideCaseSelected"), testCase.getKey()));
310         event0103.getParameterMap().put("TestDecideStateTime",
311                 new AxField(new AxReferenceKey(event0103.getKey(), "TestDecideStateTime"), testTimestamp.getKey()));
312
313         AxEvent event0104 = new AxEvent(new AxArtifactKey("Event0104", "0.0.1"), "org.onap.policy.apex.sample.events");
314         event0104.setSource("Act");
315         event0104.setTarget("Outside");
316         event0104.getParameterMap().put("TestSlogan",
317                 new AxField(new AxReferenceKey(event0104.getKey(), "TestSlogan"), testSlogan.getKey()));
318         event0104.getParameterMap().put("TestMatchCase",
319                 new AxField(new AxReferenceKey(event0104.getKey(), "TestMatchCase"), testCase.getKey()));
320         event0104.getParameterMap().put("TestTimestamp",
321                 new AxField(new AxReferenceKey(event0104.getKey(), "TestTimestamp"), testTimestamp.getKey()));
322         event0104.getParameterMap().put("TestTemperature",
323                 new AxField(new AxReferenceKey(event0104.getKey(), "TestTemperature"), testTemperature.getKey()));
324         event0104.getParameterMap().put("TestMatchCaseSelected",
325                 new AxField(new AxReferenceKey(event0104.getKey(), "TestMatchCaseSelected"), testCase.getKey()));
326         event0104.getParameterMap().put("TestMatchStateTime",
327                 new AxField(new AxReferenceKey(event0104.getKey(), "TestMatchStateTime"), testTimestamp.getKey()));
328         event0104.getParameterMap().put("TestEstablishCaseSelected",
329                 new AxField(new AxReferenceKey(event0104.getKey(), "TestEstablishCaseSelected"), testCase.getKey()));
330         event0104.getParameterMap().put("TestEstablishStateTime",
331                 new AxField(new AxReferenceKey(event0104.getKey(), "TestEstablishStateTime"), testTimestamp.getKey()));
332         event0104.getParameterMap().put("TestDecideCaseSelected",
333                 new AxField(new AxReferenceKey(event0104.getKey(), "TestDecideCaseSelected"), testCase.getKey()));
334         event0104.getParameterMap().put("TestDecideStateTime",
335                 new AxField(new AxReferenceKey(event0104.getKey(), "TestDecideStateTime"), testTimestamp.getKey()));
336         event0104.getParameterMap().put("TestActCaseSelected",
337                 new AxField(new AxReferenceKey(event0104.getKey(), "TestActCaseSelected"), testCase.getKey()));
338         event0104.getParameterMap().put("TestActStateTime",
339                 new AxField(new AxReferenceKey(event0104.getKey(), "TestActStateTime"), testTimestamp.getKey()));
340
341         AxEvents events = new AxEvents(new AxArtifactKey("Events", "0.0.1"));
342         events.getEventMap().put(event0000.getKey(), event0000);
343         events.getEventMap().put(event0001.getKey(), event0001);
344         events.getEventMap().put(event0002.getKey(), event0002);
345         events.getEventMap().put(event0003.getKey(), event0003);
346         events.getEventMap().put(event0004.getKey(), event0004);
347         events.getEventMap().put(event0100.getKey(), event0100);
348         events.getEventMap().put(event0101.getKey(), event0101);
349         events.getEventMap().put(event0102.getKey(), event0102);
350         events.getEventMap().put(event0103.getKey(), event0103);
351         events.getEventMap().put(event0104.getKey(), event0104);
352
353         AxContextAlbum externalContextAlbum = new AxContextAlbum(new AxArtifactKey("ExternalContextAlbum", "0.0.1"),
354                 "EXTERNAL", false, testExternalContextItem.getKey());
355         AxContextAlbum globalContextAlbum = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"),
356                 "GLOBAL", true, testGlobalContextItem.getKey());
357         AxContextAlbum policy0ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy0ContextAlbum", "0.0.1"),
358                 "APPLICATION", true, testPolicyContextItem.getKey());
359         AxContextAlbum policy1ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy1ContextAlbum", "0.0.1"),
360                 "APPLICATION", true, testPolicyContextItem.getKey());
361
362         AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("Context", "0.0.1"));
363         albums.getAlbumsMap().put(externalContextAlbum.getKey(), externalContextAlbum);
364         albums.getAlbumsMap().put(globalContextAlbum.getKey(), globalContextAlbum);
365         albums.getAlbumsMap().put(policy0ContextAlbum.getKey(), policy0ContextAlbum);
366         albums.getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum);
367
368         Set<AxArtifactKey> referenceKeySet0 = new TreeSet<AxArtifactKey>();
369         referenceKeySet0.add(policy0ContextAlbum.getKey());
370         referenceKeySet0.add(policy1ContextAlbum.getKey());
371         referenceKeySet0.add(globalContextAlbum.getKey());
372         referenceKeySet0.add(externalContextAlbum.getKey());
373
374         Set<AxArtifactKey> referenceKeySet1 = new TreeSet<AxArtifactKey>();
375         referenceKeySet1.add(policy0ContextAlbum.getKey());
376         referenceKeySet1.add(globalContextAlbum.getKey());
377
378         Set<AxArtifactKey> referenceKeySet2 = new TreeSet<AxArtifactKey>();
379         referenceKeySet2.add(policy1ContextAlbum.getKey());
380         referenceKeySet2.add(globalContextAlbum.getKey());
381
382         Set<AxArtifactKey> referenceKeySet3 = new TreeSet<AxArtifactKey>();
383         referenceKeySet3.add(globalContextAlbum.getKey());
384         referenceKeySet3.add(externalContextAlbum.getKey());
385
386         List<Set<AxArtifactKey>> referenceKeySetList = new ArrayList<Set<AxArtifactKey>>();
387         referenceKeySetList.add(referenceKeySet0);
388         referenceKeySetList.add(referenceKeySet1);
389         referenceKeySetList.add(referenceKeySet2);
390         referenceKeySetList.add(referenceKeySet3);
391
392         AxTasks tasks = new AxTasks(new AxArtifactKey("Tasks", "0.0.1"));
393         tasks.getTaskMap().putAll(getTaskMap("Match", event0000.getParameterMap(), event0001.getParameterMap(),
394                 referenceKeySetList, axLogicExecutorType));
395         tasks.getTaskMap().putAll(getTaskMap("Establish", event0001.getParameterMap(), event0002.getParameterMap(),
396                 referenceKeySetList, axLogicExecutorType));
397         tasks.getTaskMap().putAll(getTaskMap("Decide", event0002.getParameterMap(), event0003.getParameterMap(),
398                 referenceKeySetList, axLogicExecutorType));
399         tasks.getTaskMap().putAll(getTaskMap("Act", event0003.getParameterMap(), event0004.getParameterMap(),
400                 referenceKeySetList, axLogicExecutorType));
401
402         Set<AxArtifactKey> matchTasks = new TreeSet<AxArtifactKey>();
403         Set<AxArtifactKey> establishTasks = new TreeSet<AxArtifactKey>();
404         Set<AxArtifactKey> decideTasks = new TreeSet<AxArtifactKey>();
405         Set<AxArtifactKey> actTasks = new TreeSet<AxArtifactKey>();
406         for (AxTask task : tasks.getTaskMap().values()) {
407             if (task.getKey().getName().contains("Match")) {
408                 matchTasks.add(task.getKey());
409             }
410             if (task.getKey().getName().contains("Establish")) {
411                 establishTasks.add(task.getKey());
412             }
413             if (task.getKey().getName().contains("Decide")) {
414                 decideTasks.add(task.getKey());
415             }
416             if (task.getKey().getName().contains("Act")) {
417                 actTasks.add(task.getKey());
418             }
419         }
420         List<Set<AxArtifactKey>> taskReferenceList = new ArrayList<Set<AxArtifactKey>>();
421         taskReferenceList.add(matchTasks);
422         taskReferenceList.add(establishTasks);
423         taskReferenceList.add(decideTasks);
424         taskReferenceList.add(actTasks);
425
426         List<AxArtifactKey> p0InEventList = new ArrayList<AxArtifactKey>();
427         p0InEventList.add(event0000.getKey());
428         p0InEventList.add(event0001.getKey());
429         p0InEventList.add(event0002.getKey());
430         p0InEventList.add(event0003.getKey());
431
432         List<AxArtifactKey> p0OutEventList = new ArrayList<AxArtifactKey>();
433         p0OutEventList.add(event0001.getKey());
434         p0OutEventList.add(event0002.getKey());
435         p0OutEventList.add(event0003.getKey());
436         p0OutEventList.add(event0004.getKey());
437
438         List<AxArtifactKey> p0defaultTaskList = new ArrayList<AxArtifactKey>();
439         p0defaultTaskList.add(tasks.get("Task_Match0").getKey());
440         p0defaultTaskList.add(tasks.get("Task_Establish2").getKey());
441         p0defaultTaskList.add(tasks.get("Task_Decide3").getKey());
442         p0defaultTaskList.add(tasks.get("Task_Act1").getKey());
443
444         List<AxArtifactKey> p1InEventList = new ArrayList<AxArtifactKey>();
445         p1InEventList.add(event0100.getKey());
446         p1InEventList.add(event0101.getKey());
447         p1InEventList.add(event0102.getKey());
448         p1InEventList.add(event0103.getKey());
449
450         List<AxArtifactKey> p1OutEventList = new ArrayList<AxArtifactKey>();
451         p1OutEventList.add(event0101.getKey());
452         p1OutEventList.add(event0102.getKey());
453         p1OutEventList.add(event0103.getKey());
454         p1OutEventList.add(event0104.getKey());
455
456         List<AxArtifactKey> p1defaultTaskList = new ArrayList<AxArtifactKey>();
457         p1defaultTaskList.add(tasks.get("Task_Match3").getKey());
458         p1defaultTaskList.add(tasks.get("Task_Establish1").getKey());
459         p1defaultTaskList.add(tasks.get("Task_Decide3").getKey());
460         p1defaultTaskList.add(tasks.get("Task_Act0").getKey());
461
462         Set<AxArtifactKey> p0ReferenceKeySet0 = new TreeSet<AxArtifactKey>();
463         p0ReferenceKeySet0.add(policy0ContextAlbum.getKey());
464         p0ReferenceKeySet0.add(globalContextAlbum.getKey());
465
466         Set<AxArtifactKey> p0ReferenceKeySet1 = new TreeSet<AxArtifactKey>();
467         p0ReferenceKeySet1.add(policy1ContextAlbum.getKey());
468         p0ReferenceKeySet1.add(globalContextAlbum.getKey());
469         p0ReferenceKeySet1.add(externalContextAlbum.getKey());
470
471         Set<AxArtifactKey> p0ReferenceKeySet2 = new TreeSet<AxArtifactKey>();
472         p0ReferenceKeySet2.add(policy0ContextAlbum.getKey());
473         p0ReferenceKeySet2.add(globalContextAlbum.getKey());
474         p0ReferenceKeySet2.add(externalContextAlbum.getKey());
475
476         Set<AxArtifactKey> p0ReferenceKeySet3 = new TreeSet<AxArtifactKey>();
477         p0ReferenceKeySet3.add(globalContextAlbum.getKey());
478
479         List<Set<AxArtifactKey>> p0ReferenceKeySetList = new ArrayList<Set<AxArtifactKey>>();
480         p0ReferenceKeySetList.add(p0ReferenceKeySet0);
481         p0ReferenceKeySetList.add(p0ReferenceKeySet1);
482         p0ReferenceKeySetList.add(p0ReferenceKeySet2);
483         p0ReferenceKeySetList.add(p0ReferenceKeySet3);
484
485         AxPolicy policy0 = new AxPolicy(new AxArtifactKey("Policy0", "0.0.1"));
486         policy0.setTemplate("MEDA");
487         policy0.setStateMap(getStateMap(policy0.getKey(), p0InEventList, p0OutEventList, p0ReferenceKeySetList,
488                 axLogicExecutorType, p0defaultTaskList, taskReferenceList));
489         policy0.setFirstState(policy0.getStateMap().get("Match").getKey().getLocalName());
490
491         Set<AxArtifactKey> p1ReferenceKeySet0 = new TreeSet<AxArtifactKey>();
492         p1ReferenceKeySet0.add(policy1ContextAlbum.getKey());
493         p1ReferenceKeySet0.add(globalContextAlbum.getKey());
494         p1ReferenceKeySet0.add(externalContextAlbum.getKey());
495
496         Set<AxArtifactKey> p1ReferenceKeySet1 = new TreeSet<AxArtifactKey>();
497         p1ReferenceKeySet1.add(policy1ContextAlbum.getKey());
498         p1ReferenceKeySet1.add(globalContextAlbum.getKey());
499         p1ReferenceKeySet1.add(externalContextAlbum.getKey());
500
501         Set<AxArtifactKey> p1ReferenceKeySet2 = new TreeSet<AxArtifactKey>();
502         p1ReferenceKeySet2.add(policy1ContextAlbum.getKey());
503         p1ReferenceKeySet2.add(globalContextAlbum.getKey());
504         p1ReferenceKeySet2.add(externalContextAlbum.getKey());
505
506         Set<AxArtifactKey> p1ReferenceKeySet3 = new TreeSet<AxArtifactKey>();
507         p1ReferenceKeySet3.add(globalContextAlbum.getKey());
508
509         List<Set<AxArtifactKey>> p1ReferenceKeySetList = new ArrayList<Set<AxArtifactKey>>();
510         p1ReferenceKeySetList.add(p1ReferenceKeySet0);
511         p1ReferenceKeySetList.add(p1ReferenceKeySet1);
512         p1ReferenceKeySetList.add(p1ReferenceKeySet2);
513         p1ReferenceKeySetList.add(p1ReferenceKeySet3);
514
515         AxPolicy policy1 = new AxPolicy(new AxArtifactKey("Policy1", "0.0.1"));
516         policy1.setTemplate("MEDA");
517         policy1.setStateMap(getStateMap(policy1.getKey(), p1InEventList, p1OutEventList, p1ReferenceKeySetList,
518                 axLogicExecutorType, p1defaultTaskList, taskReferenceList));
519         policy1.setFirstState(policy1.getStateMap().get("Match").getKey().getLocalName());
520
521         AxPolicies policies = new AxPolicies(new AxArtifactKey("Policies", "0.0.1"));
522         policies.getPolicyMap().put(policy0.getKey(), policy0);
523         policies.getPolicyMap().put(policy1.getKey(), policy1);
524
525         AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInformation", "0.0.1"));
526         AxPolicyModel policyModel =
527                 new AxPolicyModel(new AxArtifactKey("SamplePolicyModel" + axLogicExecutorType, "0.0.1"));
528         policyModel.setKeyInformation(keyInformation);
529         policyModel.setPolicies(policies);
530         policyModel.setEvents(events);
531         policyModel.setTasks(tasks);
532         policyModel.setAlbums(albums);
533         policyModel.setSchemas(axContextSchemas);
534         policyModel.getKeyInformation().generateKeyInfo(policyModel);
535
536         AxValidationResult result = policyModel.validate(new AxValidationResult());
537         if (!result.getValidationResult().equals(AxValidationResult.ValidationResult.VALID)) {
538             throw new ApexRuntimeException("model " + policyModel.getId() + " is not valid" + result);
539         }
540         return policyModel;
541     }
542
543     /**
544      * Gets the state map.
545      *
546      * @param policyKey the policy key
547      * @param inEventKeyList the in event key list
548      * @param outEventKeyList the out event key list
549      * @param referenceKeySetList the reference key set list
550      * @param axLogicExecutorType the ax logic executor type
551      * @param defaultTaskList the default task list
552      * @param taskKeySetList the task key set list
553      * @return the state map
554      */
555     private Map<String, AxState> getStateMap(final AxArtifactKey policyKey, final List<AxArtifactKey> inEventKeyList,
556             final List<AxArtifactKey> outEventKeyList, final List<Set<AxArtifactKey>> referenceKeySetList,
557             final String axLogicExecutorType, final List<AxArtifactKey> defaultTaskList,
558             final List<Set<AxArtifactKey>> taskKeySetList) {
559         AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(this.getClass().getPackage().getName())
560                 .setDefaultLogic("DefaultState_Logic");
561
562         AxState actState = new AxState(new AxReferenceKey(policyKey, "Act"));
563         actState.setTrigger(inEventKeyList.get(3));
564         AxStateOutput act2Out =
565                 new AxStateOutput(actState.getKey(), AxReferenceKey.getNullKey(), outEventKeyList.get(3));
566         actState.getStateOutputs().put(act2Out.getKey().getLocalName(), act2Out);
567         actState.setContextAlbumReferences(referenceKeySetList.get(3));
568         actState.setTaskSelectionLogic(
569                 new AxTaskSelectionLogic(actState.getKey(), "TaskSelectionLigic", axLogicExecutorType, logicReader));
570         actState.setDefaultTask(defaultTaskList.get(3));
571         for (AxArtifactKey taskKey : taskKeySetList.get(3)) {
572             actState.getTaskReferences().put(taskKey, new AxStateTaskReference(actState.getKey(), taskKey,
573                     AxStateTaskOutputType.DIRECT, act2Out.getKey()));
574         }
575
576         AxState decideState = new AxState(new AxReferenceKey(policyKey, "Decide"));
577         decideState.setTrigger(inEventKeyList.get(2));
578         AxStateOutput decide2Act = new AxStateOutput(decideState.getKey(), actState.getKey(), outEventKeyList.get(2));
579         decideState.getStateOutputs().put(decide2Act.getKey().getLocalName(), decide2Act);
580         decideState.setContextAlbumReferences(referenceKeySetList.get(2));
581         decideState.setTaskSelectionLogic(
582                 new AxTaskSelectionLogic(decideState.getKey(), "TaskSelectionLigic", axLogicExecutorType, logicReader));
583         decideState.setDefaultTask(defaultTaskList.get(2));
584         for (AxArtifactKey taskKey : taskKeySetList.get(2)) {
585             decideState.getTaskReferences().put(taskKey, new AxStateTaskReference(decideState.getKey(), taskKey,
586                     AxStateTaskOutputType.DIRECT, decide2Act.getKey()));
587         }
588
589         AxState establishState = new AxState(new AxReferenceKey(policyKey, "Establish"));
590         establishState.setTrigger(inEventKeyList.get(1));
591         AxStateOutput establish2Decide =
592                 new AxStateOutput(establishState.getKey(), decideState.getKey(), outEventKeyList.get(1));
593         establishState.getStateOutputs().put(establish2Decide.getKey().getLocalName(), establish2Decide);
594         establishState.setContextAlbumReferences(referenceKeySetList.get(1));
595         establishState.setTaskSelectionLogic(new AxTaskSelectionLogic(establishState.getKey(), "TaskSelectionLigic",
596                 axLogicExecutorType, logicReader));
597         establishState.setDefaultTask(defaultTaskList.get(1));
598         for (AxArtifactKey taskKey : taskKeySetList.get(1)) {
599             establishState.getTaskReferences().put(taskKey, new AxStateTaskReference(establishState.getKey(), taskKey,
600                     AxStateTaskOutputType.DIRECT, establish2Decide.getKey()));
601         }
602
603         AxState matchState = new AxState(new AxReferenceKey(policyKey, "Match"));
604         matchState.setTrigger(inEventKeyList.get(0));
605         AxStateOutput match2Establish =
606                 new AxStateOutput(matchState.getKey(), establishState.getKey(), outEventKeyList.get(0));
607         matchState.getStateOutputs().put(match2Establish.getKey().getLocalName(), match2Establish);
608         matchState.setContextAlbumReferences(referenceKeySetList.get(0));
609         matchState.setTaskSelectionLogic(
610                 new AxTaskSelectionLogic(matchState.getKey(), "TaskSelectionLigic", axLogicExecutorType, logicReader));
611         matchState.setDefaultTask(defaultTaskList.get(0));
612         for (AxArtifactKey taskKey : taskKeySetList.get(0)) {
613             matchState.getTaskReferences().put(taskKey, new AxStateTaskReference(matchState.getKey(), taskKey,
614                     AxStateTaskOutputType.DIRECT, match2Establish.getKey()));
615         }
616
617         Map<String, AxState> stateMap = new TreeMap<String, AxState>();
618         stateMap.put(matchState.getKey().getLocalName(), matchState);
619         stateMap.put(establishState.getKey().getLocalName(), establishState);
620         stateMap.put(decideState.getKey().getLocalName(), decideState);
621         stateMap.put(actState.getKey().getLocalName(), actState);
622
623         return stateMap;
624     }
625     // CHECKSTYLE:ON: checkstyle:maximumMethodLength
626
627     /**
628      * Gets the task map.
629      *
630      * @param state the state
631      * @param inputFields the input fields
632      * @param outputFields the output fields
633      * @param referenceKeySetList the reference key set list
634      * @param axLogicExecutorType the ax logic executor type
635      * @return the task map
636      */
637     private Map<AxArtifactKey, AxTask> getTaskMap(final String state, final Map<String, AxField> inputFields,
638             final Map<String, AxField> outputFields, final List<Set<AxArtifactKey>> referenceKeySetList,
639             final String axLogicExecutorType) {
640         AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(this.getClass().getPackage().getName())
641                 .setDefaultLogic("DefaultTask_Logic");
642
643         AxTask testTask0 = new AxTask(new AxArtifactKey("Task_" + state + "0", "0.0.1"));
644         testTask0.duplicateInputFields(inputFields);
645         testTask0.duplicateOutputFields(outputFields);
646         AxTaskParameter parameter00 =
647                 new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), "Parameter0"), "DefaultValue0");
648         AxTaskParameter parameter01 =
649                 new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), "Parameter1"), "DefaultValue1");
650         AxTaskParameter parameter02 =
651                 new AxTaskParameter(new AxReferenceKey(testTask0.getKey(), "Parameter2"), "DefaultValue2");
652         testTask0.getTaskParameters().put(parameter00.getKey().getLocalName(), parameter00);
653         testTask0.getTaskParameters().put(parameter01.getKey().getLocalName(), parameter01);
654         testTask0.getTaskParameters().put(parameter02.getKey().getLocalName(), parameter02);
655         testTask0.setContextAlbumReferences(referenceKeySetList.get(0));
656         testTask0.setTaskLogic(getTaskLogic(testTask0, logicReader, axLogicExecutorType, state, "2"));
657
658         AxTask testTask1 = new AxTask(new AxArtifactKey("Task_" + state + "1", "0.0.1"));
659         testTask1.duplicateInputFields(inputFields);
660         testTask1.duplicateOutputFields(outputFields);
661         AxTaskParameter parameter10 =
662                 new AxTaskParameter(new AxReferenceKey(testTask1.getKey(), "Parameter0"), "DefaultValue0");
663         AxTaskParameter parameter11 =
664                 new AxTaskParameter(new AxReferenceKey(testTask1.getKey(), "Parameter1"), "DefaultValue1");
665         testTask1.getTaskParameters().put(parameter10.getKey().getLocalName(), parameter10);
666         testTask1.getTaskParameters().put(parameter11.getKey().getLocalName(), parameter11);
667         testTask1.setContextAlbumReferences(referenceKeySetList.get(1));
668         testTask1.setTaskLogic(getTaskLogic(testTask1, logicReader, axLogicExecutorType, state, "3"));
669
670         AxTask testTask2 = new AxTask(new AxArtifactKey("Task_" + state + "2", "0.0.1"));
671         testTask2.duplicateInputFields(inputFields);
672         testTask2.duplicateOutputFields(outputFields);
673         AxTaskParameter parameter20 =
674                 new AxTaskParameter(new AxReferenceKey(testTask2.getKey(), "Parameter0"), "DefaultValue0");
675         testTask2.getTaskParameters().put(parameter20.getKey().getLocalName(), parameter20);
676         testTask2.setContextAlbumReferences(referenceKeySetList.get(2));
677         testTask2.setTaskLogic(getTaskLogic(testTask2, logicReader, axLogicExecutorType, state, "0"));
678
679         AxTask testTask3 = new AxTask(new AxArtifactKey("Task_" + state + "3", "0.0.1"));
680         testTask3.duplicateInputFields(inputFields);
681         testTask3.duplicateOutputFields(outputFields);
682         AxTaskParameter parameter30 =
683                 new AxTaskParameter(new AxReferenceKey(testTask3.getKey(), "Parameter0"), "DefaultValue0");
684         testTask3.getTaskParameters().put(parameter30.getKey().getLocalName(), parameter30);
685         testTask3.setContextAlbumReferences(referenceKeySetList.get(THIRD_ENTRY));
686         testTask3.setTaskLogic(getTaskLogic(testTask3, logicReader, axLogicExecutorType, state, "1"));
687
688         Map<AxArtifactKey, AxTask> taskMap = new TreeMap<AxArtifactKey, AxTask>();
689         taskMap.put(testTask0.getKey(), testTask0);
690         taskMap.put(testTask1.getKey(), testTask1);
691         taskMap.put(testTask2.getKey(), testTask2);
692         taskMap.put(testTask3.getKey(), testTask3);
693
694         return taskMap;
695     }
696
697     /**
698      * Gets the task logic.
699      *
700      * @param task the task
701      * @param logicReader the logic reader
702      * @param logicFlavour the logic flavour
703      * @param stateName the state name
704      * @param caseToUse the case to use
705      * @return the task logic
706      */
707     private AxTaskLogic getTaskLogic(final AxTask task, final AxLogicReader logicReader, final String logicFlavour,
708             final String stateName, final String caseToUse) {
709         AxTaskLogic axLogic =
710                 new AxTaskLogic(new AxReferenceKey(task.getKey(), "_TaskLogic"), logicFlavour, logicReader);
711
712         axLogic.setLogic(axLogic.getLogic().replaceAll("<STATE_NAME>", stateName)
713                 .replaceAll("<TASK_NAME>", task.getKey().getName()).replaceAll("<RANDOM_BYTE_VALUE>", caseToUse));
714
715         return axLogic;
716     }
717 }