64de009d5c5b6bbef46aceb79747fbb4cb94b075
[policy/apex-pdp.git] /
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.context.test.factory;
22
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;
30
31 /**
32  * The Class TestContextAlbumFactory creates test context albums.
33  *
34  * @author Liam Fallon (liam.fallon@ericsson.com)
35  */
36 public final class TestContextAlbumFactory {
37     /**
38      * Default constructor to prevent sub-classing.
39      */
40     private TestContextAlbumFactory() {}
41
42     /**
43      * Creates the policy context model.
44      *
45      * @return the ax context model
46      */
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());
52
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);
57
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);
63
64         return contextModel;
65     }
66
67     /**
68      * Creates the global context model.
69      *
70      * @return the ax context model
71      */
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());
77
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);
82
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);
88
89         return contextModel;
90     }
91
92     /**
93      * Creates the external context model.
94      *
95      * @return the ax context model
96      */
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());
102
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);
107
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);
113
114         return contextModel;
115     }
116
117     /**
118      * Creates the long context model.
119      *
120      * @return the ax context model
121      */
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());
129
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);
135
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);
141
142         return contextModel;
143     }
144
145     /**
146      * Creates the multi albums context model.
147      *
148      * @return the ax context model
149      */
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");
159
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);
165
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());
174
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);
180
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);
186
187         return contextModel;
188     }
189 }