Adding UI extensibility
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / dal / aai / config / ActiveInventoryRestConfigTest.java
1 /**
2  * ============LICENSE_START=================================================== SPARKY (AAI UI
3  * service) ============================================================================ Copyright ©
4  * 2017 AT&T Intellectual Property. Copyright © 2017 Amdocs All rights reserved.
5  * ============================================================================ Licensed under the
6  * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software distributed under the License
12  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13  * or implied. See the License for the specific language governing permissions and limitations under
14  * the License. ============LICENSE_END=====================================================
15  *
16  * ECOMP and OpenECOMP are trademarks and service marks of AT&T Intellectual Property.
17  */
18
19 package org.onap.aai.sparky.dal.aai.config;
20 /*
21  * import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import
22  * static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static
23  * org.junit.Assert.assertTrue;
24  * 
25  * import java.util.ArrayList; import java.util.List; import java.util.Properties;
26  * 
27  * import org.junit.Before; import org.junit.Test; import
28  * org.onap.aai.sparky.dal.aai.config.ActiveInventoryRestConfig; import
29  * org.onap.aai.sparky.dal.aai.enums.RestAuthenticationMode;
30  * 
31  * 
32  * public class ActiveInventoryRestConfigTest {
33  * 
34  * /** Test case initialization
35  * 
36  * @throws Exception the exception
37  *
38  * @Before public void init() throws Exception {}
39  * 
40  * private Properties buildExpectedPropertyDefinition() throws Exception {
41  * 
42  * Properties props = new Properties();
43  * 
44  * props.put("aai.rest.resourceBasePath", "/aai/v9"); props.put("aai.rest.host", "1.2.3.4");
45  * props.put("aai.rest.port", "4321"); props.put("aai.rest.numRequestRetries", "100");
46  * props.put("aai.rest.numResolverWorkers", "50"); props.put("aai.rest.maxConcurrentWorkers", "50");
47  * props.put("aai.rest.connectTimeoutInMs", "1000"); props.put("aai.rest.readTimeoutInMs", "1500");
48  * props.put("aai.rest.shallowEntities", "a,b,c,d"); props.put("aai.rest.authenticationMode",
49  * "HTTP_NOAUTH");
50  * 
51  * props.put("aai.rest.cache.enabled", "true"); props.put("aai.rest.cache.storageFolderOverride",
52  * "folderOverride"); props.put("aai.rest.cache.cacheFailures", "true");
53  * props.put("aai.rest.cache.useCacheOnly", "true"); props.put("aai.rest.cache.numWorkers", "50");
54  * props.put("aai.rest.cache.maxTimeToLiveInMs", "500");
55  * 
56  * 
57  * return props; }
58  * 
59  * /** Success path initialization and validation of accessors
60  * 
61  * @throws Exception
62  *
63  * @Test public void successfulInitialization() throws Exception {
64  * 
65  * ActiveInventoryRestConfig config = new
66  * ActiveInventoryRestConfig(buildExpectedPropertyDefinition());
67  * 
68  * /* Now verify that all the internal members have been set to default values
69  *
70  * 
71  * assertEquals(config.getHost(), "1.2.3.4"); assertEquals(config.getPort(), "4321");
72  * assertEquals(config.getNumRequestRetries(), 100); assertEquals(config.getNumResolverWorkers(),
73  * 50); assertEquals(config.getConnectTimeoutInMs(), 1000);
74  * assertEquals(config.getReadTimeoutInMs(), 1500);
75  * 
76  * List<String> expectedEntities = new ArrayList<String>(); expectedEntities.add("a");
77  * expectedEntities.add("b"); expectedEntities.add("c"); expectedEntities.add("d");
78  * 
79  * assertEquals(config.getShallowEntities().size(), 4);
80  * assertTrue(config.getShallowEntities().containsAll(expectedEntities));
81  * assertEquals(config.getAuthenticationMode(), RestAuthenticationMode.HTTP_NOAUTH);
82  * 
83  * }
84  * 
85  * /** Failed path initialization
86  * 
87  * @throws Exception
88  *
89  * @Test public void validateInitializationWithNullProperties() throws Exception {
90  * 
91  * /* Setup encryptor expectations
92  *
93  * 
94  * ActiveInventoryRestConfig config = new ActiveInventoryRestConfig(null);
95  * 
96  * /* Now verify that all the internal members have been set to default values
97  *
98  * 
99  * assertNull(config.getHost()); assertNull(config.getPort());
100  * assertEquals(config.getNumRequestRetries(), 0); assertEquals(config.getNumResolverWorkers(), 0);
101  * assertEquals(config.getConnectTimeoutInMs(), 0); assertEquals(config.getReadTimeoutInMs(), 0);
102  * 
103  * assertNull(config.getShallowEntities()); assertNull(config.getAuthenticationMode());
104  * 
105  * }
106  * 
107  * /** Failed path initialization
108  * 
109  * @throws Exception
110  *
111  * @Test public void validateInitializationWithInvalidProperties() throws Exception {
112  * 
113  * /* Setup encryptor expectations
114  *
115  * 
116  * ActiveInventoryRestConfig config = new
117  * ActiveInventoryRestConfig(ActiveInventoryConfigUtil.getinvalidTestProperties());
118  * 
119  * /* Now verify that all the internal members have been set to default values
120  *
121  * 
122  * assertEquals(config.getHost(), "localhost"); assertEquals(config.getPort(), "8443");
123  * assertEquals(config.getNumRequestRetries(), 5); assertEquals(config.getNumResolverWorkers(), 15);
124  * assertEquals(config.getConnectTimeoutInMs(), 5000); assertEquals(config.getReadTimeoutInMs(),
125  * 10000);
126  * 
127  * assertEquals(config.getShallowEntities().size(), 1); assertEquals(config.getAuthenticationMode(),
128  * RestAuthenticationMode.SSL_CERT);
129  * 
130  * }
131  * 
132  * /** Class accessor validator
133  * 
134  * @throws Exception
135  *
136  * @Test public void validateClassAccessors() throws Exception {
137  * 
138  * /* Setup encryptor expectations
139  *
140  * 
141  * ActiveInventoryRestConfig config = new
142  * ActiveInventoryRestConfig(buildExpectedPropertyDefinition());
143  * 
144  * /* Now verify that all the internal members have been set to default values
145  *
146  * 
147  * config.setAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
148  * config.setConnectTimeoutInMs(1000); config.setHost("myhost"); config.setNumRequestRetries(1500);
149  * config.setNumResolverWorkers(150); config.setPort("11223344"); config.setReadTimeoutInMs(54321);
150  * 
151  * assertEquals(config.getHost(), "myhost"); assertEquals(config.getPort(), "11223344");
152  * assertEquals(config.getNumRequestRetries(), 1500); assertEquals(config.getNumResolverWorkers(),
153  * 150); assertEquals(config.getConnectTimeoutInMs(), 1000);
154  * assertEquals(config.getReadTimeoutInMs(), 54321);
155  * 
156  * List<String> expectedEntities = new ArrayList<String>(); expectedEntities.add("a");
157  * expectedEntities.add("b"); expectedEntities.add("c"); expectedEntities.add("d");
158  * 
159  * assertEquals(config.getShallowEntities().size(), 4);
160  * assertTrue(config.getShallowEntities().containsAll(expectedEntities));
161  * assertTrue(config.isShallowEntity("b")); assertFalse(config.isShallowEntity("f"));
162  * assertFalse(config.isShallowEntity(null)); assertEquals(config.getAuthenticationMode(),
163  * RestAuthenticationMode.SSL_BASIC);
164  * 
165  * assertTrue(config.toString().contains("ActiveInventoryRestConfig"));
166  * 
167  * }
168  * 
169  * 
170  * /** Validate auth mode edge cases
171  * 
172  * @throws Exception
173  *
174  * @Test public void validateUnknownAuthModeDefaultsToSslCert() throws Exception {
175  * 
176  * /* Setup encryptor expectations
177  *
178  * 
179  * Properties props = buildExpectedPropertyDefinition();
180  * props.setProperty("aai.rest.authenticationMode", "invalid mode");
181  * props.setProperty("aai.rest.storageFolderOverride", "");
182  * 
183  * ActiveInventoryRestConfig config = new ActiveInventoryRestConfig(props);
184  * 
185  * /* Now verify that all the internal members have been set to default values
186  *
187  * 
188  * assertNotNull(config.getShallowEntities()); assertEquals(RestAuthenticationMode.SSL_CERT,
189  * config.getAuthenticationMode());
190  * 
191  * }
192  * 
193  * }
194  */