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