551c10deca1a92a1e0115b283c3e98e9cde075bc
[aai/schema-service.git] / aai-queries / src / test / java / org / onap / aai / queries / AAISetup.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 package org.onap.aai.queries;
21
22 import org.apache.commons.io.IOUtils;
23 import org.junit.BeforeClass;
24 import org.junit.ClassRule;
25 import org.junit.Rule;
26 import org.onap.aai.config.IntrospectionConfig;
27 import org.onap.aai.config.RestBeanConfig;
28 import org.onap.aai.config.SpringContextAware;
29 import org.onap.aai.edges.EdgeIngestor;
30 import org.onap.aai.introspection.LoaderFactory;
31 import org.onap.aai.introspection.MoxyLoader;
32 import org.onap.aai.nodes.NodeIngestor;
33 import org.onap.aai.rest.db.HttpEntry;
34 import org.onap.aai.serialization.db.EdgeSerializer;
35 import org.onap.aai.setup.AAIConfigTranslator;
36 import org.onap.aai.setup.SchemaLocationsBean;
37 import org.onap.aai.setup.SchemaVersion;
38 import org.onap.aai.setup.SchemaVersions;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.beans.factory.annotation.Value;
41 import org.springframework.test.context.ContextConfiguration;
42 import org.springframework.test.context.TestPropertySource;
43 import org.springframework.test.context.junit4.rules.SpringClassRule;
44 import org.springframework.test.context.junit4.rules.SpringMethodRule;
45
46 import java.io.IOException;
47 import java.io.InputStream;
48 import java.util.Map;
49
50 import static org.junit.Assert.assertNotNull;
51
52 @ContextConfiguration(classes = {
53                 SchemaLocationsBean.class,
54         SchemaVersions.class,
55                 AAIConfigTranslator.class,
56         EdgeIngestor.class,
57         EdgeSerializer.class,
58         NodeIngestor.class,
59         SpringContextAware.class,
60         IntrospectionConfig.class ,
61         RestBeanConfig.class,
62                 GremlinServerSingleton.class
63 })
64 @TestPropertySource(properties = {
65                 "schema.uri.base.path = /aai",
66                 "schema.ingest.file = src/test/resources/application-test.properties"
67 })
68 public abstract class AAISetup {
69         @Autowired
70         protected NodeIngestor nodeIngestor;
71
72         @Autowired
73         protected LoaderFactory loaderFactory;
74
75         @Autowired
76         protected  Map<SchemaVersion, MoxyLoader>  moxyLoaderInstance;
77
78         @Autowired
79         protected HttpEntry traversalHttpEntry;
80
81         @Autowired
82         protected HttpEntry traversalUriHttpEntry;
83
84         @Autowired
85         protected EdgeSerializer edgeSer;
86
87         @Autowired
88         protected EdgeIngestor edgeIngestor;
89
90         @Autowired
91         protected SchemaVersions schemaVersions;
92
93         @Autowired
94         protected GremlinServerSingleton gremlinServerSingleton;
95
96         @Value("${schema.uri.base.path}")
97         protected String basePath;
98
99     @ClassRule
100     public static final SpringClassRule springClassRule = new SpringClassRule();
101
102     @Rule
103     public final SpringMethodRule springMethodRule = new SpringMethodRule();
104
105     @BeforeClass
106     public static void setupBundleconfig() throws Exception {
107         System.setProperty("AJSC_HOME", "./");
108         System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
109
110     }
111
112     public String getPayload(String filename) throws IOException {
113
114         InputStream inputStream = getClass()
115                 .getClassLoader()
116                 .getResourceAsStream(filename);
117
118         String message = String.format("Unable to find the %s in src/test/resources", filename);
119         assertNotNull(message, inputStream);
120
121         String resource = IOUtils.toString(inputStream);
122         return resource;
123     }
124 }
125
126
127
128
129
130
131
132