Update schema service to fail to start
[aai/aai-common.git] / aai-schema-ingest / src / test / java / org / onap / aai / setup / SchemaVersionsBeanOverrideTest.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  * <p>
11  * http://www.apache.org/licenses/LICENSE-2.0
12  * <p>
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.setup;
21
22 import org.junit.Rule;
23 import org.junit.Test;
24 import org.junit.rules.ExpectedException;
25 import org.junit.runner.RunWith;
26 import org.onap.aai.restclient.MockProvider;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.boot.test.context.SpringBootTest;
29 import org.springframework.test.context.ContextConfiguration;
30 import org.springframework.test.context.TestPropertySource;
31 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
32
33 import java.io.IOException;
34 import java.util.List;
35
36 import static org.junit.Assert.assertEquals;
37 import static org.junit.Assert.assertNotNull;
38
39 @RunWith(SpringJUnit4ClassRunner.class)
40 @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-override-test.properties" })
41 @ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class, SchemaConfigVersions.class})
42 @SpringBootTest
43 public class SchemaVersionsBeanOverrideTest {
44
45     //set thrown.expect to whatever a specific test needs
46     //this establishes a default of expecting no exceptions to be thrown
47     @Rule
48     public ExpectedException thrown = ExpectedException.none();
49     @Autowired
50     SchemaVersionsBean SchemaVersionsBean;
51
52     @Test
53     public void testGetContextForVersion() throws IOException {
54
55         SchemaVersions versions = SchemaVersionsBean.getSchemaVersions();
56         assertEquals(versions.getDefaultVersion(), new SchemaVersion("v15"));
57     }
58
59     @Test
60     public void testGetVersions() throws IOException {
61
62         List<SchemaVersion> versions = SchemaVersionsBean.getVersions();
63         assertNotNull(versions);
64     }
65
66     @Test
67     public void testGetters() throws IOException {
68         List<SchemaVersion> versionsList = SchemaVersionsBean.getVersions();
69         assertNotNull(versionsList);
70         SchemaVersions versions = SchemaVersionsBean.getSchemaVersions();
71
72         assertEquals(versions.getAppRootVersion(), new SchemaVersion("v11"));
73         assertEquals(versions.getDepthVersion(), new SchemaVersion("v10"));
74         assertEquals(versions.getEdgeLabelVersion(), new SchemaVersion("v12"));
75         assertEquals(versions.getNamespaceChangeVersion(), new SchemaVersion("v11"));
76         assertEquals(versions.getRelatedLinkVersion(), new SchemaVersion("v10"));
77
78     }
79
80 }