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.getCanonicalName();
58 private static final String JAVA_FLAVOUR = "Java";
61 * Default constructor to prevent sub-classing.
63 private TestContextAlbumFactory() {}
66 * Creates the policy context model.
68 * @return the ax context model
70 public static AxContextModel createPolicyContextModel() {
71 final AxContextSchema policySchema = new AxContextSchema(new AxArtifactKey("PolicySchema", VERSION),
72 JAVA_FLAVOUR, TestPolicyContextItem.class.getCanonicalName());
73 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION),
74 APPLICATION, true, policySchema.getKey());
76 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
77 schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
78 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
79 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
81 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
82 final AxContextModel contextModel =
83 new AxContextModel(new AxArtifactKey("PolicyContextModel", VERSION), schemas, albums, keyInformation);
84 contextModel.setKeyInformation(keyInformation);
85 keyInformation.generateKeyInfo(contextModel);
91 * Creates the global context model.
93 * @return the ax context model
95 public static AxContextModel createGlobalContextModel() {
96 final AxContextSchema globalSchema = new AxContextSchema(new AxArtifactKey("GlobalSchema", VERSION),
97 JAVA_FLAVOUR, TestGlobalContextItem.class.getCanonicalName());
98 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION),
99 "GLOBAL", true, globalSchema.getKey());
101 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
102 schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
103 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
104 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
106 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
107 final AxContextModel contextModel =
108 new AxContextModel(new AxArtifactKey("GlobalContextModel", VERSION), schemas, albums, keyInformation);
109 contextModel.setKeyInformation(keyInformation);
110 keyInformation.generateKeyInfo(contextModel);
116 * Creates the external context model.
118 * @return the ax context model
120 public static AxContextModel createExternalContextModel() {
121 final AxContextSchema externalSchema = new AxContextSchema(new AxArtifactKey("ExternalSchema", VERSION),
122 JAVA_FLAVOUR, TestExternalContextItem.class.getCanonicalName());
123 final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION),
124 "EXTERNAL", true, externalSchema.getKey());
126 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
127 schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
128 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
129 albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
131 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
132 final AxContextModel contextModel =
133 new AxContextModel(new AxArtifactKey("ExternalContextModel", VERSION), schemas, albums, keyInformation);
134 contextModel.setKeyInformation(keyInformation);
135 keyInformation.generateKeyInfo(contextModel);
141 * Creates the long context model.
143 * @return the ax context model
145 public static AxContextModel createLongContextModel() {
146 final AxArtifactKey longSchemaKey = new AxArtifactKey("LongSchema", VERSION);
147 final AxContextSchema longSchema = new AxContextSchema(longSchemaKey, JAVA_FLAVOUR, JAVA_LONG);
149 final AxArtifactKey longContextAlbumKey = new AxArtifactKey("LongContextAlbum1", VERSION);
150 final AxContextAlbum albumDefinition1 =
151 new AxContextAlbum(longContextAlbumKey, APPLICATION, true, longSchema.getKey());
153 final AxArtifactKey longContextAlbumKey2 = new AxArtifactKey("LongContextAlbum2", VERSION);
154 final AxContextAlbum albumDefinition2 =
155 new AxContextAlbum(longContextAlbumKey2, APPLICATION, true, longSchema.getKey());
157 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
158 schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
159 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
160 albums.getAlbumsMap().put(albumDefinition1.getKey(), albumDefinition1);
161 albums.getAlbumsMap().put(albumDefinition2.getKey(), albumDefinition2);
163 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
164 final AxContextModel contextModel =
165 new AxContextModel(new AxArtifactKey("LongContextModel", VERSION), schemas, albums, keyInformation);
166 contextModel.setKeyInformation(keyInformation);
167 keyInformation.generateKeyInfo(contextModel);
173 * Creates the multi albums context model.
175 * @return the ax context model
177 public static AxContextModel createMultiAlbumsContextModel() {
178 final AxContextSchema longSchema =
179 new AxContextSchema(new AxArtifactKey("LongSchema", VERSION), JAVA_FLAVOUR, JAVA_LONG);
180 final AxContextSchema lTypeSchema = new AxContextSchema(new AxArtifactKey("LTypeSchema", VERSION), JAVA_FLAVOUR,
181 TestContextLongItem.class.getCanonicalName());
182 final AxContextSchema dateSchema = new AxContextSchema(new AxArtifactKey("DateSchema", VERSION), JAVA_FLAVOUR,
183 TestContextDateLocaleItem.class.getCanonicalName());
184 final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", VERSION), JAVA_FLAVOUR,
185 TestContextTreeMapItem.class.getCanonicalName());
187 final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
188 schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
189 schemas.getSchemasMap().put(lTypeSchema.getKey(), lTypeSchema);
190 schemas.getSchemasMap().put(dateSchema.getKey(), dateSchema);
191 schemas.getSchemasMap().put(mapSchema.getKey(), mapSchema);
193 final AxContextAlbum longAlbumDefinition = new AxContextAlbum(new AxArtifactKey(LONG_CONTEXT_ALBUM, VERSION),
194 APPLICATION, true, longSchema.getKey());
195 final AxContextAlbum lTypeAlbumDefinition = new AxContextAlbum(new AxArtifactKey("LTypeContextAlbum", VERSION),
196 APPLICATION, true, lTypeSchema.getKey());
197 final AxContextAlbum dateAlbumDefinition = new AxContextAlbum(new AxArtifactKey(DATE_CONTEXT_ALBUM, VERSION),
198 APPLICATION, true, dateSchema.getKey());
199 final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey(MAP_CONTEXT_ALBUM, VERSION),
200 APPLICATION, true, mapSchema.getKey());
202 final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
203 albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition);
204 albums.getAlbumsMap().put(lTypeAlbumDefinition.getKey(), lTypeAlbumDefinition);
205 albums.getAlbumsMap().put(dateAlbumDefinition.getKey(), dateAlbumDefinition);
206 albums.getAlbumsMap().put(mapAlbumDefinition.getKey(), mapAlbumDefinition);
208 final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
209 final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", VERSION),
210 schemas, albums, keyInformation);
211 contextModel.setKeyInformation(keyInformation);
212 keyInformation.generateKeyInfo(contextModel);