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