2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.testsuites.integration.context.factory;
24 import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.DATE_CONTEXT_ALBUM;
25 import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.EXTERNAL_CONTEXT_ALBUM;
26 import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.GLOBAL_CONTEXT_ALBUM;
27 import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.LONG_CONTEXT_ALBUM;
28 import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.MAP_CONTEXT_ALBUM;
29 import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.POLICY_CONTEXT_ALBUM;
30 import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.VERSION;
32 import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
33 import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
34 import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
35 import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
36 import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
37 import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
38 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
39 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
40 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
41 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
42 import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
43 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
44 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
47 * The Class TestContextAlbumFactory creates test context albums.
49 * @author Liam Fallon (liam.fallon@ericsson.com)
51 public final class TestContextAlbumFactory {
52 // Recurring string constants.
53 private static final String CONTEXT = "context";
54 private static final String SCHEMAS2 = "Schemas";
55 private static final String KEY_INFO_MAP_KEY = "KeyInfoMapKey";
56 private static final String APPLICATION = "APPLICATION";
57 private static final String JAVA_LONG = Long.class.getName();
58 private static final String JAVA_FLAVOUR = "Java";
61 * Default constructor to prevent sub-classing.
63 private TestContextAlbumFactory() {
64 // Private constructor to block subclassing
68 * Creates the policy context model.
70 * @return the ax context model
72 public static AxContextModel createPolicyContextModel() {
73 final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", VERSION),
74 JAVA_FLAVOUR, TestPolicyContextItem.class.getName());
75 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION),
76 APPLICATION, true, policySchema.getKey());
78 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
79 schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
80 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
81 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
83 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
84 final AxContextModel contextModel =
85 new AxContextModel(new AxArtifactKey("PolicyContextModel", VERSION), schemas, albums, keyInformation);
86 contextModel.setKeyInformation(keyInformation);
87 keyInformation.generateKeyInfo(contextModel);
93 * Creates the global context model.
95 * @return the ax context model
97 public static AxContextModel createGlobalContextModel() {
98 final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", VERSION),
99 JAVA_FLAVOUR, TestGlobalContextItem.class.getName());
100 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION),
101 "GLOBAL", true, globalSchema.getKey());
103 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
104 schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
105 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
106 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
108 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
109 final AxContextModel contextModel =
110 new AxContextModel(new AxArtifactKey("GlobalContextModel", VERSION), schemas, albums, keyInformation);
111 contextModel.setKeyInformation(keyInformation);
112 keyInformation.generateKeyInfo(contextModel);
118 * Creates the external context model.
120 * @return the ax context model
122 public static AxContextModel createExternalContextModel() {
123 final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", VERSION),
124 JAVA_FLAVOUR, TestExternalContextItem.class.getName());
125 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION),
126 "EXTERNAL", true, externalSchema.getKey());
128 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
129 schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
130 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
131 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
133 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
134 final AxContextModel contextModel =
135 new AxContextModel(new AxArtifactKey("ExternalContextModel", VERSION), schemas, albums, keyInformation);
136 contextModel.setKeyInformation(keyInformation);
137 keyInformation.generateKeyInfo(contextModel);
143 * Creates the long context model.
145 * @return the ax context model
147 public static AxContextModel createLongContextModel() {
148 final AxArtifactKey longSchemaKey = new AxArtifactKey("LongSchema", VERSION);
149 final AxContextSchema longSchema = new AxContextSchema(longSchemaKey, JAVA_FLAVOUR, JAVA_LONG);
151 final AxArtifactKey longContextAlbumKey = new AxArtifactKey("LongContextAlbum1", VERSION);
152 final AxContextAlbum albumDefinition1 =
153 new AxContextAlbum(longContextAlbumKey, APPLICATION, true, longSchema.getKey());
155 final AxArtifactKey longContextAlbumKey2 = new AxArtifactKey("LongContextAlbum2", VERSION);
156 final AxContextAlbum albumDefinition2 =
157 new AxContextAlbum(longContextAlbumKey2, APPLICATION, true, longSchema.getKey());
159 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
160 schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
161 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
162 albums.getAlbumsMap().put(albumDefinition1.getKey(), albumDefinition1);
163 albums.getAlbumsMap().put(albumDefinition2.getKey(), albumDefinition2);
165 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
166 final AxContextModel contextModel =
167 new AxContextModel(new AxArtifactKey("LongContextModel", VERSION), schemas, albums, keyInformation);
168 contextModel.setKeyInformation(keyInformation);
169 keyInformation.generateKeyInfo(contextModel);
175 * Creates the multi albums context model.
177 * @return the ax context model
179 public static AxContextModel createMultiAlbumsContextModel() {
180 final AxContextSchema longSchema =
181 new AxContextSchema(new AxArtifactKey("LongSchema", VERSION), JAVA_FLAVOUR, JAVA_LONG);
182 final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", VERSION), JAVA_FLAVOUR,
183 TestContextLongItem.class.getName());
184 final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", VERSION), JAVA_FLAVOUR,
185 TestContextDateLocaleItem.class.getName());
186 final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", VERSION), JAVA_FLAVOUR,
187 TestContextTreeMapItem.class.getName());
189 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
190 schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
191 schemas.getSchemasMap().put(lTypeSchema.getKey(), lTypeSchema);
192 schemas.getSchemasMap().put(dateSchema.getKey(), dateSchema);
193 schemas.getSchemasMap().put(mapSchema.getKey(), mapSchema);
195 final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey(LONG_CONTEXT_ALBUM, VERSION),
196 APPLICATION, true, longSchema.getKey());
197 final AxContextAlbum lTypeAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LTypeContextAlbum", VERSION),
198 APPLICATION, true, lTypeSchema.getKey());
199 final AxContextAlbum dateAlbumDefinition = new AxContextAlbum(new AxArtifactKey(DATE_CONTEXT_ALBUM, VERSION),
200 APPLICATION, true, dateSchema.getKey());
201 final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey(MAP_CONTEXT_ALBUM, VERSION),
202 APPLICATION, true, mapSchema.getKey());
204 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
205 albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition);
206 albums.getAlbumsMap().put(lTypeAlbumDefinition.getKey(), lTypeAlbumDefinition);
207 albums.getAlbumsMap().put(dateAlbumDefinition.getKey(), dateAlbumDefinition);
208 albums.getAlbumsMap().put(mapAlbumDefinition.getKey(), mapAlbumDefinition);
210 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
211 final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", VERSION),
212 schemas, albums, keyInformation);
213 contextModel.setKeyInformation(keyInformation);
214 keyInformation.generateKeyInfo(contextModel);