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.context.test.factory;
23 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
24 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
25 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
26 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
27 import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
28 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
29 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
32 * The Class TestContextAlbumFactory creates test context albums.
34 * @author Liam Fallon (liam.fallon@ericsson.com)
36 public final class TestContextAlbumFactory {
38 * Default constructor to prevent sub-classing.
40 private TestContextAlbumFactory() {}
43 * Creates the policy context model.
45 * @return the ax context model
47 public static AxContextModel createPolicyContextModel() {
48 final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", "0.0.1"), "Java",
49 "org.onap.policy.apex.context.test.concepts.TestPolicyContextItem");
50 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("PolicyContextAlbum", "0.0.1"),
51 "APPLICATION", true, policySchema.getKey());
53 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
54 schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
55 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
56 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
58 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
59 final AxContextModel contextModel =
60 new AxContextModel(new AxArtifactKey("PolicyContextModel", "0.0.1"), schemas, albums, keyInformation);
61 contextModel.setKeyInformation(keyInformation);
62 keyInformation.generateKeyInfo(contextModel);
68 * Creates the global context model.
70 * @return the ax context model
72 public static AxContextModel createGlobalContextModel() {
73 final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", "0.0.1"), "Java",
74 "org.onap.policy.apex.context.test.concepts.TestGlobalContextItem");
75 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"),
76 "GLOBAL", true, globalSchema.getKey());
78 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
79 schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
80 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
81 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
83 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
84 final AxContextModel contextModel =
85 new AxContextModel(new AxArtifactKey("GlobalContextModel", "0.0.1"), schemas, albums, keyInformation);
86 contextModel.setKeyInformation(keyInformation);
87 keyInformation.generateKeyInfo(contextModel);
93 * Creates the external context model.
95 * @return the ax context model
97 public static AxContextModel createExternalContextModel() {
98 final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", "0.0.1"), "Java",
99 "org.onap.policy.apex.context.test.concepts.TestExternalContextItem");
100 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey("ExternalContextAlbum", "0.0.1"),
101 "EXTERNAL", true, externalSchema.getKey());
103 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
104 schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
105 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
106 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
108 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
109 final AxContextModel contextModel =
110 new AxContextModel(new AxArtifactKey("ExternalContextModel", "0.0.1"), schemas, albums, keyInformation);
111 contextModel.setKeyInformation(keyInformation);
112 keyInformation.generateKeyInfo(contextModel);
118 * Creates the long context model.
120 * @return the ax context model
122 public static AxContextModel createLongContextModel() {
123 final AxContextSchema longSchema =
124 new AxContextSchema(new AxArtifactKey("LongSchema", "0.0.1"), "Java", "java.lang.Long");
125 final AxContextAlbum albumDefinition1 = new AxContextAlbum(new AxArtifactKey("LongContextAlbum1", "0.0.1"),
126 "APPLICATION", true, longSchema.getKey());
127 final AxContextAlbum albumDefinition2 = new AxContextAlbum(new AxArtifactKey("LongContextAlbum2", "0.0.1"),
128 "APPLICATION", true, longSchema.getKey());
130 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
131 schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
132 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
133 albums.getAlbumsMap().put(albumDefinition1.getKey(), albumDefinition1);
134 albums.getAlbumsMap().put(albumDefinition2.getKey(), albumDefinition2);
136 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
137 final AxContextModel contextModel =
138 new AxContextModel(new AxArtifactKey("LongContextModel", "0.0.1"), schemas, albums, keyInformation);
139 contextModel.setKeyInformation(keyInformation);
140 keyInformation.generateKeyInfo(contextModel);
146 * Creates the multi albums context model.
148 * @return the ax context model
150 public static AxContextModel createMultiAlbumsContextModel() {
151 final AxContextSchema longSchema =
152 new AxContextSchema(new AxArtifactKey("LongSchema", "0.0.1"), "Java", "java.lang.Long");
153 final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", "0.0.1"), "Java",
154 "org.onap.policy.apex.context.test.concepts.TestContextItem003");
155 final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", "0.0.1"), "Java",
156 "org.onap.policy.apex.context.test.concepts.TestContextItem00A");
157 final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", "0.0.1"), "Java",
158 "org.onap.policy.apex.context.test.concepts.TestContextItem00C");
160 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", "0.0.1"));
161 schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
162 schemas.getSchemasMap().put(lTypeSchema.getKey(), lTypeSchema);
163 schemas.getSchemasMap().put(dateSchema.getKey(), dateSchema);
164 schemas.getSchemasMap().put(mapSchema.getKey(), mapSchema);
166 final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LongContextAlbum", "0.0.1"),
167 "APPLICATION", true, longSchema.getKey());
168 final AxContextAlbum lTypeAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LTypeContextAlbum", "0.0.1"),
169 "APPLICATION", true, lTypeSchema.getKey());
170 final AxContextAlbum dateAlbumDefinition = new AxContextAlbum(new AxArtifactKey("DateContextAlbum", "0.0.1"),
171 "APPLICATION", true, dateSchema.getKey());
172 final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey("MapContextAlbum", "0.0.1"),
173 "APPLICATION", true, mapSchema.getKey());
175 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
176 albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition);
177 albums.getAlbumsMap().put(lTypeAlbumDefinition.getKey(), lTypeAlbumDefinition);
178 albums.getAlbumsMap().put(dateAlbumDefinition.getKey(), dateAlbumDefinition);
179 albums.getAlbumsMap().put(mapAlbumDefinition.getKey(), mapAlbumDefinition);
181 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
182 final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", "0.0.1"),
183 schemas, albums, keyInformation);
184 contextModel.setKeyInformation(keyInformation);
185 keyInformation.generateKeyInfo(contextModel);