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