Changes for checkstyle 8.32
[policy/apex-pdp.git] / model / context-model / src / test / java / org / onap / policy / apex / model / contextmodel / handling / TestApexContextModelCreator.java
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 java.util.UUID;
24 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
25 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
26 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
27 import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
28 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
29 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
30 import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
31 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
32 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
33
34 public class TestApexContextModelCreator implements TestApexModelCreator<AxContextModel> {
35
36     @Override
37     public AxContextModel getModel() {
38         final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
39                 "org.onap.policy.apex.concept.TestContextItem000");
40         final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
41                 "org.onap.policy.apex.concept.TestContextItem00A");
42
43         final AxContextSchemas contextSchemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1"));
44         contextSchemas.getSchemasMap().put(schema0.getKey(), schema0);
45         contextSchemas.getSchemasMap().put(schema1.getKey(), schema1);
46
47         final AxContextAlbum contextAlbum0 =
48                 new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema0.getKey());
49         final AxContextAlbum contextAlbum1 =
50                 new AxContextAlbum(new AxArtifactKey("contextAlbum1", "0.0.1"), "GLOBAL", false, schema1.getKey());
51
52         final AxContextAlbums axContext = new AxContextAlbums(new AxArtifactKey("contextAlbums", "0.0.1"));
53         axContext.getAlbumsMap().put(contextAlbum0.getKey(), contextAlbum0);
54         axContext.getAlbumsMap().put(contextAlbum1.getKey(), contextAlbum1);
55
56         final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
57         final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"),
58                 contextSchemas, axContext, keyInformation);
59
60         contextModel.setKeyInformation(keyInformation);
61         contextModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(), new AxKeyInfo(schema0.getKey(),
62                 UUID.fromString("00000000-0000-0000-0000-000000000001"), "axContextSchema0"));
63         contextModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(), new AxKeyInfo(schema1.getKey(),
64                 UUID.fromString("00000000-0000-0000-0000-000000000002"), "axContextSchema1"));
65         contextModel.getKeyInformation().getKeyInfoMap().put(contextSchemas.getKey(), new AxKeyInfo(
66                 contextSchemas.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000003"), "ContextSchemas"));
67         contextModel.getKeyInformation().getKeyInfoMap().put(contextAlbum0.getKey(), new AxKeyInfo(
68                 contextAlbum0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000004"), "contextAlbum0"));
69         contextModel.getKeyInformation().getKeyInfoMap().put(contextAlbum1.getKey(), new AxKeyInfo(
70                 contextAlbum1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000005"), "contextAlbum1"));
71         contextModel.getKeyInformation().getKeyInfoMap().put(axContext.getKey(), new AxKeyInfo(axContext.getKey(),
72                 UUID.fromString("00000000-0000-0000-0000-000000000006"), "axContext"));
73         contextModel.getKeyInformation().getKeyInfoMap().put(contextModel.getKey(), new AxKeyInfo(contextModel.getKey(),
74                 UUID.fromString("00000000-0000-0000-0000-000000000007"), "contextModel"));
75         contextModel.getKeyInformation().getKeyInfoMap().put(keyInformation.getKey(), new AxKeyInfo(
76                 keyInformation.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000008"), "keyInformation"));
77
78         return contextModel;
79     }
80
81     @Override
82     public AxContextModel getInvalidModel() {
83         final AxContextModel contextModel = getModel();
84
85         contextModel.getAlbums().get(new AxArtifactKey("contextAlbum0", "0.0.1")).setScope("UNDEFINED");
86
87         contextModel.getSchemas().get(new AxArtifactKey("StringType", "0.0.1")).setSchema("");
88
89         return contextModel;
90     }
91
92     @Override
93     public AxContextModel getMalstructuredModel() {
94         final AxContextModel contextModel = getModel();
95
96         contextModel.getAlbums().get(new AxArtifactKey("contextAlbum1", "0.0.1"))
97                 .setKey(new AxArtifactKey("contextAlbum1", "0.0.2"));;
98         contextModel.getSchemas().get(new AxArtifactKey("MapType", "0.0.1"))
99                 .setKey(new AxArtifactKey("MapType", "0.0.2"));;
100
101         return contextModel;
102     }
103
104     @Override
105     public AxContextModel getObservationModel() {
106         final AxContextModel contextModel = getModel();
107
108         contextModel.getKeyInformation().get("contextAlbum1", "0.0.1").setDescription("");
109
110         return contextModel;
111     }
112
113     @Override
114     public AxContextModel getWarningModel() {
115         final AxContextModel contextModel = getModel();
116
117         contextModel.getKeyInformation().get("contextAlbum1", "0.0.1")
118                 .setUuid(UUID.fromString("00000000-0000-0000-0000-000000000000"));
119
120         return contextModel;
121     }
122 }