eafffe632b4bc2a3065508a896dfc63889a16335
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / audit / ListEndpointsTest.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.audit;
22
23 import org.junit.Assert;
24 import org.junit.Before;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.junit.rules.ExpectedException;
28 import org.onap.aai.AAISetup;
29 import org.onap.aai.concurrent.AaiCallable;
30 import org.onap.aai.setup.SchemaServiceVersions;
31 import org.onap.aai.setup.SchemaVersion;
32 import org.onap.aai.setup.SchemaVersions;
33 import org.onap.aai.setup.SchemaVersionsBean;
34 import org.slf4j.MDC;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.beans.factory.annotation.Value;
37 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
38 import org.springframework.context.annotation.PropertySource;
39 import org.springframework.stereotype.Component;
40 import org.springframework.test.context.TestPropertySource;
41
42 import javax.validation.constraints.AssertTrue;
43 import java.io.File;
44 import java.io.FileReader;
45 import java.util.List;
46 import java.util.Map;
47 import java.util.Properties;
48
49 import static org.junit.Assert.assertTrue;
50
51 public class ListEndpointsTest extends AAISetup {
52
53     private Properties properties;
54     private SchemaVersion version;
55     private ListEndpoints listEndpoints;
56
57     @Before
58     public void setUp() throws Exception {
59         properties = new Properties();
60         version = schemaVersions.getDefaultVersion();
61         listEndpoints = new ListEndpoints(basePath, schemaVersions.getDefaultVersion());
62     }
63
64     @Test
65     public void testGetEndpoints() {
66         Assert.assertTrue(listEndpoints != null);
67         List<String> list = listEndpoints.getEndpoints();
68         Assert.assertTrue(list != null && !list.isEmpty());
69
70         for (String endpoint : list) {
71             System.out.println("endpoints: " + endpoint);
72         }
73     }
74
75     @Test
76     public void testGetEndpointsWithParam() {
77         Assert.assertTrue(listEndpoints != null);
78         List<String> list = listEndpoints.getEndpoints();
79         Assert.assertTrue(list != null && !list.isEmpty());
80     }
81
82     @Test(expected = RuntimeException.class)
83     public void testGetEndpoints_throwException() {
84         ListEndpoints listEndpointsFail = new ListEndpoints(basePath, null);
85     }
86
87     @Test
88     public void testGetLogicalNames() {
89         Assert.assertTrue(listEndpoints != null);
90         Map<String, String> map = listEndpoints.getLogicalNames();
91         Assert.assertTrue(map != null && !map.isEmpty());
92     }
93
94     @Test
95     public void testToString() {
96         Assert.assertTrue(listEndpoints != null);
97         String endpoints = listEndpoints.toString();
98     }
99
100     @Test
101     public void testToStrinWithParam() {
102         Assert.assertTrue(listEndpoints != null);
103         String endpoints = listEndpoints.toString("complex");
104         Assert.assertTrue(!endpoints.contains("complex"));
105     }
106 }