b2c49b6b4be3899ebfe0fc760ffcf18daef82c0a
[policy/apex-pdp.git] / model / policy-model / src / test / java / org / onap / policy / apex / model / policymodel / handling / SupportApexPolicyModelCreator.java
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.model.policymodel.handling;
22
23 import java.util.UUID;
24
25 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
26 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
27 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
28 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
29 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
30 import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
31 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
32 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
33 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
34 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
35 import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
36 import org.onap.policy.apex.model.eventmodel.concepts.AxEvents;
37 import org.onap.policy.apex.model.eventmodel.concepts.AxField;
38 import org.onap.policy.apex.model.eventmodel.concepts.AxInputField;
39 import org.onap.policy.apex.model.eventmodel.concepts.AxOutputField;
40 import org.onap.policy.apex.model.policymodel.concepts.AxPolicies;
41 import org.onap.policy.apex.model.policymodel.concepts.AxPolicy;
42 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
43 import org.onap.policy.apex.model.policymodel.concepts.AxState;
44 import org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic;
45 import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput;
46 import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType;
47 import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference;
48 import org.onap.policy.apex.model.policymodel.concepts.AxTask;
49 import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic;
50 import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter;
51 import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic;
52 import org.onap.policy.apex.model.policymodel.concepts.AxTasks;
53
54 /**
55  * Model creator for model tests.
56  * 
57  * @author Liam Fallon (liam.fallon@ericsson.com)
58  */
59 public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPolicyModel> {
60
61     @Override
62     public AxPolicyModel getModel() {
63         final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("eventContextItem0", "0.0.1"), "Java",
64                         "java.lang.String");
65         final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("eventContextItem1", "0.0.1"), "Java",
66                         "java.lang.Long");
67         final AxContextSchema schema2 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
68                         "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000");
69         final AxContextSchema schema3 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
70                         "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A");
71
72         final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1"));
73         schemas.getSchemasMap().put(schema0.getKey(), schema0);
74         schemas.getSchemasMap().put(schema1.getKey(), schema1);
75         schemas.getSchemasMap().put(schema2.getKey(), schema2);
76         schemas.getSchemasMap().put(schema3.getKey(), schema3);
77
78         final AxContextAlbum album0 = new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION",
79                         true, schema3.getKey());
80         final AxContextAlbum album1 = new AxContextAlbum(new AxArtifactKey("contextAlbum1", "0.0.1"), "GLOBAL", false,
81                         schema2.getKey());
82
83         final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
84         albums.getAlbumsMap().put(album0.getKey(), album0);
85         albums.getAlbumsMap().put(album1.getKey(), album1);
86
87         final AxEvent inEvent = new AxEvent(new AxArtifactKey("inEvent", "0.0.1"),
88                         "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
89         inEvent.getParameterMap().put("IEPAR0",
90                         new AxField(new AxReferenceKey(inEvent.getKey(), "IEPAR0"), schema0.getKey()));
91         inEvent.getParameterMap().put("IEPAR1",
92                         new AxField(new AxReferenceKey(inEvent.getKey(), "IEPAR1"), schema1.getKey()));
93
94         final AxEvent outEvent0 = new AxEvent(new AxArtifactKey("outEvent0", "0.0.1"),
95                         "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
96         outEvent0.getParameterMap().put("OE0PAR0",
97                         new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PAR0"), schema0.getKey()));
98         outEvent0.getParameterMap().put("OE0PAR1",
99                         new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PAR1"), schema1.getKey()));
100         outEvent0.getParameterMap().put("OE1PAR0",
101                         new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PAR0"), schema0.getKey()));
102         outEvent0.getParameterMap().put("OE1PAR1",
103                         new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PAR1"), schema1.getKey()));
104
105         final AxEvent outEvent1 = new AxEvent(new AxArtifactKey("outEvent1", "0.0.1"),
106                         "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
107         outEvent1.getParameterMap().put("OE1PAR0",
108                         new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PAR0"), schema0.getKey()));
109         outEvent1.getParameterMap().put("OE1PAR1",
110                         new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PAR1"), schema1.getKey()));
111
112         final AxEvents events = new AxEvents(new AxArtifactKey("events", "0.0.1"));
113         events.getEventMap().put(inEvent.getKey(), inEvent);
114         events.getEventMap().put(outEvent0.getKey(), outEvent0);
115         events.getEventMap().put(outEvent1.getKey(), outEvent1);
116
117         final AxTask task = new AxTask(new AxArtifactKey("task", "0.0.1"));
118
119         for (final AxField field : inEvent.getFields()) {
120             final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
121                             "inputFields", field.getKey().getLocalName());
122             final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
123             task.getInputFields().put(inputField.getKey().getLocalName(), inputField);
124         }
125
126         for (final AxField field : outEvent0.getFields()) {
127             final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
128                             "outputFields", field.getKey().getLocalName());
129             final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
130             task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
131         }
132
133         for (final AxField field : outEvent1.getFields()) {
134             final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
135                             "outputFields", field.getKey().getLocalName());
136             final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
137             task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
138         }
139
140         final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter0"),
141                         "Task parameter 0 value");
142         final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameter1"),
143                         "Task parameter 1 value");
144
145         task.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0);
146         task.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1);
147         task.getContextAlbumReferences().add(album0.getKey());
148         task.getContextAlbumReferences().add(album1.getKey());
149
150         final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(task.getKey(), "taskLogic"), "MVEL",
151                         "Some task logic");
152         task.setTaskLogic(taskLogic);
153
154         final AxTasks tasks = new AxTasks(new AxArtifactKey("tasks", "0.0.1"));
155         tasks.getTaskMap().put(task.getKey(), task);
156
157         final AxPolicy policy = new AxPolicy(new AxArtifactKey("policy", "0.0.1"));
158         policy.setTemplate("FREEFORM");
159
160         final AxState state = new AxState(new AxReferenceKey(policy.getKey(), "state"));
161         final AxTaskSelectionLogic taskSelectionLogic = new AxTaskSelectionLogic(
162                         new AxReferenceKey(state.getKey(), "taskSelectionLogic"), "MVEL", "Some TS logic ");
163
164         state.setTrigger(inEvent.getKey());
165         state.getContextAlbumReferences().add(album0.getKey());
166         state.getContextAlbumReferences().add(album1.getKey());
167         state.setTaskSelectionLogic(taskSelectionLogic);
168         state.setDefaultTask(task.getKey());
169
170         final AxStateOutput stateOutput0 = new AxStateOutput(new AxReferenceKey(state.getKey(), "stateOutput0"),
171                         outEvent0.getKey(), AxReferenceKey.getNullKey());
172         state.getStateOutputs().put(stateOutput0.getKey().getLocalName(), stateOutput0);
173
174         final AxStateTaskReference stateTaskReference = new AxStateTaskReference(
175                         new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.DIRECT,
176                         stateOutput0.getKey());
177
178         state.getTaskReferences().put(task.getKey(), stateTaskReference);
179
180         policy.getStateMap().put(state.getKey().getLocalName(), state);
181         policy.setFirstState(state.getKey().getLocalName());
182
183         final AxPolicies policies = new AxPolicies(new AxArtifactKey("policies", "0.0.1"));
184         policies.getPolicyMap().put(policy.getKey(), policy);
185
186         final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
187         final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("PolicyModel", "0.0.1"));
188         policyModel.setKeyInformation(keyInformation);
189         policyModel.setSchemas(schemas);
190         policyModel.setAlbums(albums);
191         policyModel.setEvents(events);
192         policyModel.setTasks(tasks);
193         policyModel.setPolicies(policies);
194         policyModel.getKeyInformation().generateKeyInfo(policyModel);
195
196         int uuidIncrementer = 0;
197         for (final AxKeyInfo keyInfo : policyModel.getKeyInformation().getKeyInfoMap().values()) {
198             final String uuidString = String.format("ce9168c-e6df-414f-9646-6da464b6e%03d", uuidIncrementer++);
199             keyInfo.setUuid(UUID.fromString(uuidString));
200         }
201
202         final AxValidationResult result = new AxValidationResult();
203         policyModel.validate(result);
204
205         return policyModel;
206     }
207
208     /**
209      * Gets another policy model.
210      * 
211      * @return the model
212      */
213     public AxPolicyModel getAnotherModel() {
214         final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("eventContextItemA0", "0.0.1"), "Java",
215                         "java.lang.String");
216         final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("eventContextItemA1", "0.0.1"), "Java",
217                         "java.lang.Long");
218         final AxContextSchema schema2 = new AxContextSchema(new AxArtifactKey("StringTypeA", "0.0.1"), "Java",
219                         "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000");
220         final AxContextSchema schema3 = new AxContextSchema(new AxArtifactKey("MapTypeA", "0.0.1"), "Java",
221                         "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A");
222
223         final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemasA", "0.0.1"));
224         schemas.getSchemasMap().put(schema0.getKey(), schema0);
225         schemas.getSchemasMap().put(schema1.getKey(), schema1);
226         schemas.getSchemasMap().put(schema2.getKey(), schema2);
227         schemas.getSchemasMap().put(schema3.getKey(), schema3);
228
229         final AxContextAlbum album0 = new AxContextAlbum(new AxArtifactKey("contextAlbumA0", "0.0.1"), "APPLICATION",
230                         true, schema3.getKey());
231         final AxContextAlbum album1 = new AxContextAlbum(new AxArtifactKey("contextAlbumA1", "0.0.1"), "GLOBAL", false,
232                         schema2.getKey());
233
234         final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("contextA", "0.0.1"));
235         albums.getAlbumsMap().put(album0.getKey(), album0);
236         albums.getAlbumsMap().put(album1.getKey(), album1);
237
238         final AxEvent inEvent = new AxEvent(new AxArtifactKey("inEventA", "0.0.1"),
239                         "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
240         inEvent.getParameterMap().put("IEPARA0",
241                         new AxField(new AxReferenceKey(inEvent.getKey(), "IEPARA0"), schema0.getKey()));
242         inEvent.getParameterMap().put("IEPARA1",
243                         new AxField(new AxReferenceKey(inEvent.getKey(), "IEPARA1"), schema1.getKey()));
244
245         final AxEvent outEvent0 = new AxEvent(new AxArtifactKey("outEventA0", "0.0.1"),
246                         "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
247         outEvent0.getParameterMap().put("OE0PARA0",
248                         new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PARA0"), schema0.getKey()));
249         outEvent0.getParameterMap().put("OE0PARA1",
250                         new AxField(new AxReferenceKey(outEvent0.getKey(), "OE0PARA1"), schema1.getKey()));
251         outEvent0.getParameterMap().put("OE1PARA0",
252                         new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PARA0"), schema0.getKey()));
253         outEvent0.getParameterMap().put("OE1PARA1",
254                         new AxField(new AxReferenceKey(outEvent0.getKey(), "OE1PARA1"), schema1.getKey()));
255
256         final AxEvent outEvent1 = new AxEvent(new AxArtifactKey("outEventA1", "0.0.1"),
257                         "org.onap.policy.apex.model.policymodel.events", "Source", "Target");
258         outEvent1.getParameterMap().put("OE1PARA0",
259                         new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PARA0"), schema0.getKey()));
260         outEvent1.getParameterMap().put("OE1PARA1",
261                         new AxField(new AxReferenceKey(outEvent1.getKey(), "OE1PARA1"), schema1.getKey()));
262
263         final AxEvents events = new AxEvents(new AxArtifactKey("eventsA", "0.0.1"));
264         events.getEventMap().put(inEvent.getKey(), inEvent);
265         events.getEventMap().put(outEvent0.getKey(), outEvent0);
266         events.getEventMap().put(outEvent1.getKey(), outEvent1);
267
268         final AxTask task = new AxTask(new AxArtifactKey("taskA", "0.0.1"));
269
270         for (final AxField field : inEvent.getFields()) {
271             final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
272                             "inputFieldsA", field.getKey().getLocalName());
273             final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
274             task.getInputFields().put(inputField.getKey().getLocalName(), inputField);
275         }
276
277         for (final AxField field : outEvent0.getFields()) {
278             final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
279                             "outputFieldsA", field.getKey().getLocalName());
280             final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
281             task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
282         }
283
284         for (final AxField field : outEvent1.getFields()) {
285             final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
286                             "outputFieldsA", field.getKey().getLocalName());
287             final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
288             task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
289         }
290
291         final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA0"),
292                         "Task parameter 0 value");
293         final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(task.getKey(), "taskParameterA1"),
294                         "Task parameter 1 value");
295
296         task.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0);
297         task.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1);
298         task.getContextAlbumReferences().add(album0.getKey());
299         task.getContextAlbumReferences().add(album1.getKey());
300
301         final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(task.getKey(), "taskLogicA"), "MVEL",
302                         "Some task logic");
303         task.setTaskLogic(taskLogic);
304
305         final AxTasks tasks = new AxTasks(new AxArtifactKey("tasksA", "0.0.1"));
306         tasks.getTaskMap().put(task.getKey(), task);
307
308         final AxPolicy policy = new AxPolicy(new AxArtifactKey("policyA", "0.0.1"));
309         policy.setTemplate("FREEFORM");
310
311         final AxState state = new AxState(new AxReferenceKey(policy.getKey(), "stateA"));
312         final AxTaskSelectionLogic taskSelectionLogic = new AxTaskSelectionLogic(
313                         new AxReferenceKey(state.getKey(), "taskSelectionLogicA"), "MVEL", "Some TS logic ");
314
315         state.setTrigger(inEvent.getKey());
316         state.getContextAlbumReferences().add(album0.getKey());
317         state.getContextAlbumReferences().add(album1.getKey());
318         state.setTaskSelectionLogic(taskSelectionLogic);
319         state.setDefaultTask(task.getKey());
320
321         final AxStateOutput stateOutput0 = new AxStateOutput(new AxReferenceKey(state.getKey(), "stateOutputA0"),
322                         outEvent0.getKey(), AxReferenceKey.getNullKey());
323         state.getStateOutputs().put(stateOutput0.getKey().getLocalName(), stateOutput0);
324
325         final AxStateTaskReference stateTaskReference = new AxStateTaskReference(
326                         new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.DIRECT,
327                         stateOutput0.getKey());
328
329         state.getTaskReferences().put(task.getKey(), stateTaskReference);
330
331         policy.getStateMap().put(state.getKey().getLocalName(), state);
332         policy.setFirstState(state.getKey().getLocalName());
333
334         final AxPolicies policies = new AxPolicies(new AxArtifactKey("policiesA", "0.0.1"));
335         policies.getPolicyMap().put(policy.getKey(), policy);
336
337         final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKeyA", "0.0.1"));
338         final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("PolicyModelA", "0.0.1"));
339         policyModel.setKeyInformation(keyInformation);
340         policyModel.setSchemas(schemas);
341         policyModel.setAlbums(albums);
342         policyModel.setEvents(events);
343         policyModel.setTasks(tasks);
344         policyModel.setPolicies(policies);
345         policyModel.getKeyInformation().generateKeyInfo(policyModel);
346
347         int uuidIncrementer = 0;
348         for (final AxKeyInfo keyInfo : policyModel.getKeyInformation().getKeyInfoMap().values()) {
349             final String uuidString = String.format("ce9168c-e6df-414f-9646-6da464b6e%03d", uuidIncrementer++);
350             keyInfo.setUuid(UUID.fromString(uuidString));
351         }
352
353         final AxValidationResult result = new AxValidationResult();
354         policyModel.validate(result);
355
356         return policyModel;
357     }
358
359     @Override
360     public AxPolicyModel getMalstructuredModel() {
361         final AxPolicyModel policyModel = new AxPolicyModel(new AxArtifactKey("policyModel", "0.0.1"));
362         return policyModel;
363     }
364
365     @Override
366     public AxPolicyModel getObservationModel() {
367         final AxPolicyModel policyModel = getModel();
368
369         final AxState state = policyModel.getPolicies().get("policy").getStateMap().get("state");
370         final AxTask task = policyModel.getTasks().get("task");
371
372         final AxStateFinalizerLogic stateFinalizerLogic = new AxStateFinalizerLogic(
373                         new AxReferenceKey(state.getKey(), "SFL"), "MVEL", "Some SF logic ");
374         state.getStateFinalizerLogicMap().put(stateFinalizerLogic.getKey().getLocalName(), stateFinalizerLogic);
375         final AxStateTaskReference stateTaskReference = new AxStateTaskReference(
376                         new AxReferenceKey(state.getKey(), task.getKey().getName()), AxStateTaskOutputType.LOGIC,
377                         stateFinalizerLogic.getKey());
378
379         state.getTaskReferences().put(task.getKey(), stateTaskReference);
380
381         return policyModel;
382     }
383
384     @Override
385     public AxPolicyModel getWarningModel() {
386         final AxPolicyModel policyModel = getModel();
387
388         final AxState anotherState = new AxState(
389                         new AxReferenceKey(new AxArtifactKey("policy", "0.0.1"), "anotherState"));
390
391         final AxEvent inEvent = policyModel.getEvents().getEventMap().get(new AxArtifactKey("inEvent", "0.0.1"));
392         final AxEvent outEvent0 = policyModel.getEvents().getEventMap().get(new AxArtifactKey("outEvent0", "0.0.1"));
393
394         final AxTask anotherTask = new AxTask(new AxArtifactKey("anotherTask", "0.0.1"));
395
396         for (final AxField field : inEvent.getFields()) {
397             final AxReferenceKey fieldkey = new AxReferenceKey(anotherTask.getKey().getName(),
398                             anotherTask.getKey().getVersion(), "inputFields", field.getKey().getLocalName());
399             final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
400             anotherTask.getInputFields().put(inputField.getKey().getLocalName(), inputField);
401         }
402
403         for (final AxField field : outEvent0.getFields()) {
404             final AxReferenceKey fieldkey = new AxReferenceKey(anotherTask.getKey().getName(),
405                             anotherTask.getKey().getVersion(), "outputFields", field.getKey().getLocalName());
406             final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
407             anotherTask.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
408         }
409
410         final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter0"),
411                         "Task parameter 0 value");
412         final AxTaskParameter taskPar1 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter1"),
413                         "Task parameter 1 value");
414
415         anotherTask.getTaskParameters().put(taskPar0.getKey().getLocalName(), taskPar0);
416         anotherTask.getTaskParameters().put(taskPar1.getKey().getLocalName(), taskPar1);
417
418         final AxTaskLogic taskLogic = new AxTaskLogic(new AxReferenceKey(anotherTask.getKey(), "taskLogic"), "MVEL",
419                         "Some task logic");
420         anotherTask.setTaskLogic(taskLogic);
421         policyModel.getTasks().getTaskMap().put(anotherTask.getKey(), anotherTask);
422
423         final AxStateOutput anotherStateOutput0 = new AxStateOutput(
424                         new AxReferenceKey(anotherState.getKey(), "stateOutput0"), outEvent0.getKey(),
425                         AxReferenceKey.getNullKey());
426         anotherState.setTrigger(inEvent.getKey());
427         anotherState.getStateOutputs().put(anotherStateOutput0.getKey().getLocalName(), anotherStateOutput0);
428         anotherState.setDefaultTask(anotherTask.getKey());
429         final AxStateTaskReference anotherStateTaskReference = new AxStateTaskReference(
430                         new AxReferenceKey(anotherState.getKey(), anotherTask.getKey().getName()),
431                         AxStateTaskOutputType.DIRECT, anotherStateOutput0.getKey());
432         anotherState.getTaskReferences().put(anotherTask.getKey(), anotherStateTaskReference);
433
434         policyModel.getPolicies().getPolicyMap().get(new AxArtifactKey("policy", "0.0.1")).getStateMap()
435                         .put(anotherState.getKey().getLocalName(), anotherState);
436
437         policyModel.getKeyInformation().generateKeyInfo(policyModel);
438
439         return policyModel;
440     }
441
442     @Override
443     public AxPolicyModel getInvalidModel() {
444         final AxPolicyModel policyModel = getModel();
445
446         policyModel.getAlbums().get(new AxArtifactKey("contextAlbum0", "0.0.1")).setScope("UNDEFINED");
447         policyModel.getAlbums().get(new AxArtifactKey("contextAlbum1", "0.0.1")).setScope("UNDEFINED");
448
449         final AxEvent outEvent0 = policyModel.getEvents().get("outEvent0");
450         outEvent0.getParameterMap().remove("OE1PAR0");
451         outEvent0.getParameterMap().remove("OE1PAR1");
452
453         return policyModel;
454     }
455 }