2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.audit;
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;
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;
43 import javax.validation.constraints.AssertTrue;
45 import java.io.FileReader;
46 import java.util.List;
48 import java.util.Properties;
50 import static org.junit.Assert.assertTrue;
51 @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
52 public class ListEndpointsTest extends AAISetup {
54 private Properties properties;
55 private SchemaVersion version;
56 private ListEndpoints listEndpoints;
59 public void setUp() throws Exception {
60 properties = new Properties();
61 version = schemaVersions.getDefaultVersion();
62 listEndpoints = new ListEndpoints(basePath, schemaVersions.getDefaultVersion());
66 public void testGetEndpoints() {
67 Assert.assertTrue(listEndpoints != null);
68 List<String> list = listEndpoints.getEndpoints();
69 Assert.assertTrue(list != null && !list.isEmpty());
71 for (String endpoint : list) {
72 System.out.println("endpoints: " + endpoint);
77 public void testGetEndpointsWithParam() {
78 Assert.assertTrue(listEndpoints != null);
79 List<String> list = listEndpoints.getEndpoints();
80 Assert.assertTrue(list != null && !list.isEmpty());
83 @Test(expected = RuntimeException.class)
84 public void testGetEndpoints_throwException() {
85 ListEndpoints listEndpointsFail = new ListEndpoints(basePath, null);
89 public void testGetLogicalNames() {
90 Assert.assertTrue(listEndpoints != null);
91 Map<String, String> map = listEndpoints.getLogicalNames();
92 Assert.assertTrue(map != null && !map.isEmpty());
96 public void testToString() {
97 Assert.assertTrue(listEndpoints != null);
98 String endpoints = listEndpoints.toString();
102 public void testToStrinWithParam() {
103 Assert.assertTrue(listEndpoints != null);
104 String endpoints = listEndpoints.toString("complex");
105 Assert.assertTrue(!endpoints.contains("complex"));