2 * ============LICENSE_START=======================================================
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
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=========================================================
21 package org.onap.crud;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.HashSet;
26 import java.util.List;
28 import org.junit.Before;
29 import org.mockito.Mock;
30 import org.mockito.Mockito;
31 import org.onap.aai.edges.EdgeIngestor;
32 import org.onap.aai.nodes.NodeIngestor;
33 import org.onap.aai.setup.AAIConfigTranslator;
34 import org.onap.aai.setup.SchemaLocationsBean;
35 import org.onap.aai.setup.SchemaVersion;
36 import org.onap.aai.setup.SchemaVersions;
37 import org.onap.aai.setup.Translator;
38 import org.onap.schema.EdgePropsConfiguration;
39 import org.onap.schema.EdgeRulesLoader;
40 import org.onap.schema.OxmModelLoader;
42 public class OXMModelLoaderSetup {
44 private EdgeRulesLoader edgeRulesLoader;
46 private OxmModelLoader oxmModelLoader;
49 private SchemaLocationsBean schemaLocationsBean;
52 private SchemaVersions schemaVersions;
55 private EdgePropsConfiguration edgePropsConfiguration;
57 private List<SchemaVersion> schemaVersionList = new ArrayList<>();
60 public void schemaBeanMockSetup() throws Exception {
62 schemaVersionList.add(new SchemaVersion("v8"));
63 schemaVersionList.add(new SchemaVersion("v9"));
64 schemaVersionList.add(new SchemaVersion("v10"));
65 schemaVersionList.add(new SchemaVersion("v11"));
66 schemaVersionList.add(new SchemaVersion("v13"));
68 Mockito.when(schemaVersions.getVersions()).thenReturn(schemaVersionList);
69 Mockito.when(schemaLocationsBean.getNodesInclusionPattern()).thenReturn(Arrays.asList(".*oxm(.*).xml"));
70 Mockito.when(schemaLocationsBean.getEdgesInclusionPattern()).thenReturn(Arrays.asList("DbEdgeRules_.*.json"));
71 Mockito.when(schemaLocationsBean.getNodeDirectory()).thenReturn("src/test/resources/multi-oxm/");
72 Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/rules/");
73 Mockito.when(edgePropsConfiguration.getEdgePropsDir()).thenReturn("src/test/resources/edgeProps/");
75 AAIConfigTranslator aaiConfigTranslator = new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
76 Set<Translator> translators = new HashSet<>();
77 translators.add(aaiConfigTranslator);
78 NodeIngestor nodeIngestor = new NodeIngestor(translators);
79 nodeIngestor.initialize();
80 EdgeIngestor edgeIngestor = new EdgeIngestor(translators);
81 edgeIngestor.initialize();
82 edgeRulesLoader = new EdgeRulesLoader(aaiConfigTranslator, edgeIngestor, edgePropsConfiguration);
83 oxmModelLoader = new OxmModelLoader(aaiConfigTranslator, nodeIngestor);