5d6067331cdfacacf17583b1bc63c5aa683f0df2
[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.Test;
26 import org.onap.aai.AAISetup;
27 import org.onap.aai.setup.SchemaVersion;
28 import org.springframework.test.annotation.DirtiesContext;
29
30 import java.util.List;
31 import java.util.Map;
32 import java.util.Properties;
33
34 @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
35 public class ListEndpointsTest extends AAISetup {
36
37     private Properties properties;
38     private SchemaVersion version;
39     private ListEndpoints listEndpoints;
40
41     @Before
42     public void setUp() {
43         properties = new Properties();
44         version = schemaVersions.getDefaultVersion();
45         listEndpoints = new ListEndpoints(basePath, schemaVersions.getDefaultVersion());
46     }
47
48     @Test
49     public void testGetEndpoints() {
50         Assert.assertNotNull(listEndpoints);
51         List<String> list = listEndpoints.getEndpoints();
52         Assert.assertTrue(list != null && !list.isEmpty());
53
54         for (String endpoint : list) {
55             System.out.println("endpoints: " + endpoint);
56         }
57     }
58
59     @Test
60     public void testGetEndpointsWithParam() {
61         Assert.assertNotNull(listEndpoints);
62         List<String> list = listEndpoints.getEndpoints();
63         Assert.assertTrue(list != null && !list.isEmpty());
64     }
65
66     @Test(expected = RuntimeException.class)
67     public void testGetEndpoints_throwException() {
68         new ListEndpoints(basePath, null);
69     }
70
71     @Test
72     public void testGetLogicalNames() {
73         Assert.assertNotNull(listEndpoints);
74         Map<String, String> map = listEndpoints.getLogicalNames();
75         Assert.assertTrue(map != null && !map.isEmpty());
76     }
77
78     @Test
79     public void testToStrinWithParam() {
80         Assert.assertNotNull(listEndpoints);
81         String endpoints = listEndpoints.toString("complex");
82         Assert.assertTrue(!endpoints.contains("complex"));
83     }
84 }