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;
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.AxReferenceKey;
27 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
28 import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
29 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
30 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
31 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
32 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
33 import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
34 import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
35 import org.onap.policy.apex.model.enginemodel.concepts.AxEngineStats;
37 public class DummyTestApexEngineModelCreator implements TestApexModelCreator<AxEngineModel> {
40 public AxEngineModel getModel() {
41 final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
42 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
43 final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
44 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
46 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1"));
47 schemas.getSchemasMap().put(schema0.getKey(), schema0);
48 schemas.getSchemasMap().put(schema1.getKey(), schema1);
50 final AxContextAlbum album0 =
51 new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema1.getKey());
53 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
54 albums.getAlbumsMap().put(album0.getKey(), album0);
56 final AxEngineModel engineModel = new AxEngineModel(new AxArtifactKey("AnEngine", "0.0.1"));
57 engineModel.setSchemas(schemas);
58 engineModel.setAlbums(albums);
59 engineModel.setTimestamp(System.currentTimeMillis());
60 engineModel.setState(AxEngineState.EXECUTING);
61 engineModel.setStats(new AxEngineStats(new AxReferenceKey(engineModel.getKey(), "EngineStats"),
62 System.currentTimeMillis(), 100, 205, 200, 12345, 9876));
63 engineModel.getKeyInformation().generateKeyInfo(engineModel);
65 final AxValidationResult result = new AxValidationResult();
66 engineModel.validate(result);
72 public AxEngineModel getInvalidModel() {
73 final AxEngineModel engineModel = getModel();
75 engineModel.setTimestamp(System.currentTimeMillis());
76 engineModel.setState(AxEngineState.UNDEFINED);
77 engineModel.setStats(new AxEngineStats(new AxReferenceKey(engineModel.getKey(), "EngineStats"),
78 System.currentTimeMillis(), 100, 205, 200, 12345, 9876));
79 engineModel.getKeyInformation().generateKeyInfo(engineModel);
85 * Get a malstructured model.
87 public AxEngineModel getMalstructuredModel() {
88 final AxEngineModel engineModel = getModel();
90 engineModel.setTimestamp(-1);
91 engineModel.setState(AxEngineState.UNDEFINED);
97 public AxEngineModel getObservationModel() {
98 final AxEngineModel engineModel = getModel();
100 final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
101 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
102 final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
103 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
105 engineModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(),
106 new AxKeyInfo(schema0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000001"), ""));
107 engineModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(),
108 new AxKeyInfo(schema1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000002"), ""));
114 public AxEngineModel getWarningModel() {
115 final AxEngineModel engineModel = getModel();
117 final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
118 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
119 final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
120 "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
122 engineModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(),
123 new AxKeyInfo(schema0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000000"), ""));
124 engineModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(),
125 new AxKeyInfo(schema1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000001"), ""));