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 static org.onap.policy.apex.context.test.utils.Constants.DATE_CONTEXT_ALBUM;
24 import static org.onap.policy.apex.context.test.utils.Constants.EXTERNAL_CONTEXT_ALBUM;
25 import static org.onap.policy.apex.context.test.utils.Constants.GLOBAL_CONTEXT_ALBUM;
26 import static org.onap.policy.apex.context.test.utils.Constants.LONG_CONTEXT_ALBUM;
27 import static org.onap.policy.apex.context.test.utils.Constants.MAP_CONTEXT_ALBUM;
28 import static org.onap.policy.apex.context.test.utils.Constants.POLICY_CONTEXT_ALBUM;
29 import static org.onap.policy.apex.context.test.utils.Constants.VERSION;
31 import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
32 import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
33 import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
34 import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
35 import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
36 import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
37 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
38 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
39 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
40 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
41 import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
42 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
43 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
46 * The Class TestContextAlbumFactory creates test context albums.
48 * @author Liam Fallon (liam.fallon@ericsson.com)
50 public final class TestContextAlbumFactory {
52 private static final String APPLICATION = "APPLICATION";
53 private static final String JAVA_LONG = Long.class.getCanonicalName();
54 private static final String JAVA_FLAVOUR = "Java";
57 * Default constructor to prevent sub-classing.
59 private TestContextAlbumFactory() {}
62 * Creates the policy context model.
64 * @return the ax context model
66 public static AxContextModel createPolicyContextModel() {
67 final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", VERSION),
68 JAVA_FLAVOUR, TestPolicyContextItem.class.getCanonicalName());
69 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION),
70 APPLICATION, true, policySchema.getKey());
72 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
73 schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
74 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
75 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
77 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
78 final AxContextModel contextModel =
79 new AxContextModel(new AxArtifactKey("PolicyContextModel", VERSION), schemas, albums, keyInformation);
80 contextModel.setKeyInformation(keyInformation);
81 keyInformation.generateKeyInfo(contextModel);
87 * Creates the global context model.
89 * @return the ax context model
91 public static AxContextModel createGlobalContextModel() {
92 final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", VERSION),
93 JAVA_FLAVOUR, TestGlobalContextItem.class.getCanonicalName());
94 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION),
95 "GLOBAL", true, globalSchema.getKey());
97 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
98 schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
99 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
100 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
102 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
103 final AxContextModel contextModel =
104 new AxContextModel(new AxArtifactKey("GlobalContextModel", VERSION), schemas, albums, keyInformation);
105 contextModel.setKeyInformation(keyInformation);
106 keyInformation.generateKeyInfo(contextModel);
112 * Creates the external context model.
114 * @return the ax context model
116 public static AxContextModel createExternalContextModel() {
117 final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", VERSION),
118 JAVA_FLAVOUR, TestExternalContextItem.class.getCanonicalName());
119 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION),
120 "EXTERNAL", true, externalSchema.getKey());
122 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
123 schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
124 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
125 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
127 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
128 final AxContextModel contextModel =
129 new AxContextModel(new AxArtifactKey("ExternalContextModel", VERSION), schemas, albums, keyInformation);
130 contextModel.setKeyInformation(keyInformation);
131 keyInformation.generateKeyInfo(contextModel);
137 * Creates the long context model.
139 * @return the ax context model
141 public static AxContextModel createLongContextModel() {
142 final AxArtifactKey longSchemaKey = new AxArtifactKey("LongSchema", VERSION);
143 final AxContextSchema longSchema = new AxContextSchema(longSchemaKey, JAVA_FLAVOUR, JAVA_LONG);
145 final AxArtifactKey longContextAlbumKey = new AxArtifactKey("LongContextAlbum1", VERSION);
146 final AxContextAlbum albumDefinition1 =
147 new AxContextAlbum(longContextAlbumKey, APPLICATION, true, longSchema.getKey());
149 final AxArtifactKey longContextAlbumKey2 = new AxArtifactKey("LongContextAlbum2", VERSION);
150 final AxContextAlbum albumDefinition2 =
151 new AxContextAlbum(longContextAlbumKey2, APPLICATION, true, longSchema.getKey());
153 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
154 schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
155 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
156 albums.getAlbumsMap().put(albumDefinition1.getKey(), albumDefinition1);
157 albums.getAlbumsMap().put(albumDefinition2.getKey(), albumDefinition2);
159 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
160 final AxContextModel contextModel =
161 new AxContextModel(new AxArtifactKey("LongContextModel", VERSION), schemas, albums, keyInformation);
162 contextModel.setKeyInformation(keyInformation);
163 keyInformation.generateKeyInfo(contextModel);
169 * Creates the multi albums context model.
171 * @return the ax context model
173 public static AxContextModel createMultiAlbumsContextModel() {
174 final AxContextSchema longSchema =
175 new AxContextSchema(new AxArtifactKey("LongSchema", VERSION), JAVA_FLAVOUR, JAVA_LONG);
176 final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", VERSION), JAVA_FLAVOUR,
177 TestContextLongItem.class.getCanonicalName());
178 final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", VERSION), JAVA_FLAVOUR,
179 TestContextDateLocaleItem.class.getCanonicalName());
180 final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", VERSION), JAVA_FLAVOUR,
181 TestContextTreeMapItem.class.getCanonicalName());
183 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
184 schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
185 schemas.getSchemasMap().put(lTypeSchema.getKey(), lTypeSchema);
186 schemas.getSchemasMap().put(dateSchema.getKey(), dateSchema);
187 schemas.getSchemasMap().put(mapSchema.getKey(), mapSchema);
189 final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey(LONG_CONTEXT_ALBUM, VERSION),
190 APPLICATION, true, longSchema.getKey());
191 final AxContextAlbum lTypeAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LTypeContextAlbum", VERSION),
192 APPLICATION, true, lTypeSchema.getKey());
193 final AxContextAlbum dateAlbumDefinition = new AxContextAlbum(new AxArtifactKey(DATE_CONTEXT_ALBUM, VERSION),
194 APPLICATION, true, dateSchema.getKey());
195 final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey(MAP_CONTEXT_ALBUM, VERSION),
196 APPLICATION, true, mapSchema.getKey());
198 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
199 albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition);
200 albums.getAlbumsMap().put(lTypeAlbumDefinition.getKey(), lTypeAlbumDefinition);
201 albums.getAlbumsMap().put(dateAlbumDefinition.getKey(), dateAlbumDefinition);
202 albums.getAlbumsMap().put(mapAlbumDefinition.getKey(), mapAlbumDefinition);
204 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
205 final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", VERSION),
206 schemas, albums, keyInformation);
207 contextModel.setKeyInformation(keyInformation);
208 keyInformation.generateKeyInfo(contextModel);