configurable param resolution
[ccsdk/sli/plugins.git] / restapi-call-node / provider / src / test / org / onap / ccsdk / sli / plugins / restapicall / TestRestapiCallNode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  * reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.ccsdk.sli.plugins.restapicall;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27
28 import java.util.HashMap;
29 import java.util.Map;
30 import org.junit.Rule;
31 import org.junit.Test;
32 import org.junit.contrib.java.lang.system.EnvironmentVariables;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
35 import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 public class TestRestapiCallNode {
40
41     @SuppressWarnings("unused")
42     private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class);
43     @Rule
44     public EnvironmentVariables environmentVariables = new EnvironmentVariables();
45     
46
47
48     @Test
49     public void testDelete() throws SvcLogicException {
50         SvcLogicContext ctx = new SvcLogicContext();
51
52         Map<String, String> p = new HashMap<>();
53         p.put("restapiUrl", "https://echo.getpostman.com/delete");
54         p.put("restapiUser", "user1");
55         p.put("restapiPassword", "pwd1");
56         p.put("httpMethod", "delete");
57         p.put("skipSending", "true");
58
59         RestapiCallNode rcn = new RestapiCallNode();
60         rcn.sendRequest(p, ctx);
61     }
62
63     @Test
64     public void testDeleteWithPayload() throws SvcLogicException {
65         SvcLogicContext ctx = new SvcLogicContext();
66
67         ctx.setAttribute("prop.name", "site1");
68
69         Map<String, String> p = new HashMap<>();
70         p.put("templateFileName", "src/test/resources/sdwan-site.json");
71         p.put("restapiUrl", "https://echo.getpostman.com/delete");
72         p.put("restapiUser", "user1");
73         p.put("restapiPassword", "pwd1");
74         p.put("httpMethod", "delete");
75         p.put("skipSending", "true");
76
77         RestapiCallNode rcn = new RestapiCallNode();
78         rcn.sendRequest(p, ctx);
79     }
80
81     @Test
82     public void testJsonTemplate() throws SvcLogicException {
83         SvcLogicContext ctx = new SvcLogicContext();
84         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3");
85         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
86         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
87         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
88         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
89         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
90         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
91         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
92         ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123");
93         ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete");
94         ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0");
95         ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New");
96         ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New");
97         ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1");
98         ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci");
99         ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123");
100         ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete");
101         ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0");
102         ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New");
103         ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New");
104         ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1");
105         ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci");
106
107         Map<String, String> p = new HashMap<>();
108         p.put("templateFileName", "src/test/resources/test-template.json");
109         p.put("restapiUrl", "http://echo.getpostman.com");
110         p.put("restapiUser", "user1");
111         p.put("restapiPassword", "abc123");
112         p.put("format", "json");
113         p.put("httpMethod", "post");
114         p.put("responsePrefix", "response");
115         p.put("skipSending", "true");
116
117         RestapiCallNode rcn = new RestapiCallNode();
118         rcn.sendRequest(p, ctx);
119     }
120
121     @Test
122     public void testInvalidRepeatTimes() throws SvcLogicException {
123         SvcLogicContext ctx = new SvcLogicContext();
124         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a");
125         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
126         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
127         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
128         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
129         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
130         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
131         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
132
133         Map<String, String> p = new HashMap<>();
134         p.put("templateFileName", "src/test/resources/test-template.json");
135         p.put("restapiUrl", "http://echo.getpostman.com");
136         p.put("restapiUser", "user1");
137         p.put("restapiPassword", "abc123");
138         p.put("format", "json");
139         p.put("httpMethod", "post");
140         p.put("responsePrefix", "response");
141         p.put("skipSending", "true");
142
143         RestapiCallNode rcn = new RestapiCallNode();
144         rcn.sendRequest(p, ctx);
145     }
146
147     @Test(expected = SvcLogicException.class)
148     public void testInvalidTemplatePath() throws SvcLogicException {
149         SvcLogicContext ctx = new SvcLogicContext();
150         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
151         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
152         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
153         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
154         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
155         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
156         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
157         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
158
159         Map<String, String> p = new HashMap<>();
160         p.put("templateFileName", "src/test/resourcess/test-template.json");
161         p.put("restapiUrl", "http://echo.getpostman.com");
162         p.put("restapiUser", "user1");
163         p.put("restapiPassword", "abc123");
164         p.put("format", "json");
165         p.put("httpMethod", "post");
166         p.put("responsePrefix", "response");
167         p.put("skipSending", "true");
168
169         RestapiCallNode rcn = new RestapiCallNode();
170         rcn.sendRequest(p, ctx);
171     }
172
173     @Test(expected = SvcLogicException.class)
174     public void testWithoutSkipSending() throws SvcLogicException {
175         SvcLogicContext ctx = new SvcLogicContext();
176         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
177         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
178         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
179         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
180         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
181         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
182         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
183         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
184
185         Map<String, String> p = new HashMap<>();
186         p.put("templateFileName", "src/test/resources/test-template.json");
187         p.put("restapiUrl", "http://echo.getpostman.com");
188         p.put("restapiUser", "user1");
189         p.put("restapiPassword", "abc123");
190         p.put("format", "json");
191         p.put("httpMethod", "post");
192         p.put("responsePrefix", "response");
193         p.put("skipSending", "false");
194
195         RestapiCallNode rcn = new RestapiCallNode();
196         rcn.sendRequest(p, ctx);
197     }
198
199
200     @Test(expected = SvcLogicException.class)
201     public void testWithInvalidURI() throws SvcLogicException {
202         SvcLogicContext ctx = new SvcLogicContext();
203         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
204         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
205         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
206         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
207         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
208         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
209         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
210         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
211
212         Map<String, String> p = new HashMap<>();
213         p.put("templateFileName", "src/test/resources/test-template.json");
214         p.put("restapiUrl", "http://echo.  getpostman.com");
215         p.put("restapiUser", "user1");
216         p.put("restapiPassword", "abc123");
217         p.put("format", "json");
218         p.put("httpMethod", "post");
219         p.put("responsePrefix", "response");
220         p.put("skipSending", "false");
221
222         RestapiCallNode rcn = new RestapiCallNode();
223         rcn.sendRequest(p, ctx);
224     }
225
226     @Test
227     public void testVpnJsonTemplate() throws SvcLogicException {
228         SvcLogicContext ctx = new SvcLogicContext();
229         ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001");
230         ctx.setAttribute("prop.l3vpn.topology", "point_to_point");
231
232         Map<String, String> p = new HashMap<>();
233         p.put("templateFileName", "src/test/resources/l3smvpntemplate.json");
234         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services");
235         p.put("restapiUser", "admin");
236         p.put("restapiPassword", "admin123");
237         p.put("format", "json");
238         p.put("httpMethod", "post");
239         p.put("responsePrefix", "restapi-result");
240         p.put("skipSending", "true");
241
242         RestapiCallNode rcn = new RestapiCallNode();
243         rcn.sendRequest(p, ctx);
244     }
245
246     @Test
247     public void testSiteJsonTemplate() throws SvcLogicException {
248         SvcLogicContext ctx = new SvcLogicContext();
249         ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001");
250         ctx.setAttribute("prop.l3vpn.topology", "point_to_point");
251
252         ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002");
253         ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003");
254         ctx.setAttribute("prop.l3vpn.entry1-id", "1");
255         ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004");
256         ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e");
257         ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b");
258         ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1");
259         ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2");
260         ctx.setAttribute("prop.l3vpn.sna1_svlan", "100");
261         ctx.setAttribute("prop.l3vpn.ac1_protocol", "static");
262         ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24");
263         ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4");
264
265         ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005");
266         ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006");
267         ctx.setAttribute("prop.l3vpn.entry2-id", "1");
268         ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007");
269         ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a");
270         ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c");
271         ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6");
272         ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5");
273         ctx.setAttribute("prop.l3vpn.sna2_svlan", "200");
274         ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp");
275         ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7");
276         ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200");
277
278         Map<String, String> p = new HashMap<>();
279         p.put("templateFileName", "src/test/resources/l3smsitetemplate.json");
280         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites");
281         p.put("restapiUser", "admin");
282         p.put("restapiPassword", "admin123");
283         p.put("format", "json");
284         p.put("httpMethod", "post");
285         p.put("responsePrefix", "restapi-result");
286         p.put("skipSending", "true");
287
288         RestapiCallNode rcn = new RestapiCallNode();
289         rcn.sendRequest(p, ctx);
290     }
291
292     @Test
293     public void testVrfJsonTemplate() throws SvcLogicException {
294         SvcLogicContext ctx = new SvcLogicContext();
295         ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007");
296         ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003");
297         ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e");
298         ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009");
299         ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006");
300         ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a");
301
302         Map<String, String> p = new HashMap<>();
303         p.put("templateFileName", "src/test/resources/l3smvrftemplate.json");
304         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes");
305         p.put("restapiUser", "admin");
306         p.put("restapiPassword", "admin123");
307         p.put("format", "json");
308         p.put("httpMethod", "post");
309         p.put("responsePrefix", "restapi-result");
310         p.put("skipSending", "true");
311
312         RestapiCallNode rcn = new RestapiCallNode();
313         rcn.sendRequest(p, ctx);
314     }
315
316     @Test
317     public void testDeleteVpnJsonTemplate() throws SvcLogicException {
318         SvcLogicContext ctx = new SvcLogicContext();
319         ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001");
320         ctx.setAttribute("prop.l3vpn.topology", "point_to_point");
321
322         Map<String, String> p = new HashMap<>();
323         //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json");
324         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"
325             + "/vpnservice=10000000-0000-0000-0000-000000000001");
326         p.put("restapiUser", "admin");
327         p.put("restapiPassword", "admin123");
328         p.put("format", "json");
329         p.put("httpMethod", "delete");
330         p.put("responsePrefix", "restapi-result");
331         p.put("skipSending", "true");
332
333         RestapiCallNode rcn = new RestapiCallNode();
334         rcn.sendRequest(p, ctx);
335     }
336
337     @Test
338     public void testL2DciTemplate() throws SvcLogicException {
339         SvcLogicContext ctx = new SvcLogicContext();
340         ctx.setAttribute("prop.dci-connects.id", "Id1");
341         ctx.setAttribute("prop.dci-connects.name", "Name1");
342         ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1");
343         ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2");
344         ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1");
345         ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2");
346         ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1");
347         ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2");
348         ctx.setAttribute("prop.dci-connects.vni", "1");
349
350         Map<String, String> p = new HashMap<>();
351         p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json");
352         p.put("restapiUrl", "http://echo.getpostman.com");
353         p.put("restapiUser", "user1");
354         p.put("restapiPassword", "abc123");
355         p.put("format", "json");
356         p.put("httpMethod", "post");
357         p.put("responsePrefix", "response");
358         p.put("skipSending", "true");
359
360         RestapiCallNode rcn = new RestapiCallNode();
361         rcn.sendRequest(p, ctx);
362     }
363
364     @Test
365     public void testL3DciTemplate() throws SvcLogicException {
366         SvcLogicContext ctx = new SvcLogicContext();
367         ctx.setAttribute("prop.dci-connects.id", "Id1");
368         ctx.setAttribute("prop.dci-connects.name", "Name1");
369         ctx.setAttribute("prop.dci-connects.local_networks_length", "2");
370         ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1");
371         ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2");
372         ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1");
373         ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2");
374         ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1");
375         ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2");
376         ctx.setAttribute("prop.dci-connects.vni", "1");
377
378         Map<String, String> p = new HashMap<>();
379         p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json");
380         p.put("restapiUrl", "http://echo.getpostman.com");
381         p.put("restapiUser", "user1");
382         p.put("restapiPassword", "abc123");
383         p.put("format", "json");
384         p.put("httpMethod", "post");
385         p.put("responsePrefix", "response");
386         p.put("skipSending", "true");
387
388         RestapiCallNode rcn = new RestapiCallNode();
389         rcn.sendRequest(p, ctx);
390
391     }
392
393     @Test
394     public void testControllerTokenTemplate() throws SvcLogicException {
395         SvcLogicContext ctx = new SvcLogicContext();
396         ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin");
397         ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123");
398
399         Map<String, String> p = new HashMap<>();
400         p.put("templateFileName", "src/test/resources/actokentemplate.json");
401         p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens");
402         p.put("format", "json");
403         p.put("httpMethod", "post");
404         p.put("responsePrefix", "restapi-result");
405         p.put("skipSending", "true");
406
407         RestapiCallNode rcn = new RestapiCallNode();
408         rcn.sendRequest(p, ctx);
409     }
410
411
412     @Test
413     public void testDeleteNoneAsContentType() throws SvcLogicException {
414         SvcLogicContext ctx = new SvcLogicContext();
415
416         Map<String, String> p = new HashMap<>();
417         p.put("restapiUrl", "https://echo.getpostman.com/delete");
418         p.put("restapiUser", "user1");
419         p.put("restapiPassword", "pwd1");
420         p.put("httpMethod", "delete");
421         p.put("format", "none");
422         p.put("skipSending", "true");
423
424         RestapiCallNode rcn = new RestapiCallNode();
425         rcn.sendRequest(p, ctx);
426     }
427
428     @Test
429     public void testPostNoneAsContentType() throws SvcLogicException {
430         SvcLogicContext ctx = new SvcLogicContext();
431         ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001");
432         ctx.setAttribute("prop.l3vpn.topology", "point_to_point");
433
434         Map<String, String> p = new HashMap<>();
435         p.put("templateFileName", "src/test/resources/l3smvpntemplate.json");
436         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services");
437         p.put("restapiUser", "admin");
438         p.put("restapiPassword", "admin123");
439         p.put("format", "none");
440         p.put("httpMethod", "post");
441         p.put("responsePrefix", "restapi-result");
442         p.put("skipSending", "true");
443
444         RestapiCallNode rcn = new RestapiCallNode();
445         rcn.sendRequest(p, ctx);
446     }
447     /*
448      * {
449   "partnerOne": {
450     "url": "http://localhost:7001"                                                                                                                                                             4 http://uebsb93kcdc.it.att.com:3904",
451     "test": "/metrics"
452   },
453   "partnerTwo": {
454     "url": "http://localhost:7002",
455     "user": "controller_user",
456     "password": "P@ssword",
457     "test": "/metrics"
458   },
459   "partnerThree": {
460     "url": "http://localhost:7003",
461     "user": "controller_admin"
462   }
463 }
464      */
465     @Test
466     public void testPartners() throws Exception{
467
468         environmentVariables.set("deployer_pass", "sdncp-123");
469         assertEquals("sdncp-123", System.getenv("deployer_pass"));
470
471         String partnerTwoKey = "partnerTwo";
472         String partnerTwoUsername = "controller_user";
473         String partnerTwoPassword = "P@ssword";
474
475         System.setProperty("SDNC_CONFIG_DIR", "src/test/resources");
476         RestapiCallNode rcn = new RestapiCallNode();
477         assertNull(rcn.partnerStore.get("partnerOne"));
478         PartnerDetails details = rcn.partnerStore.get(partnerTwoKey);
479         assertEquals(partnerTwoUsername,details.username);
480         assertEquals(partnerTwoPassword,details.password);
481         assertNull(rcn.partnerStore.get("partnerThree"));
482         
483         //In this scenario the caller expects username, password and url to be picked up from the partners json
484         Map<String, String> paramMap = new HashMap<String,String>();
485         paramMap.put("partner", partnerTwoKey);
486         rcn.handlePartner(paramMap );
487         assertEquals(partnerTwoUsername,paramMap.get(rcn.restapiUserKey));
488         assertEquals(partnerTwoPassword,paramMap.get(rcn.restapiPasswordKey));
489         assertEquals("http://localhost:7002",paramMap.get(rcn.restapiUrlString));
490
491         //In this scenario the caller expects username, password and url to be picked up from the partners json
492         //the provided suffix will be appended to the default url from the partners json
493         paramMap = new HashMap<String,String>();
494         paramMap.put("partner", partnerTwoKey);
495         paramMap.put("restapiUrlSuffix", "/networking/v1/instance/3");
496         rcn.handlePartner(paramMap);
497         p = new Parameters();
498         RestapiCallNode.getParameters(paramMap, p);
499         assertEquals(partnerTwoUsername,p.restapiUser);
500         assertEquals(partnerTwoPassword,p.restapiPassword);
501         assertEquals("http://localhost:7002/networking/v1/instance/3",p.restapiUrl);
502
503         paramMap = new HashMap<String, String>();
504         paramMap.put("partner","partnerFour" );
505         paramMap.put("httpMethod", "delete");
506         paramMap.put("skipSending", "true");
507         rcn.handlePartner(paramMap);
508         Parameters p = new Parameters();
509         RestapiCallNode.getParameters(paramMap, p);
510         assertEquals(p.restapiPassword, "sdncp-123");
511         assertEquals(p.restapiUser, "m30402@sdncp.att.com");
512         assertEquals(p.restapiUrl, "http://localhost:7004");
513     }
514     
515     @Test
516     public void retryPolicyBean() throws Exception {
517     Integer retries = 3;
518     String first = "http://localhost:7001";
519     String second = "http://localhost:7001";
520     
521     RetryPolicy p = new RetryPolicy(new String[] {first,second}, retries);
522     assertEquals(retries,p.getMaximumRetries());
523     assertNotNull(p.getRetryMessage());
524     String next = p.getNextHostName();
525     assertEquals(second,next);
526     assertEquals(1,p.getRetryCount());
527     next = p.getNextHostName();
528     assertEquals(first,next);
529     assertEquals(2,p.getRetryCount());
530     }
531 }