f4d62d444389d44158325aff87ec07d6cd405fde
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / DataLinkSetup.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.aai;
22
23 import java.util.Map;
24
25 import org.junit.BeforeClass;
26 import org.junit.ClassRule;
27 import org.junit.Rule;
28 import org.onap.aai.config.ConfigConfiguration;
29 import org.onap.aai.config.IntrospectionConfig;
30 import org.onap.aai.config.RestBeanConfig;
31 import org.onap.aai.config.SpringContextAware;
32 import org.onap.aai.edges.EdgeIngestor;
33 import org.onap.aai.introspection.LoaderFactory;
34 import org.onap.aai.introspection.MoxyLoader;
35 import org.onap.aai.nodes.NodeIngestor;
36 import org.onap.aai.rest.db.HttpEntry;
37 import org.onap.aai.serialization.db.EdgeSerializer;
38 import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
39 import org.onap.aai.setup.AAIConfigTranslator;
40 import org.onap.aai.setup.SchemaLocationsBean;
41 import org.onap.aai.setup.SchemaVersion;
42 import org.onap.aai.setup.SchemaVersions;
43 import org.onap.aai.testutils.TestUtilConfigTranslatorforDataLink;
44 import org.onap.aai.util.AAIConstants;
45 import org.springframework.beans.factory.annotation.Autowired;
46 import org.springframework.beans.factory.annotation.Value;
47 import org.springframework.test.annotation.DirtiesContext;
48 import org.springframework.test.context.ContextConfiguration;
49 import org.springframework.test.context.TestPropertySource;
50 import org.springframework.test.context.junit4.rules.SpringClassRule;
51 import org.springframework.test.context.junit4.rules.SpringMethodRule;
52
53 @ContextConfiguration(
54         classes = {ConfigConfiguration.class, TestUtilConfigTranslatorforDataLink.class, EdgeIngestor.class,
55                 EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class, IntrospectionConfig.class,
56                 RestBeanConfig.class})
57 @TestPropertySource(
58         properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000", "schema.version.api.default = v4",
59                 "schema.version.edge.label.start = v4", "schema.version.depth.start = v3",
60                 "schema.version.app.root.start = v4", "schema.version.related.link.start = v4",
61                 "schema.version.namespace.change.start = v4", "schema.version.list = v1,v2,v3,v4",
62                 "schema.translator.list = config"})
63 @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
64 public abstract class DataLinkSetup {
65
66     @ClassRule
67     public static final SpringClassRule springClassRule = new SpringClassRule();
68
69     @Rule
70     public final SpringMethodRule springMethodRule = new SpringMethodRule();
71
72     @Autowired
73     protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
74
75     @Autowired
76     protected HttpEntry traversalHttpEntry;
77
78     @Autowired
79     protected HttpEntry traversalUriHttpEntry;
80
81     @Autowired
82     protected NodeIngestor nodeIngestor;
83
84     @Autowired
85     protected LoaderFactory loaderFactory;
86
87     @Autowired
88     protected SchemaVersions schemaVersions;
89
90     @Value("${schema.uri.base.path}")
91     protected String basePath;
92
93     @Value("${schema.xsd.maxoccurs}")
94     protected String maxOccurs;
95
96     protected static final String SERVICE_NAME = "JUNIT";
97
98     @BeforeClass
99     public static void setupBundleconfig() throws Exception {
100         System.setProperty("AJSC_HOME", ".");
101         System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
102         System.setProperty("aai.service.name", SERVICE_NAME);
103         QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"),
104                 "src/test/resources/bundleconfig-local/etc/oxm/");
105     }
106
107 }