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