f7c7a13451c4fd5c7d38d8217173521938d054e9
[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.model.contextmodel.handling;
22
23 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
24 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
25 import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
26 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
27
28 /**
29  * This class creates sample Policy Models.
30  *
31  * @author Liam Fallon (liam.fallon@ericsson.com)
32  */
33 public class TestContextComparisonFactory {
34
35     /**
36      * Get a full context model.
37      * @return the model
38      */
39     public AxContextModel getFullModel() {
40         final AxContextSchema testContextSchema000 =
41                 new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
42                         "org.onap.policy.apex.concept.TestContextSchema000");
43         final AxContextSchema testContextSchema00A =
44                 new AxContextSchema(new AxArtifactKey("TestContextSchema00A", "0.0.1"), "JAVA",
45                         "org.onap.policy.apex.concept.TestContextSchema00A");
46         final AxContextSchema testContextSchema00C =
47                 new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
48                         "org.onap.policy.apex.concept.TestContextSchema00C");
49
50         final AxContextAlbum externalContextAlbum = new AxContextAlbum(
51                 new AxArtifactKey("ExternalContextAlbum", "0.0.1"), "EXTERNAL", false, testContextSchema000.getKey());
52         final AxContextAlbum globalContextAlbum = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"),
53                 "GLOBAL", true, testContextSchema00A.getKey());
54         final AxContextAlbum policy0ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy0ContextAlbum", "0.0.1"),
55                 "APPLICATION", true, testContextSchema00C.getKey());
56         final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
57                 new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema00C.getKey());
58
59         final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
60         contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
61         contextModel.getSchemas().getSchemasMap().put(testContextSchema00A.getKey(), testContextSchema00A);
62         contextModel.getSchemas().getSchemasMap().put(testContextSchema00C.getKey(), testContextSchema00C);
63
64         contextModel.getAlbums().getAlbumsMap().put(externalContextAlbum.getKey(), externalContextAlbum);
65         contextModel.getAlbums().getAlbumsMap().put(globalContextAlbum.getKey(), globalContextAlbum);
66         contextModel.getAlbums().getAlbumsMap().put(policy0ContextAlbum.getKey(), policy0ContextAlbum);
67         contextModel.getAlbums().getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum);
68
69         return contextModel;
70     }
71
72     public AxContextModel getEmptyModel() {
73         return new AxContextModel(new AxArtifactKey("Context", "0.0.1"));
74     }
75
76     /**
77      * Get a skeleton model.
78      * @return The model
79      */
80     public AxContextModel getShellModel() {
81         final AxContextSchema testContextSchema000 =
82                 new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
83                         "org.onap.policy.apex.concept.TestContextSchema000");
84         final AxContextSchema testContextSchema00A =
85                 new AxContextSchema(new AxArtifactKey("TestContextSchema00A", "0.0.1"), "JAVA",
86                         "org.onap.policy.apex.concept.TestContextSchema00A");
87         final AxContextSchema testContextSchema00C =
88                 new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
89                         "org.onap.policy.apex.concept.TestContextSchema00C");
90
91         final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
92         contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
93         contextModel.getSchemas().getSchemasMap().put(testContextSchema00A.getKey(), testContextSchema00A);
94         contextModel.getSchemas().getSchemasMap().put(testContextSchema00C.getKey(), testContextSchema00C);
95
96         return contextModel;
97     }
98
99     /**
100      * Get a single entry model.
101      * @return The single entry model
102      */
103     public AxContextModel getSingleEntryModel() {
104         final AxContextSchema testContextSchema000 =
105                 new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
106                         "org.onap.policy.apex.concept.TestContextSchema000");
107
108         final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
109                 new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema000.getKey());
110
111         final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
112         contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
113
114         contextModel.getAlbums().getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum);
115
116         return contextModel;
117     }
118
119     /**
120      * Get a model with no global entries.
121      * @return the model
122      */
123     public AxContextModel getNoGlobalContextModel() {
124         final AxContextSchema testContextSchema000 =
125                 new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
126                         "org.onap.policy.apex.concept.TestContextSchema000");
127         final AxContextSchema testContextSchema00C =
128                 new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
129                         "org.onap.policy.apex.concept.TestContextSchema00C");
130
131         final AxContextAlbum externalContextAlbum = new AxContextAlbum(
132                 new AxArtifactKey("ExternalContextAlbum", "0.0.1"), "EXTERNAL", false, testContextSchema000.getKey());
133         final AxContextAlbum policy0ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy0ContextAlbum", "0.0.1"),
134                 "APPLICATION", true, testContextSchema00C.getKey());
135         final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
136                 new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema00C.getKey());
137
138         final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
139         contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
140         contextModel.getSchemas().getSchemasMap().put(testContextSchema00C.getKey(), testContextSchema00C);
141
142         contextModel.getAlbums().getAlbumsMap().put(externalContextAlbum.getKey(), externalContextAlbum);
143         contextModel.getAlbums().getAlbumsMap().put(policy0ContextAlbum.getKey(), policy0ContextAlbum);
144         contextModel.getAlbums().getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum);
145
146         return contextModel;
147     }
148 }