Upgrade version of aai-common
[aai/gizmo.git] / src / test / java / org / onap / crud / OXMModelLoaderSetup.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.crud;
22
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.List;
26
27 import org.junit.Before;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.onap.aai.edges.EdgeIngestor;
31 import org.onap.aai.nodes.NodeIngestor;
32 import org.onap.aai.setup.AAIConfigTranslator;
33 import org.onap.aai.setup.SchemaLocationsBean;
34 import org.onap.aai.setup.SchemaVersion;
35 import org.onap.aai.setup.SchemaVersions;
36 import org.onap.schema.EdgePropsConfiguration;
37 import org.onap.schema.EdgeRulesLoader;
38 import org.onap.schema.OxmModelLoader;
39
40 public class OXMModelLoaderSetup {
41
42     private EdgeRulesLoader edgeRulesLoader;
43
44     private OxmModelLoader oxmModelLoader;
45
46     @Mock
47     private SchemaLocationsBean schemaLocationsBean;
48
49     @Mock
50     private SchemaVersions schemaVersions;
51
52     @Mock
53     private EdgePropsConfiguration edgePropsConfiguration;
54
55     private List<SchemaVersion> schemaVersionList = new ArrayList<>();
56
57     @Before
58     public void schemaBeanMockSetup() throws Exception {
59
60         schemaVersionList.add(new SchemaVersion("v8"));
61         schemaVersionList.add(new SchemaVersion("v9"));
62         schemaVersionList.add(new SchemaVersion("v10"));
63         schemaVersionList.add(new SchemaVersion("v11"));
64         schemaVersionList.add(new SchemaVersion("v13"));
65
66         Mockito.when(schemaVersions.getVersions()).thenReturn(schemaVersionList);
67         Mockito.when(schemaLocationsBean.getNodesInclusionPattern()).thenReturn(Arrays.asList(".*oxm(.*).xml"));
68         Mockito.when(schemaLocationsBean.getEdgesInclusionPattern()).thenReturn(Arrays.asList("DbEdgeRules_.*.json"));
69         Mockito.when(schemaLocationsBean.getNodeDirectory()).thenReturn("src/test/resources/multi-oxm/");
70         Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/rules");
71         Mockito.when(edgePropsConfiguration.getEdgePropsDir()).thenReturn("src/test/resources/edgeProps/");
72
73         AAIConfigTranslator aaiConfigTranslator = new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
74         NodeIngestor nodeIngestor = new NodeIngestor(aaiConfigTranslator);
75         EdgeIngestor edgeIngestor = new EdgeIngestor(aaiConfigTranslator, schemaVersions);
76         edgeRulesLoader = new EdgeRulesLoader(aaiConfigTranslator, edgeIngestor, edgePropsConfiguration);
77         oxmModelLoader = new OxmModelLoader(aaiConfigTranslator, nodeIngestor);
78     }
79 }