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