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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.model.enginemodel.handling;
23 import java.util.UUID;
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.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.enginemodel.concepts.AxEngineModel;
35 import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
36 import org.onap.policy.apex.model.enginemodel.concepts.AxEngineStats;
38 public class DummyTestApexEngineModelCreator implements TestApexModelCreator<AxEngineModel> {
41 public AxEngineModel getModel() {
42 final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
43 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
44 final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
45 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
47 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1"));
48 schemas.getSchemasMap().put(schema0.getKey(), schema0);
49 schemas.getSchemasMap().put(schema1.getKey(), schema1);
51 final AxContextAlbum album0 =
52 new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema1.getKey());
54 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
55 albums.getAlbumsMap().put(album0.getKey(), album0);
57 final AxEngineModel engineModel = new AxEngineModel(new AxArtifactKey("AnEngine", "0.0.1"));
58 engineModel.setSchemas(schemas);
59 engineModel.setAlbums(albums);
60 engineModel.setTimestamp(System.currentTimeMillis());
61 engineModel.setState(AxEngineState.EXECUTING);
62 engineModel.setStats(new AxEngineStats(new AxReferenceKey(engineModel.getKey(), "EngineStats"),
63 System.currentTimeMillis(), 100, 205, 200, 12345, 9876));
64 engineModel.getKeyInformation().generateKeyInfo(engineModel);
66 final AxValidationResult result = new AxValidationResult();
67 engineModel.validate(result);
73 public AxEngineModel getInvalidModel() {
74 final AxEngineModel engineModel = getModel();
76 engineModel.setTimestamp(System.currentTimeMillis());
77 engineModel.setState(AxEngineState.UNDEFINED);
78 engineModel.setStats(new AxEngineStats(new AxReferenceKey(engineModel.getKey(), "EngineStats"),
79 System.currentTimeMillis(), 100, 205, 200, 12345, 9876));
80 engineModel.getKeyInformation().generateKeyInfo(engineModel);
86 * Get a malstructured model.
88 public AxEngineModel getMalstructuredModel() {
89 final AxEngineModel engineModel = getModel();
91 engineModel.setTimestamp(-1);
92 engineModel.setState(AxEngineState.UNDEFINED);
98 public AxEngineModel getObservationModel() {
99 final AxEngineModel engineModel = getModel();
101 final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
102 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
103 final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
104 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
106 engineModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(),
107 new AxKeyInfo(schema0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000001"), ""));
108 engineModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(),
109 new AxKeyInfo(schema1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000002"), ""));
115 public AxEngineModel getWarningModel() {
116 final AxEngineModel engineModel = getModel();
118 final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
119 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
120 final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
121 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
123 engineModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(),
124 new AxKeyInfo(schema0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000000"), ""));
125 engineModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(),
126 new AxKeyInfo(schema1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000001"), ""));