Merge "Fix all blocker sonar issues and some checkstyle"
[aai/aai-common.git] / aai-schema-abstraction / src / test / java / org / onap / aai / schemaif / oxm / OxmSchemaServiceSetup.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2019 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2019 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
22 package org.onap.aai.schemaif.oxm;
23
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.HashSet;
27 import java.util.List;
28 import java.util.Set;
29 import org.junit.Before;
30 import org.junit.runner.RunWith;
31 import org.mockito.Mock;
32 import org.mockito.Mockito;
33 import org.mockito.runners.MockitoJUnitRunner;
34 import org.onap.aai.edges.EdgeIngestor;
35 import org.onap.aai.nodes.NodeIngestor;
36 import org.onap.aai.setup.AAIConfigTranslator;
37 import org.onap.aai.setup.SchemaLocationsBean;
38 import org.onap.aai.setup.SchemaVersion;
39 import org.onap.aai.setup.SchemaConfigVersions;
40 import org.onap.aai.setup.Translator;
41
42 @RunWith(MockitoJUnitRunner.class)
43 public class OxmSchemaServiceSetup {
44
45     @Mock
46     private SchemaLocationsBean schemaLocationsBean;
47
48     @Mock
49     private SchemaConfigVersions schemaConfigVersions;
50
51     private EdgePropsConfiguration edgePropsConfiguration = new EdgePropsConfiguration();
52
53     private List<SchemaVersion> schemaVersionList = new ArrayList<>();
54
55     private OxmEdgeRulesLoader edgeLoader;
56     private OxmSchemaLoader vertexLoader;
57
58     @Before
59     public void schemaBeanMockSetup() throws Exception {
60         schemaVersionList.add(new SchemaVersion("v13"));
61
62         Mockito.when(schemaConfigVersions.getVersions()).thenReturn(schemaVersionList);
63         Mockito.when(schemaLocationsBean.getNodesInclusionPattern()).thenReturn(Arrays.asList(".*oxm(.*).xml"));
64         Mockito.when(schemaLocationsBean.getEdgesInclusionPattern()).thenReturn(Arrays.asList("DbEdgeRules_.*.json"));
65         Mockito.when(schemaLocationsBean.getNodeDirectory()).thenReturn("src/test/resources/oxm/oxm");
66         Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/oxm/edge-rules");
67
68         AAIConfigTranslator aaiConfigTranslator = new AAIConfigTranslator(schemaLocationsBean,  schemaConfigVersions);
69         Set<Translator> translators = new HashSet<>();
70         translators.add(aaiConfigTranslator);
71         NodeIngestor nodeIngestor = new NodeIngestor(translators);
72         nodeIngestor.initialize();
73         EdgeIngestor edgeIngestor = new EdgeIngestor(translators);
74         edgeIngestor.initialize();
75
76         edgePropsConfiguration.setEdgePropsDir("src/test/resources/oxm/edge-props");
77         edgeLoader = new OxmEdgeRulesLoader(aaiConfigTranslator, edgeIngestor, edgePropsConfiguration);
78         vertexLoader = new OxmSchemaLoader(aaiConfigTranslator, nodeIngestor);
79     }
80
81 }