2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.aai.schemaif.oxm;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.HashSet;
27 import java.util.List;
29 import org.junit.Before;
30 import org.mockito.Mock;
31 import org.mockito.Mockito;
32 import org.onap.aai.edges.EdgeIngestor;
33 import org.onap.aai.nodes.NodeIngestor;
34 import org.onap.aai.setup.AAIConfigTranslator;
35 import org.onap.aai.setup.SchemaLocationsBean;
36 import org.onap.aai.setup.SchemaVersion;
37 import org.onap.aai.setup.SchemaConfigVersions;
38 import org.onap.aai.setup.Translator;
40 public class OxmSchemaServiceSetup {
43 private SchemaLocationsBean schemaLocationsBean;
46 private SchemaConfigVersions schemaConfigVersions;
48 private EdgePropsConfiguration edgePropsConfiguration = new EdgePropsConfiguration();
50 private List<SchemaVersion> schemaVersionList = new ArrayList<>();
52 private OxmEdgeRulesLoader edgeLoader;
53 private OxmSchemaLoader vertexLoader;
56 public void schemaBeanMockSetup() throws Exception {
57 schemaVersionList.add(new SchemaVersion("v13"));
59 Mockito.when(schemaConfigVersions.getVersions()).thenReturn(schemaVersionList);
60 Mockito.when(schemaLocationsBean.getNodesInclusionPattern()).thenReturn(Arrays.asList(".*oxm(.*).xml"));
61 Mockito.when(schemaLocationsBean.getEdgesInclusionPattern()).thenReturn(Arrays.asList("DbEdgeRules_.*.json"));
62 Mockito.when(schemaLocationsBean.getNodeDirectory()).thenReturn("src/test/resources/oxm/oxm");
63 Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/oxm/edge-rules");
65 AAIConfigTranslator aaiConfigTranslator = new AAIConfigTranslator(schemaLocationsBean, schemaConfigVersions);
66 Set<Translator> translators = new HashSet<>();
67 translators.add(aaiConfigTranslator);
68 NodeIngestor nodeIngestor = new NodeIngestor(translators);
69 nodeIngestor.initialize();
70 EdgeIngestor edgeIngestor = new EdgeIngestor(translators);
71 edgeIngestor.initialize();
73 edgePropsConfiguration.setEdgePropsDir("src/test/resources/oxm/edge-props");
74 edgeLoader = new OxmEdgeRulesLoader(aaiConfigTranslator, edgeIngestor, edgePropsConfiguration);
75 vertexLoader = new OxmSchemaLoader(aaiConfigTranslator, nodeIngestor);