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