Junit coverage increased
[vfc/nfvo/driver/vnfm/svnfm.git] / huawei / vnfmadapter / VnfmadapterService / service / src / test / java / org / onap / vfc / nfvo / vnfm / svnfm / vnfmadapter / service / adapter / impl / AdapterResourceManagerTest.java
1 /*
2  * Copyright 2016-2017 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertTrue;
21
22 import java.io.IOException;
23 import java.lang.reflect.Method;
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulParametes;
30 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.testutils.JsonUtil;
31
32 import net.sf.json.JSONException;
33 import net.sf.json.JSONObject;
34
35 public class AdapterResourceManagerTest {
36
37     AdapterResourceManager manager = null;
38
39     @Before
40     public void setUp() {
41         manager = new AdapterResourceManager();
42     }
43
44     @Test(expected=JSONException.class)
45     public void uploadVNFPackageTestJsonException() {
46         JSONObject vnfpkg = new JSONObject();
47         Map<String, String> paramsMap = new HashMap<>();
48         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
49     }
50     
51      @Test
52     public void uploadVNFPackageTestJsonException1() {
53         JSONObject vnfpkg = new JSONObject();
54         vnfpkg.put("", "");
55         Map<String, String> paramsMap = new HashMap<>();
56         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
57     }
58
59     @Test(expected=JSONException.class)
60     public void uploadVNFPackageTestJsonException2() {
61         Map<String, String> paramsMap = new HashMap<>();
62          manager.uploadVNFPackage(null, paramsMap);
63     }
64
65     @Test
66     public void uploadVNFPackageTestJsonException3() {
67         JSONObject vnfpkg = new JSONObject();
68         vnfpkg.put("name", "test");
69         Map<String, String> paramsMap = new HashMap<>();
70         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
71         assertTrue(res.get("reason").equals("csarid and vnfmid are null."));
72
73     }
74
75     @Test
76     public void uploadVNFPackageTestEmptyParam() {
77         JSONObject vnfpkg = new JSONObject();
78         vnfpkg.put("name", "test");
79         Map<String, String> paramsMap = new HashMap<>();
80         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
81         assertTrue(res.get("reason").equals("csarid and vnfmid are null."));
82
83     }
84
85     @Test(expected=NullPointerException.class)
86     public void uploadVNFPackageTestNullParam() {
87         JSONObject vnfpkg = new JSONObject();
88         vnfpkg.put("name", "test");
89         JSONObject res = manager.uploadVNFPackage(vnfpkg, null);
90         assertTrue(res.get("reason").equals("csarid and vnfmid are null."));
91
92     }
93
94     @Test
95     public void uploadVNFPackageTestInvalidCsrid() {
96         JSONObject vnfpkg = new JSONObject();
97         vnfpkg.put("name", "test");
98         Map<String, String> paramsMap = new HashMap<>();
99         paramsMap.put("csarid", "");
100         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
101         assertTrue(res.get("reason").equals("csarid is null."));
102
103     }
104
105     @Test
106     public void uploadVNFPackageTestInvalidCsrid2() {
107         JSONObject vnfpkg = new JSONObject();
108         vnfpkg.put("name", "test");
109         Map<String, String> paramsMap = new HashMap<>();
110         paramsMap.put("csarid", null);
111         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
112         assertTrue(res.get("reason").equals("csarid is null."));
113
114     }
115
116     @Test
117     public void uploadVNFPackageTestInvalidVnfmid() {
118         JSONObject vnfpkg = new JSONObject();
119         vnfpkg.put("name", "test");
120         Map<String, String> paramsMap = new HashMap<>();
121         paramsMap.put("csarid", "csarid123");
122         paramsMap.put("vnfmid", null);
123         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
124         assertTrue(res.get("reason").equals("vnfmid is null."));
125
126     }
127
128     @Test
129     public void uploadVNFPackageTestInvalidVnfmid2() {
130         JSONObject vnfpkg = new JSONObject();
131         vnfpkg.put("name", "test");
132         Map<String, String> paramsMap = new HashMap<>();
133         paramsMap.put("csarid", "csarid123");
134         paramsMap.put("vnfmid", "");
135         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
136         assertTrue(res.get("reason").equals("vnfmid is null."));
137
138     }
139
140     @Test
141     public void uploadVNFPackageTestNullResp() {
142         JSONObject vnfpkg = new JSONObject();
143         vnfpkg.put("name", "test");
144         Map<String, String> paramsMap = new HashMap<>();
145         paramsMap.put("csarid", "csarid123");
146         paramsMap.put("vnfmid", "vnfmid1234");
147         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
148         assertTrue(res.get("reason").equals("RestfulResponse is null."));
149
150     }
151
152     @Test
153     public void downloadCsarTestNullUrl() {
154         String url = null;
155         String filePath = null;
156         JSONObject res = manager.downloadCsar(url, filePath);
157         assertTrue(res.get("reason").equals("url is null."));
158     }
159
160     @Test
161     public void downloadCsarTestEmptyUrl() {
162         String url = "";
163         String filePath = null;
164         JSONObject res = manager.downloadCsar(url, filePath);
165         assertTrue(res.get("reason").equals("url is null."));
166     }
167
168     @Test
169     public void downloadCsarTestNullFilePath() {
170         String url = "http://localhost:8080";
171         String filePath = null;
172         JSONObject res = manager.downloadCsar(url, filePath);
173         assertTrue(res.get("reason").equals("downloadUrl filePath is null."));
174     }
175
176     @Test
177     public void downloadCsarTestEmptyFilePath() {
178         String url = "http://localhost:8080";
179         String filePath = "";
180         JSONObject res = manager.downloadCsar(url, filePath);
181         assertTrue(res.get("reason").equals("downloadUrl filePath is null."));
182     }
183
184     @Test
185     public void getVnfmConnInfoTestSuccess() {
186 //        new MockUp<VNFRestfulUtil>() {
187 //
188 //            @Mock
189 //            public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
190 //                RestfulResponse resp = new RestfulResponse();
191 //                resp.setStatus(200);
192 //                Map<String, String> objMap = new HashMap<String, String>();
193 //                objMap.put("id", "test123");
194 //
195 //                String responseString = toJson(objMap);
196 //                resp.setResponseJson(responseString);
197 //                return resp;
198 //            }
199 //
200 //        };
201         Map<String, String> paramsMap = new HashMap<String, String>();
202         JSONObject res = manager.getVnfmConnInfo(paramsMap);
203         assertTrue(res.get("id").equals("test123"));
204     }
205
206     @Test
207     public void getVnfmConnInfoTestNullResp() {
208 //        new MockUp<VNFRestfulUtil>() {
209 //
210 //            @Mock
211 //            public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
212 //
213 //                return null;
214 //            }
215 //
216 //        };
217         Map<String, String> paramsMap = new HashMap<String, String>();
218         JSONObject res = manager.getVnfmConnInfo(paramsMap);
219         assertTrue(res.get("reason").equals("RestfulResponse is null."));
220     }
221
222     @Test
223     public void getVnfmConnInfoTestServerError() {
224 //        new MockUp<VNFRestfulUtil>() {
225 //
226 //            @Mock
227 //            public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
228 //                RestfulResponse resp = new RestfulResponse();
229 //                resp.setStatus(500);
230 //                Map<String, String> objMap = new HashMap<String, String>();
231 //                objMap.put("id", "test123");
232 //
233 //                String responseString = toJson(objMap);
234 //                resp.setResponseJson(responseString);
235 //                return resp;
236 //            }
237 //
238 //        };
239         Map<String, String> paramsMap = new HashMap<String, String>();
240         JSONObject res = manager.getVnfmConnInfo(paramsMap);
241         assertTrue(res.get("reason").equals("ESR return fail."));
242     }
243
244     @Test
245     public void uploadTestInternalError() {
246         JSONObject vnfpackage = new JSONObject();
247         String vnfmurl = "http://localhost";
248         String conntoken = "test";
249         JSONObject res = manager.upload(vnfpackage, vnfmurl, conntoken);
250         assertEquals(res.get("retCode"), 500);
251     }
252
253     public static String toJson(Map o) {
254         try {
255             return JsonUtil.marshal(o);
256         } catch(IOException e) {
257             return "";
258         }
259     }
260
261     @Test
262     public void testGetAllCloud(){
263         String url = null;
264         manager.getAllCloud(url,null);
265     }
266
267     @Test
268     public void testGetAllCloud2(){
269         String url = "http://127.0.0.1:31943";
270         manager.getAllCloud(url,null);
271     }
272     @Test
273     public void testUnzipCSAR(){
274         manager.unzipCSAR(null,null);
275     }
276     @Test
277     public void testUnzipCSAR2(){
278         manager.unzipCSAR("vCpe.zip",null);
279     }
280     @Test
281     public void testUnzipCSAR3(){
282         manager.unzipCSAR("vCpe.zip","/opt");
283     }
284     @Test
285     public void testUnzipCSAR4(){
286 //        new MockUp<DownloadCsarManager>(){
287 //            @Mock
288 //            public  int unzipCSAR(String fileName,String filePath){
289 //                return 0;
290 //            }
291 //        };
292         manager.unzipCSAR("vCpe.zip","/opt");
293     }
294     @Test
295     public void testUnzipCSAR5(){
296 //        new MockUp<DownloadCsarManager>(){
297 //            @Mock
298 //            public  int unzipCSAR(String fileName,String filePath){
299 //                return -1;
300 //            }
301 //        };
302         manager.unzipCSAR("vCpe.zip","/opt");
303     }
304
305     @Test
306     public void testGetVnfdVersion(){
307         manager.getVnfdVersion("http://","127.0.0.1","token");
308     }
309
310     @Test(expected=NullPointerException.class)
311     public void testgetVNFDPlanInfoNull(){
312         
313         manager.getVNFDPlanInfo(null, null, null);
314         }
315     
316     @Test
317     public void testgetVNFDPlanInfo(){
318         
319         manager.getVNFDPlanInfo("https://127.0.0.1:80", "vnfd123", "token");
320         }
321     
322     @Test
323     public void testgetVNFDPlanInfoConn(){
324         
325 //      new MockUp<HttpClient>(){
326 //              @Mock
327 //              public int executeMethod(HttpMethod method) {
328 //                  return 200;
329 //              }
330 //          };
331 //      
332 //          new MockUp<HttpMethodBase>(){
333 //              
334 //              @Mock 
335 //               public int getStatusCode(){
336 //                      
337 //                      return 200;
338 //              }
339 //              
340 //              @Mock 
341 //               public String getResponseBodyAsString()
342 //                                 throws IOException
343 //                                {
344 //                      JSONObject jobj = new JSONObject();
345 //                      jobj.put("Status", 200);
346 //                      jobj.put("UserName", "User");
347 //                      jobj.put("password", "pass");
348 //                      String str = jobj.toString();
349 //                      return str;
350 //                                 }
351 //              
352 //          };
353         
354         manager.getVNFDPlanInfo("https://127.0.0.1:80", "vnfd123", "accessSession");
355         }
356     
357     @Test
358     public void testgetVNFDPlanInfoConn500(){
359         
360 //      new MockUp<HttpClient>(){
361 //              @Mock
362 //              public int executeMethod(HttpMethod method) {
363 //                  return 200;
364 //              }
365 //          };
366 //      
367 //          new MockUp<HttpMethodBase>(){
368 //              
369 //              @Mock 
370 //               public int getStatusCode(){
371 //                      
372 //                      return 500;
373 //              }
374 //              
375 //               @Mock 
376 //               public String getResponseBodyAsString()
377 //                                 throws IOException
378 //                                {
379 //                      String str = "Failed";
380 //                      return str;
381 //                                 }
382 //              
383 //          };
384         
385         manager.getVNFDPlanInfo("https://127.0.0.1:80", "vnfd123", "accessSession");
386         }
387     
388     
389     @Test
390     public void testGetVnfdVersion200(){
391         
392 //      new MockUp<HttpClient>(){
393 //              @Mock
394 //              public int executeMethod(HttpMethod method) {
395 //                  return 200;
396 //              }
397 //          };
398 //          
399 //          new MockUp<HttpMethodBase>(){
400 //              
401 //              @Mock 
402 //               public int getStatusCode(){
403 //                      
404 //                      return 200;
405 //              }
406 //              
407 //              @Mock 
408 //               public String getResponseBodyAsString()
409 //                                 throws IOException
410 //                                {
411 //                      JSONObject jobj = new JSONObject();
412 //                      jobj.put("Status", 200);
413 //                      jobj.put("UserName", "User");
414 //                      jobj.put("password", "pass");
415 //                      String str = jobj.toString();
416 //                      return str;
417 //                                 }
418 //              
419 //          };
420             
421             JSONObject jobj = manager.getVnfdVersion("http://","127.0.0.1:80","accessSession");
422     }
423     
424     @Test
425     public void testGetVnfdVersion500(){
426         
427 //      new MockUp<HttpClient>(){
428 //              @Mock
429 //              public int executeMethod(HttpMethod method) {
430 //                  return 200;
431 //              }
432 //          };
433 //          
434 //          new MockUp<HttpMethodBase>(){
435 //              
436 //              @Mock 
437 //               public int getStatusCode(){
438 //                      
439 //                      return 500;
440 //              }
441 //              
442 //          @Mock 
443 //       public String getResponseBodyAsString()
444 //                         throws IOException
445 //                        {
446 //              String str = "Failed";
447 //              return str;
448 //                         }
449 //          };
450             
451         manager.getVnfdVersion("http://","127.0.0.1:80","accessSession");
452     }
453     
454     @Test
455     public void uploadVNFPackageTestcsarid() {
456          RestfulParametes rp = new RestfulParametes();
457          rp.setRawData("success");
458          rp.setRawData("sdjhbfj");
459          HashMap<String,String>  headerMap = new HashMap<String,String>();
460          headerMap.put("Content-Type", "application/json");
461          headerMap.put("X-TransactionId", "5851");
462          rp.setHeaderMap(headerMap);
463          HashMap<String,String>  paramMap = new HashMap<String,String>();
464          paramMap.put("id", "1234");
465          rp.setParamMap(paramMap);
466         JSONObject vnfpkg = new JSONObject();
467         vnfpkg.put("name", "test");
468         vnfpkg.put("Restfulparameters", rp);
469         Map<String, String> paramsMap = new HashMap<>();
470         paramsMap.put("csarid", "csarid200");
471         paramsMap.put("vnfmid", "vnfmid1234");
472         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
473         assertTrue(res.get("reason").equals("RestfulResponse is null."));
474     }
475     
476     @Test
477     public void uploadVNFPackageTestcsaridNull() {
478         JSONObject vnfpkg = new JSONObject();
479         vnfpkg.put("name", "test");
480         Map<String, String> paramsMap = new HashMap<>();
481         paramsMap.put("csarid", "caser200");
482         paramsMap.put("vnfmid", "vnfmid1234");
483         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
484         assertTrue(res.get("reason").equals("RestfulResponse is null."));
485
486     }
487     
488     @Test
489     public void uploadVNFPackageTestParamEmpty() {
490         JSONObject vnfpkg = new JSONObject();
491         vnfpkg.put("name", "test");
492         Map<String, String> paramsMap = new HashMap<>();
493         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
494     }
495     
496     @Test
497     public void downloadCsarTestUrlAndFilePathWrong() {
498         String url = "http://localhost:8080";
499         String filePath = "Tset";
500         JSONObject res = manager.downloadCsar(url, filePath);
501     }
502     @Test
503     public void downloadCsarTestUrlAndFilePath() {
504         String url = "https://127.0.0.1:31943";
505         String filePath = "src/test/resources/Check.txt";
506         JSONObject res = manager.downloadCsar(url, filePath);
507     }
508      
509     @Test
510     public void testGetAllCloudUrlEmpty(){
511         String url = "";
512         manager.getAllCloud(url,null);
513     }
514     
515     @Test
516     public void testGetAllCloudUrlandConn(){
517         String url = "http://127.0.0.1:31943";
518         String conn = "conn";
519         manager.getAllCloud(url,conn);
520     }
521     
522     @Test
523     public void testUnzipCSAREmpty(){
524         manager.unzipCSAR("vCpe.zip","");
525     }
526     @Test
527     public void testUnzipCSAREmpty1(){
528         manager.unzipCSAR("","/opt");
529     }
530     
531     @Test
532     public void readVfnPkgInfoFromJsonTest() throws IOException{
533         
534         System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
535         AdapterResourceManager.readVfnPkgInfoFromJson();
536     }
537     @Test
538     public void readVfnPkgInfoFromJsonTestNumBelowZero() throws IOException{
539         
540         System.setProperty("catalina.base", "C:/Users/Huawei/Desktop");
541         AdapterResourceManager.readVfnPkgInfoFromJson();
542     }
543     
544     @Test
545     public void testGetAllCloudUrlandaccessSession(){
546         
547 //      new MockUp<HttpClient>(){
548 //              @Mock
549 //              public int executeMethod(HttpMethod method) {
550 //                  return 200;
551 //              }
552 //          };
553 //          
554 //          new MockUp<HttpMethodBase>(){
555 //              
556 //              @Mock 
557 //               public int getStatusCode(){
558 //                      
559 //                      return 200;
560 //              }
561 //              
562 //              @Mock 
563 //               public String getResponseBodyAsString()
564 //                                 throws IOException
565 //                                {
566 //                      String str = "{\n\t\"driverInfo\": {\n\t\t\"driverName\": \"hwvnfm\",\n\t\t\"instanceID\": \"hwvnfm-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\"services\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\"support_sys\": [{\n\t\t\t\t\"type\": \"vnfm\",\n\t\t\t\t\"version\": \"V100R001\"\n\t\t\t}]\n\t\t}]\n\t}\n}";
567 //                      JSONObject jobj = new JSONObject();
568 //                      jobj.put("Status", 200);
569 //                      jobj.put("UserName", "User");
570 //                      jobj.put("password", "pass");
571 //                      JSONArray ja = new JSONArray();
572 //                      ja.add(str);
573 //                      jobj.put("vim_info", ja);
574 //                      String str1 = jobj.toString();
575 //                      return str1;
576 //                                 }
577 //              
578 //          };
579             
580             System.setProperty("catalina.base", "C:/Users/Huawei/Desktop");
581         String url = "http://127.0.0.1:31943";
582         String conn = "accessSession";
583         manager.getAllCloud(url,conn);
584     }
585     
586     @Test
587     public void testGetAllCloudUrlandaccessSession500(){
588         
589 //      new MockUp<HttpClient>(){
590 //              @Mock
591 //              public int executeMethod(HttpMethod method) {
592 //                  return 200;
593 //              }
594 //          };
595 //          
596 //          new MockUp<HttpMethodBase>(){
597 //              
598 //              @Mock 
599 //               public int getStatusCode(){
600 //                      
601 //                      return 500;
602 //              }
603 //              
604 //              @Mock 
605 //               public String getResponseBodyAsString()
606 //                                 throws IOException
607 //                                {
608 //                      String str = "Failed";
609 //                      return str;
610 //                                 }
611 //              
612 //          };
613             
614             System.setProperty("catalina.base", "C:/Users/Huawei/Desktop");
615         String url = "http://127.0.0.1:31943";
616         String conn = "accessSession";
617         manager.getAllCloud(url,conn);
618     }
619     
620     @Test
621     public void testUpload(){
622         
623 //      new MockUp<HttpClient>(){
624 //              @Mock
625 //              public int executeMethod(HttpMethod method) {
626 //                  return 200;
627 //              }
628 //          };
629 //          
630 //          new MockUp<HttpMethodBase>(){
631 //              
632 //              @Mock 
633 //               public int getStatusCode(){
634 //                      
635 //                      return 200;
636 //              }
637 //              
638 //              @Mock 
639 //               public String getResponseBodyAsString()
640 //                                 throws IOException
641 //                                {
642 //                      JSONObject jobj = new JSONObject();
643 //                      jobj.put("Status", 200);
644 //                      jobj.put("UserName", "User");
645 //                      jobj.put("password", "pass");
646 //                      String str = jobj.toString();
647 //                      return str;
648 //                                 }
649 //              
650 //          };
651             
652         JSONObject vnfpackage = new JSONObject();
653         vnfpackage.put("UserName", "User");
654         vnfpackage.put("password", "Pass");
655         String vnfmurl = "http://127.0.0.1:31943";
656           String conntoken = "accessSession";
657           System.setProperty("catalina.base", "src/test/resources/");
658         manager.upload(vnfpackage, vnfmurl, conntoken);
659     }
660     
661     @Test
662     public void testUploadNoJson(){
663         
664 //      new MockUp<HttpClient>(){
665 //              @Mock
666 //              public int executeMethod(HttpMethod method) {
667 //                  return 200;
668 //              }
669 //          };
670 //          
671 //          new MockUp<HttpMethodBase>(){
672 //              
673 //              @Mock 
674 //               public int getStatusCode(){
675 //                      
676 //                      return 200;
677 //              }
678 //              
679 //              @Mock 
680 //               public String getResponseBodyAsString()
681 //                                 throws IOException
682 //                                {
683 //                      
684 //                      String str = "Test";
685 //                      return str;
686 //                                 }
687 //              
688 //          };
689             
690         JSONObject vnfpackage = new JSONObject();
691         vnfpackage.put("UserName", "User");
692         vnfpackage.put("password", "Pass");
693         String vnfmurl = "http://127.0.0.1:31943";
694           String conntoken = "accessSession";
695           System.setProperty("catalina.base", "src/test/resources/");
696         manager.upload(vnfpackage, vnfmurl, conntoken);
697     }
698     
699     @Test
700     public void testUpload500(){
701         
702 //      new MockUp<HttpClient>(){
703 //              @Mock
704 //              public int executeMethod(HttpMethod method) {
705 //                  return 200;
706 //              }
707 //          };
708 //          
709 //          new MockUp<HttpMethodBase>(){
710 //              
711 //              @Mock 
712 //               public int getStatusCode(){
713 //                      
714 //                      return 500;
715 //              }
716 //              
717 //              @Mock 
718 //               public String getResponseBodyAsString()
719 //                                 throws IOException
720 //                                {
721 //                      String str = "Failed";
722 //                      return str;
723 //                                 }
724 //              
725 //          };
726             
727         JSONObject vnfpackage = new JSONObject();
728         vnfpackage.put("UserName", "User");
729         vnfpackage.put("password", "Pass");
730         String vnfmurl = "http://127.0.0.1:31943";
731           String conntoken = "accessSession";
732           System.setProperty("catalina.base", "src/test/resources/");
733         manager.upload(vnfpackage, vnfmurl, conntoken);
734     }
735     
736     @Test
737     public void testGetVnfmCsarInfoEmpty(){
738         manager.getVnfmCsarInfo("");
739     }
740     @Test
741     public void testGetVnfmCsarInfoNull(){
742         manager.getVnfmCsarInfo(null);
743     }
744     /*@Test
745     public void testGetVnfmCsarInfo(){
746         manager.getVnfmCsarInfo("casr-id-123");
747     }*/
748     @Test
749     public void downloadCsarTest() {
750         
751 //      new MockUp<DownloadCsarManager>(){
752 //      @Mock
753 //      public String download(String url, String filepath) {
754 //                      return "Success";
755 //      
756 //      }
757 //      };
758         
759         String url = "http://localhost:8080";
760         String filePath = "src/test/resources/Check.txt";
761         JSONObject res = manager.downloadCsar(url, filePath);
762         assertTrue(true);
763     }
764     
765     @Test(expected=JSONException.class)
766     public void uploadVNFPackageTest() {
767         
768 //      new MockUp<VNFRestfulUtil>(){
769 //              @Mock
770 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
771 //                      RestfulResponse rr = new RestfulResponse();
772 //                      Map<String, String> header = new HashMap<>();
773 //                      header.put("Content-Type", "Application/Json");
774 //                      header.put("X-FormId", "jhfdl");
775 //                      rr.setRespHeaderMap(header);
776 //                      rr.setStatus(200);
777 //                      rr.setResponseJson("shdfhj");
778 //                      
779 //                      return rr;
780 //                      
781 //              }
782 //      };
783 //      
784 //      new MockUp<RestfulResponse>(){
785 //              
786 //              @Mock
787 //               public String getResponseContent() {
788 //                      
789 //                              return "Success";
790 //               }
791 //              
792 //      };
793 //      
794 //      new MockUp<JSONObject>(){
795 //      @Mock
796 //      public JSONObject fromObject(Object object){
797 //              JSONObject js = new JSONObject();
798 //              js.put("Result", "Success");
799 //              js.put("Check", "Ok");
800 //              js.put("downloadUri", "http://127.0.0.1:80");
801 //              return js;
802 //      }
803 //      };
804
805         JSONObject vnfpkg = new JSONObject();
806         vnfpkg.put("name", "test");
807         JSONObject obj = new JSONObject();
808         obj.put("csar_file_path", "src/test/resources/Check10.txt");
809         obj.put("csar_file_name", "casrFile");
810         vnfpkg.put("template", obj);
811         Map<String, String> paramsMap = new HashMap<>();
812         paramsMap.put("csarid", "csarid123");
813         paramsMap.put("vnfmid", "vnfmid1234");
814         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
815         assertTrue(true);
816
817     }
818     
819     @Test(expected=JSONException.class)
820     public void uploadVNFPackageTestSuccess() {
821         
822 //      new MockUp<VNFRestfulUtil>(){
823 //              @Mock
824 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
825 //                      RestfulResponse rr = new RestfulResponse();
826 //                      Map<String, String> header = new HashMap<>();
827 //                      header.put("Content-Type", "Application/Json");
828 //                      header.put("X-FormId", "jhfdl");
829 //                      rr.setRespHeaderMap(header);
830 //                      rr.setStatus(200);
831 //                      rr.setResponseJson("shdfhj");
832 //                      
833 //                      return rr;
834 //                      
835 //              }
836 //      };
837 //      
838 //      new MockUp<RestfulResponse>(){
839 //              
840 //              @Mock
841 //               public String getResponseContent() {
842 //                      
843 //                              return "Success";
844 //               }
845 //              
846 //      };
847 //      
848 //      new MockUp<JSONObject>(){
849 //      @Mock
850 //      public JSONObject fromObject(Object object){
851 //              JSONObject js = new JSONObject();
852 //              js.put("Result", "Success");
853 //              js.put("Check", "Ok");
854 //              js.put("downloadUri", "http://127.0.0.1:80");
855 //              return js;
856 //      }
857 //      };
858 //      
859 //      new MockUp<DownloadCsarManager>(){
860 //              @Mock
861 //              public String download(String url, String filepath) {
862 //                      return "Success";
863 //              
864 //              }
865 //              };
866         
867         JSONObject vnfpkg = new JSONObject();
868         vnfpkg.put("name", "test");
869         JSONObject obj = new JSONObject();
870         obj.put("csar_file_path", "src/test/resources/Check10.txt");
871         obj.put("csar_file_name", "casrFile");
872         vnfpkg.put("template", obj);
873         Map<String, String> paramsMap = new HashMap<>();
874         paramsMap.put("csarid", "csarid123");
875         paramsMap.put("vnfmid", "vnfmid1234");
876         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
877         assertTrue(true);
878
879     }
880     
881     @Test(expected=JSONException.class)
882     public void uploadVNFPackageTestSuccessUNZIP() {
883         
884 //      new MockUp<VNFRestfulUtil>(){
885 //              @Mock
886 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
887 //                      RestfulResponse rr = new RestfulResponse();
888 //                      Map<String, String> header = new HashMap<>();
889 //                      header.put("Content-Type", "Application/Json");
890 //                      header.put("X-FormId", "jhfdl");
891 //                      rr.setRespHeaderMap(header);
892 //                      rr.setStatus(200);
893 //                      rr.setResponseJson("shdfhj");
894 //                      
895 //                      return rr;
896 //                      
897 //              }
898 //      };
899 //      
900 //      new MockUp<RestfulResponse>(){
901 //              
902 //              @Mock
903 //               public String getResponseContent() {
904 //                      
905 //                              return "Success";
906 //               }
907 //              
908 //      };
909 //      
910 //      new MockUp<JSONObject>(){
911 //      @Mock
912 //      public JSONObject fromObject(Object object){
913 //              JSONObject js = new JSONObject();
914 //              js.put("Result", "Success");
915 //              js.put("Check", "Ok");
916 //              js.put("downloadUri", "http://127.0.0.1:80");
917 //              return js;
918 //      }
919 //      };
920 //      
921 //      new MockUp<DownloadCsarManager>(){
922 //              @Mock
923 //              public String download(String url, String filepath) {
924 //                      return "Success";
925 //              
926 //              }
927 //              };
928 //      
929 //              new MockUp<DownloadCsarManager>(){
930 //              @Mock
931 //               public int unzipCSAR(String fileName, String filePath) {
932 //                              return 0;
933 //              
934 //              }
935 //              };
936                 
937         JSONObject vnfpkg = new JSONObject();
938         vnfpkg.put("name", "test");
939         JSONObject obj = new JSONObject();
940         obj.put("csar_file_path", "src/test/resources/Check10.txt");
941         obj.put("csar_file_name", "casrFile");
942         vnfpkg.put("template", obj);
943         Map<String, String> paramsMap = new HashMap<>();
944         paramsMap.put("csarid", "csarid123");
945         paramsMap.put("vnfmid", "vnfmid1234");
946         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
947         assertTrue(res.get("reason").equals("RestfulResponse is null."));
948
949     }
950     
951     @Test(expected=JSONException.class)
952     public void uploadVNFPackageTestSuccessUNZIPFTPSClient() {
953         
954 //      new MockUp<VNFRestfulUtil>(){
955 //              @Mock
956 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
957 //                      RestfulResponse rr = new RestfulResponse();
958 //                      Map<String, String> header = new HashMap<>();
959 //                      header.put("Content-Type", "Application/Json");
960 //                      header.put("X-FormId", "jhfdl");
961 //                      rr.setRespHeaderMap(header);
962 //                      rr.setStatus(200);
963 //                      rr.setResponseJson("shdfhj");
964 //                      
965 //                      return rr;
966 //                      
967 //              }
968 //      };
969 //      
970 //      new MockUp<RestfulResponse>(){
971 //              
972 //              @Mock
973 //               public String getResponseContent() {
974 //                      
975 //                              return "Success";
976 //               }
977 //              
978 //      };
979 //      
980 //      new MockUp<JSONObject>(){
981 //      @Mock
982 //      public JSONObject fromObject(Object object){
983 //              JSONObject js = new JSONObject();
984 //              js.put("Result", "Success");
985 //              js.put("Check", "Ok");
986 //              js.put("downloadUri", "http://127.0.0.1:80");
987 //              return js;
988 //      }
989 //      };
990 //      
991 //      new MockUp<DownloadCsarManager>(){
992 //              @Mock
993 //              public String download(String url, String filepath) {
994 //                      return "Success";
995 //              
996 //              }
997 //              };
998 //      
999 //              new MockUp<DownloadCsarManager>(){
1000 //              @Mock
1001 //               public int unzipCSAR(String fileName, String filePath) {
1002 //                              return 0;
1003 //              
1004 //              }
1005 //              };
1006                 
1007         JSONObject vnfpkg = new JSONObject();
1008         vnfpkg.put("name", "test");
1009         JSONObject obj = new JSONObject();
1010         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1011         obj.put("csar_file_name", "casrFile");
1012         obj.put("ftp_server_ip", "https:127.0.0.1:80");
1013         obj.put("ftp_username", "FtpUser");
1014         obj.put("ftp_password", "FtpPass");
1015         vnfpkg.put("template", obj);
1016         Map<String, String> paramsMap = new HashMap<>();
1017         paramsMap.put("csarid", "csarid123");
1018         paramsMap.put("vnfmid", "vnfmid1234");
1019         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1020         assertTrue(res.get("reason").equals("RestfulResponse is null."));
1021
1022     }
1023     
1024     @Test(expected=JSONException.class)
1025     public void uploadVNFPackageTestSuccessUNZIPWithUrl() {
1026         
1027 //      new MockUp<VNFRestfulUtil>(){
1028 //              @Mock
1029 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1030 //                      RestfulResponse rr = new RestfulResponse();
1031 //                      Map<String, String> header = new HashMap<>();
1032 //                      header.put("Content-Type", "Application/Json");
1033 //                      header.put("X-FormId", "jhfdl");
1034 //                      rr.setRespHeaderMap(header);
1035 //                      rr.setStatus(200);
1036 //                      rr.setResponseJson("shdfhj");
1037 //                      
1038 //                      return rr;
1039 //                      
1040 //              }
1041 //      };
1042 //      
1043 //      new MockUp<RestfulResponse>(){
1044 //              
1045 //              @Mock
1046 //               public String getResponseContent() {
1047 //                      
1048 //                              return "Success";
1049 //               }
1050 //              
1051 //      };
1052 //      
1053 //      new MockUp<DownloadCsarManager>(){
1054 //              @Mock
1055 //              public String download(String url, String filepath) {
1056 //                      return "Success";
1057 //              
1058 //              }
1059 //              };
1060 //              new MockUp<JSONObject>(){
1061 //              @Mock
1062 //              public JSONObject fromObject(Object object){
1063 //                      JSONObject js = new JSONObject();
1064 //                      js.put("Result", "Success");
1065 //                      js.put("Check", "Ok");
1066 //                      js.put("url", "http://localhost:80");
1067 //                      js.put("userName", "User");
1068 //                      js.put("password", "pass");
1069 //                      js.put("downloadUri", "http://127.0.0.1:80");
1070 //                      return js;
1071 //              }
1072 //              };
1073 //              
1074 //              new MockUp<DownloadCsarManager>(){
1075 //              @Mock
1076 //               public int unzipCSAR(String fileName, String filePath) {
1077 //                              return 0;
1078 //              
1079 //              }
1080 //              };
1081                 
1082         JSONObject vnfpkg = new JSONObject();
1083         vnfpkg.put("name", "test");
1084         JSONObject obj = new JSONObject();
1085         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1086         obj.put("csar_file_name", "casrFile");
1087         vnfpkg.put("template", obj);
1088         Map<String, String> paramsMap = new HashMap<>();
1089         paramsMap.put("csarid", "csarid123");
1090         paramsMap.put("vnfmid", "vnfmid1234");
1091         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1092         assertTrue(true);
1093
1094     }
1095     
1096     
1097     @Test
1098     public void uploadVNFPackageTestSuccessUNZIP1() {
1099         
1100 //      new MockUp<RestfulResponse>(){
1101 //              
1102 //              @Mock
1103 //               public String getResponseContent() {
1104 //                      
1105 //                              return "Success";
1106 //               }
1107 //              
1108 //      };
1109 //      
1110 //      new MockUp<DownloadCsarManager>(){
1111 //              @Mock
1112 //              public String download(String url, String filepath) {
1113 //                      return "Success";
1114 //              
1115 //              }
1116 //              };
1117 //              new MockUp<JSONObject>(){
1118 //              @Mock
1119 //              public JSONObject fromObject(Object object){
1120 //                      JSONObject js = new JSONObject();
1121 //                      js.put("Result", "Success");
1122 //                      js.put("Check", "Ok");
1123 //                      js.put("downloadUri", "http://127.0.0.1:80");
1124 //                      return js;
1125 //              }
1126 //              };
1127 //              
1128 //              new MockUp<DownloadCsarManager>(){
1129 //              @Mock
1130 //               public int unzipCSAR(String fileName, String filePath) {
1131 //                              return 0;
1132 //              
1133 //              }
1134 //              };
1135                 
1136         JSONObject vnfpkg = new JSONObject();
1137         vnfpkg.put("name", "test");
1138         JSONObject obj = new JSONObject();
1139         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1140         obj.put("csar_file_name", "casrFile");
1141         vnfpkg.put("template", obj);
1142         Map<String, String> paramsMap = new HashMap<>();
1143         paramsMap.put("csarid", "csarid123");
1144         paramsMap.put("vnfmid", "vnfmid1234");
1145         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1146         assertTrue(res.get("reason").equals("RestfulResponse is null."));
1147
1148     }
1149     
1150     @Test(expected=JSONException.class)
1151     public void uploadVNFPackageTestSuccessConnect() {
1152         
1153 //      new MockUp<VNFRestfulUtil>(){
1154 //              @Mock
1155 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1156 //                      RestfulResponse rr = new RestfulResponse();
1157 //                      Map<String, String> header = new HashMap<>();
1158 //                      header.put("Content-Type", "Application/Json");
1159 //                      header.put("X-FormId", "jhfdl");
1160 //                      rr.setRespHeaderMap(header);
1161 //                      rr.setStatus(200);
1162 //                      rr.setResponseJson("shdfhj");
1163 //                      
1164 //                      return rr;
1165 //                      
1166 //              }
1167 //      };
1168 //      
1169 //      new MockUp<RestfulResponse>(){
1170 //              
1171 //              @Mock
1172 //               public String getResponseContent() {
1173 //                      
1174 //                              return "Success";
1175 //               }
1176 //              
1177 //      };
1178 //      
1179 //      new MockUp<DownloadCsarManager>(){
1180 //              @Mock
1181 //              public String download(String url, String filepath) {
1182 //                      return "Success";
1183 //              
1184 //              }
1185 //              };
1186 //              new MockUp<JSONObject>(){
1187 //              @Mock
1188 //              public JSONObject fromObject(Object object){
1189 //                      JSONObject js = new JSONObject();
1190 //                      js.put("Result", "Success");
1191 //                      js.put("Check", "Ok");
1192 //                      js.put("url", "http://localhost:80");
1193 //                      js.put("userName", "User");
1194 //                      js.put("password", "pass");
1195 //                      js.put("downloadUri", "http://127.0.0.1:80");
1196 //                      return js;
1197 //              }
1198 //              };
1199 //              
1200 //              new MockUp<DownloadCsarManager>(){
1201 //              @Mock
1202 //               public int unzipCSAR(String fileName, String filePath) {
1203 //                              return 0;
1204 //              
1205 //              }
1206 //              };
1207 //              
1208 //              new MockUp<ConnectMgrVnfm>(){
1209 //                      
1210 //                      @Mock
1211 //                       public int connect(JSONObject vnfmObj, String authModel) {
1212 //                              
1213 //                              authModel = "accessSession";
1214 //                              return 200;
1215 //                      }
1216 //                      
1217 //              };
1218                 
1219         JSONObject vnfpkg = new JSONObject();
1220         vnfpkg.put("name", "test");
1221         JSONObject obj = new JSONObject();
1222         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1223         obj.put("csar_file_name", "casrFile");
1224         vnfpkg.put("template", obj);
1225         Map<String, String> paramsMap = new HashMap<>();
1226         paramsMap.put("csarid", "csarid123");
1227         paramsMap.put("vnfmid", "vnfmid1234");
1228         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1229         assertTrue(true);
1230
1231     }
1232     
1233     @Test(expected=JSONException.class)
1234     public void uploadVNFPackageTestSuccessConnectPath() {
1235         
1236 //      new MockUp<VNFRestfulUtil>(){
1237 //              @Mock
1238 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1239 //                      RestfulResponse rr = new RestfulResponse();
1240 //                      Map<String, String> header = new HashMap<>();
1241 //                      header.put("Content-Type", "Application/Json");
1242 //                      header.put("X-FormId", "jhfdl");
1243 //                      rr.setRespHeaderMap(header);
1244 //                      rr.setStatus(200);
1245 //                      rr.setResponseJson("shdfhj");
1246 //                      
1247 //                      return rr;
1248 //                      
1249 //              }
1250 //      };
1251 //      
1252 //      new MockUp<RestfulResponse>(){
1253 //              
1254 //              @Mock
1255 //               public String getResponseContent() {
1256 //                      
1257 //                              return "Success";
1258 //               }
1259 //              
1260 //      };
1261 //      
1262 //      new MockUp<DownloadCsarManager>(){
1263 //              @Mock
1264 //              public String download(String url, String filepath) {
1265 //                      return "Success";
1266 //              
1267 //              }
1268 //              };
1269 //              new MockUp<JSONObject>(){
1270 //              @Mock
1271 //              public JSONObject fromObject(Object object){
1272 //                      JSONObject js = new JSONObject();
1273 //                      js.put("Result", "Success");
1274 //                      js.put("Check", "Ok");
1275 //                      js.put("url", "http://localhost:80");
1276 //                      js.put("userName", "User");
1277 //                      js.put("password", "pass");
1278 //                      js.put("downloadUri", "http://127.0.0.1:80");
1279 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1280 //                      js.put("keyStorePass", "Changeme_123");
1281 //                      js.put("keyStoreType", "PKCS12");
1282 //                      JSONArray ja = new JSONArray();
1283 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1284 //                      ja.add(str);
1285 //                      js.put("vim_info", ja);
1286 //                      return js;
1287 //              }
1288 //              };
1289 //              
1290 //              new MockUp<DownloadCsarManager>(){
1291 //              @Mock
1292 //               public int unzipCSAR(String fileName, String filePath) {
1293 //                              return 0;
1294 //              
1295 //              }
1296 //              };
1297 //              
1298 //              new MockUp<ConnectMgrVnfm>(){
1299 //                      
1300 //                      @Mock
1301 //                       public int connect(JSONObject vnfmObj, String authModel) {
1302 //                              vnfmObj.put("connToken", "accessSession");
1303 //                              vnfmObj.put("Content-Type", "Application/Json");
1304 //                              authModel = "accessSession";
1305 //                              return 200;
1306 //                      }
1307 //                      
1308 //              };
1309 //              
1310 //              new MockUp<HttpClient>(){
1311 //                      @Mock
1312 //                      public int executeMethod(HttpMethod method) {
1313 //                          return 200;
1314 //                      }
1315 //                  };
1316 //                  
1317 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1318 //              
1319 //               new MockUp<HttpMethodBase>(){
1320 //                      
1321 //                      @Mock 
1322 //                       public int getStatusCode(){
1323 //                              
1324 //                              return 200;
1325 //                      }
1326 //                      
1327 //                      @Mock 
1328 //                       public String getResponseBodyAsString()
1329 //                                         throws IOException
1330 //                                        {
1331 //                              String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1332 //                              JSONObject jobj = new JSONObject();
1333 //                              jobj.put("Status", 200);
1334 //                              jobj.put("UserName", "User");
1335 //                              jobj.put("password", "pass");
1336 //                              JSONArray ja = new JSONArray();
1337 //                              ja.add(str);
1338 //                              jobj.put("vim_info", ja);
1339 //                              String str1 = jobj.toString();
1340 //                              return str1;
1341 //                                         }
1342 //                  };
1343                 
1344         JSONObject vnfpkg = new JSONObject();
1345         vnfpkg.put("name", "test");
1346         JSONObject obj = new JSONObject();
1347         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1348         obj.put("csar_file_name", "casrFile");
1349         vnfpkg.put("template", obj);
1350         Map<String, String> paramsMap = new HashMap<>();
1351         paramsMap.put("csarid", "csarid123");
1352         paramsMap.put("vnfmid", "vnfmid1234");
1353         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1354         assertTrue(res.get("reason").equals("RestfulResponse is null."));
1355
1356     }
1357     
1358     @Test(expected=JSONException.class)
1359     public void uploadVNFPackageTestSuccessConnectPath500() {
1360 //      
1361 //      new MockUp<VNFRestfulUtil>(){
1362 //              @Mock
1363 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1364 //                      RestfulResponse rr = new RestfulResponse();
1365 //                      Map<String, String> header = new HashMap<>();
1366 //                      header.put("Content-Type", "Application/Json");
1367 //                      header.put("X-FormId", "jhfdl");
1368 //                      rr.setRespHeaderMap(header);
1369 //                      rr.setStatus(200);
1370 //                      rr.setResponseJson("shdfhj");
1371 //                      
1372 //                      return rr;
1373 //                      
1374 //              }
1375 //      };
1376 //      
1377 //      new MockUp<RestfulResponse>(){
1378 //              
1379 //              @Mock
1380 //               public String getResponseContent() {
1381 //                      
1382 //                              return "Success";
1383 //               }
1384 //              
1385 //      };
1386 //      
1387 //      new MockUp<DownloadCsarManager>(){
1388 //              @Mock
1389 //              public String download(String url, String filepath) {
1390 //                      return "Success";
1391 //              
1392 //              }
1393 //              };
1394 //              new MockUp<JSONObject>(){
1395 //              @Mock
1396 //              public JSONObject fromObject(Object object){
1397 //                      JSONObject js = new JSONObject();
1398 //                      js.put("Result", "Success");
1399 //                      js.put("Check", "Ok");
1400 //                      js.put("url", "http://localhost:80");
1401 //                      js.put("userName", "User");
1402 //                      js.put("password", "pass");
1403 //                      js.put("downloadUri", "http://127.0.0.1:80");
1404 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1405 //                      js.put("keyStorePass", "Changeme_123");
1406 //                      js.put("keyStoreType", "PKCS12");
1407 //                      JSONArray ja = new JSONArray();
1408 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1409 //                      ja.add(str);
1410 //                      js.put("vim_info", ja);
1411 //                      return js;
1412 //              }
1413 //              };
1414 //              
1415 //              new MockUp<DownloadCsarManager>(){
1416 //              @Mock
1417 //               public int unzipCSAR(String fileName, String filePath) {
1418 //                              return 0;
1419 //              
1420 //              }
1421 //              };
1422 //              
1423 //              new MockUp<ConnectMgrVnfm>(){
1424 //                      
1425 //                      @Mock
1426 //                       public int connect(JSONObject vnfmObj, String authModel) {
1427 //                              vnfmObj.put("connToken", "accessSession");
1428 //                              vnfmObj.put("Content-Type", "Application/Json");
1429 //                              authModel = "accessSession";
1430 //                              return 200;
1431 //                      }
1432 //                      
1433 //              };
1434 //              
1435 //              new MockUp<HttpClient>(){
1436 //                      @Mock
1437 //                      public int executeMethod(HttpMethod method) {
1438 //                          return 200;
1439 //                      }
1440 //                  };
1441 //                  
1442 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1443 //              
1444 //               new MockUp<HttpMethodBase>(){
1445 //                      
1446 //                      @Mock 
1447 //                       public int getStatusCode(){
1448 //                              
1449 //                              return 500;
1450 //                      }
1451 //                      
1452 //                      @Mock 
1453 //                       public String getResponseBodyAsString()
1454 //                                         throws IOException
1455 //                                        {
1456 //                              String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1457 //                              JSONObject jobj = new JSONObject();
1458 //                              jobj.put("Status", 500);
1459 //                              jobj.put("UserName", "User");
1460 //                              jobj.put("password", "pass");
1461 //                              JSONArray ja = new JSONArray();
1462 //                              ja.add(str);
1463 //                              jobj.put("vim_info", ja);
1464 //                              String str1 = jobj.toString();
1465 //                              return str1;
1466 //                                         }
1467 //                  };
1468                 
1469         JSONObject vnfpkg = new JSONObject();
1470         vnfpkg.put("name", "test");
1471         JSONObject obj = new JSONObject();
1472         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1473         obj.put("csar_file_name", "casrFile");
1474         vnfpkg.put("template", obj);
1475         Map<String, String> paramsMap = new HashMap<>();
1476         paramsMap.put("csarid", "csarid123");
1477         paramsMap.put("vnfmid", "vnfmid1234");
1478         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1479         assertTrue(true);
1480
1481     }
1482     
1483     @Test(expected=JSONException.class)
1484     public void uploadVNFPackageTestSuccessConnectPathEmpty() {
1485         
1486 //      new MockUp<VNFRestfulUtil>(){
1487 //              @Mock
1488 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1489 //                      RestfulResponse rr = new RestfulResponse();
1490 //                      Map<String, String> header = new HashMap<>();
1491 //                      header.put("Content-Type", "Application/Json");
1492 //                      header.put("X-FormId", "jhfdl");
1493 //                      rr.setRespHeaderMap(header);
1494 //                      rr.setStatus(200);
1495 //                      rr.setResponseJson("shdfhj");
1496 //                      
1497 //                      return rr;
1498 //                      
1499 //              }
1500 //      };
1501 //      
1502 //      new MockUp<RestfulResponse>(){
1503 //              
1504 //              @Mock
1505 //               public String getResponseContent() {
1506 //                      
1507 //                              return "Success";
1508 //               }
1509 //              
1510 //      };
1511 //      
1512 //      new MockUp<DownloadCsarManager>(){
1513 //              @Mock
1514 //              public String download(String url, String filepath) {
1515 //                      return "Success";
1516 //              
1517 //              }
1518 //              };
1519 //              new MockUp<JSONObject>(){
1520 //              @Mock
1521 //              public JSONObject fromObject(Object object){
1522 //                      JSONObject js = new JSONObject();
1523 //                      js.put("Result", "Success");
1524 //                      js.put("Check", "Ok");
1525 //                      js.put("url", "http://localhost:80");
1526 //                      js.put("userName", "User");
1527 //                      js.put("password", "pass");
1528 //                      js.put("downloadUri", "http://127.0.0.1:80");
1529 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1530 //                      js.put("keyStorePass", "Changeme_123");
1531 //                      js.put("keyStoreType", "PKCS12");
1532 //                      JSONArray ja = new JSONArray();
1533 //                      String str = "{\n\"vim_id\": \"\",\n\t\t\"vim-info\": \"1\",\n\t\t\"vim-name\": \"\"\n}";
1534 //                      ja.add(str);
1535 //                      js.put("vim_info", ja);
1536 //                      return js;
1537 //              }
1538 //              };
1539 //              
1540 //              new MockUp<DownloadCsarManager>(){
1541 //              @Mock
1542 //               public int unzipCSAR(String fileName, String filePath) {
1543 //                              return 0;
1544 //              
1545 //              }
1546 //              };
1547 //              
1548 //              new MockUp<ConnectMgrVnfm>(){
1549 //                      
1550 //                      @Mock
1551 //                       public int connect(JSONObject vnfmObj, String authModel) {
1552 //                              vnfmObj.put("connToken", "accessSession");
1553 //                              vnfmObj.put("Content-Type", "Application/Json");
1554 //                              authModel = "accessSession";
1555 //                              return 200;
1556 //                      }
1557 //                      
1558 //              };
1559 //              
1560 //              new MockUp<HttpClient>(){
1561 //                      @Mock
1562 //                      public int executeMethod(HttpMethod method) {
1563 //                          return 200;
1564 //                      }
1565 //                  };
1566 //                  
1567 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1568 //              
1569 //               new MockUp<HttpMethodBase>(){
1570 //                      
1571 //                      @Mock 
1572 //                       public int getStatusCode(){
1573 //                              
1574 //                              return 200;
1575 //                      }
1576 //                      
1577 //                      @Mock 
1578 //                       public String getResponseBodyAsString()
1579 //                                         throws IOException
1580 //                                        {
1581 //                              String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1582 //                              JSONObject jobj = new JSONObject();
1583 //                              jobj.put("Status", 200);
1584 //                              jobj.put("UserName", "User");
1585 //                              jobj.put("password", "pass");
1586 //                              JSONArray ja = new JSONArray();
1587 //                              ja.add(str);
1588 //                              jobj.put("vim_info", ja);
1589 //                              String str1 = jobj.toString();
1590 //                              return str1;
1591 //                                         }
1592 //                  };
1593                 
1594         JSONObject vnfpkg = new JSONObject();
1595         vnfpkg.put("name", "test");
1596         JSONObject obj = new JSONObject();
1597         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1598         obj.put("csar_file_name", "casrFile");
1599         vnfpkg.put("template", obj);
1600         Map<String, String> paramsMap = new HashMap<>();
1601         paramsMap.put("csarid", "csarid123");
1602         paramsMap.put("vnfmid", "vnfmid1234");
1603         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1604         assertTrue(res.get("reason").equals("RestfulResponse is null."));
1605
1606     }
1607     @Test(expected=JSONException.class)
1608     public void uploadVNFPackageTestSuccessId() {
1609         
1610 //      new MockUp<VNFRestfulUtil>(){
1611 //              @Mock
1612 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1613 //                      RestfulResponse rr = new RestfulResponse();
1614 //                      Map<String, String> header = new HashMap<>();
1615 //                      header.put("Content-Type", "Application/Json");
1616 //                      header.put("X-FormId", "jhfdl");
1617 //                      rr.setRespHeaderMap(header);
1618 //                      rr.setStatus(200);
1619 //                      rr.setResponseJson("shdfhj");
1620 //                      
1621 //                      return rr;
1622 //                      
1623 //              }
1624 //      };
1625 //      
1626 //      new MockUp<RestfulResponse>(){
1627 //              
1628 //              @Mock
1629 //               public String getResponseContent() {
1630 //                      
1631 //                              return "Success";
1632 //               }
1633 //              
1634 //      };
1635 //      
1636 //      new MockUp<DownloadCsarManager>(){
1637 //              @Mock
1638 //              public String download(String url, String filepath) {
1639 //                      return "Success";
1640 //              
1641 //              }
1642 //              };
1643 //              new MockUp<JSONObject>(){
1644 //              @Mock
1645 //              public JSONObject fromObject(Object object){
1646 //                      JSONObject js = new JSONObject();
1647 //                      js.put("id", "upload-id-123");
1648 //                      js.put("Result", "Success");
1649 //                      js.put("Check", "Ok");
1650 //                      js.put("url", "http://localhost:80");
1651 //                      js.put("userName", "User");
1652 //                      js.put("password", "pass");
1653 //                      js.put("downloadUri", "http://127.0.0.1:80");
1654 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1655 //                      js.put("keyStorePass", "Changeme_123");
1656 //                      js.put("keyStoreType", "PKCS12");
1657 //                      JSONArray ja = new JSONArray();
1658 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1659 //                      ja.add(str);
1660 //                      js.put("vim_info", ja);
1661 //                      return js;
1662 //              }
1663 //              };
1664 //              
1665 //              new MockUp<DownloadCsarManager>(){
1666 //              @Mock
1667 //               public int unzipCSAR(String fileName, String filePath) {
1668 //                              return 0;
1669 //              
1670 //              }
1671 //              };
1672 //              
1673 //              new MockUp<ConnectMgrVnfm>(){
1674 //                      
1675 //                      @Mock
1676 //                       public int connect(JSONObject vnfmObj, String authModel) {
1677 //                              vnfmObj.put("connToken", "accessSession");
1678 //                              vnfmObj.put("Content-Type", "Application/Json");
1679 //                              authModel = "accessSession";
1680 //                              return 200;
1681 //                      }
1682 //                      
1683 //              };
1684 //              
1685 //              new MockUp<HttpClient>(){
1686 //                      @Mock
1687 //                      public int executeMethod(HttpMethod method) {
1688 //                          return 200;
1689 //                      }
1690 //                  };
1691 //                  
1692 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1693 //              
1694 //               new MockUp<HttpMethodBase>(){
1695 //                      
1696 //                      @Mock 
1697 //                       public int getStatusCode(){
1698 //                              
1699 //                              return 200;
1700 //                      }
1701 //                      
1702 //                      @Mock 
1703 //                       public String getResponseBodyAsString()
1704 //                                         throws IOException
1705 //                                        {
1706 //                              String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1707 //                              JSONObject jobj = new JSONObject();
1708 //                              jobj.put("Status", 200);
1709 //                              jobj.put("UserName", "User");
1710 //                              jobj.put("password", "pass");
1711 //                              JSONArray ja = new JSONArray();
1712 //                              ja.add(str);
1713 //                              jobj.put("vim_info", ja);
1714 //                              String str1 = jobj.toString();
1715 //                              return str1;
1716 //                                         }
1717 //                  };
1718                 
1719         JSONObject vnfpkg = new JSONObject();
1720         vnfpkg.put("name", "test");
1721         JSONObject obj = new JSONObject();
1722         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1723         obj.put("csar_file_name", "casrFile");
1724         vnfpkg.put("template", obj);
1725         Map<String, String> paramsMap = new HashMap<>();
1726         paramsMap.put("csarid", "csarid123");
1727         paramsMap.put("vnfmid", "vnfmid1234");
1728         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1729         assertTrue(res.get("reason").equals("RestfulResponse is null."));
1730
1731     }
1732     @Test(expected=JSONException.class)
1733     public void uploadVNFPackageTestSuccessIdNull() {
1734         
1735 //      new MockUp<VNFRestfulUtil>(){
1736 //              @Mock
1737 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1738 //                      RestfulResponse rr = new RestfulResponse();
1739 //                      Map<String, String> header = new HashMap<>();
1740 //                      header.put("Content-Type", "Application/Json");
1741 //                      header.put("X-FormId", "jhfdl");
1742 //                      rr.setRespHeaderMap(header);
1743 //                      rr.setStatus(200);
1744 //                      rr.setResponseJson("shdfhj");
1745 //                      
1746 //                      return rr;
1747 //                      
1748 //              }
1749 //      };
1750 //      
1751 //      new MockUp<RestfulResponse>(){
1752 //              
1753 //              @Mock
1754 //               public String getResponseContent() {
1755 //                      
1756 //                              return "Success";
1757 //               }
1758 //              
1759 //      };
1760 //      
1761 //      new MockUp<DownloadCsarManager>(){
1762 //              @Mock
1763 //              public String download(String url, String filepath) {
1764 //                      return "Success";
1765 //              
1766 //              }
1767 //              };
1768 //              new MockUp<JSONObject>(){
1769 //              @Mock
1770 //              public JSONObject fromObject(Object object){
1771 //                      JSONObject js = new JSONObject();
1772 //                      js.put("id", null);
1773 //                      js.put("Result", "Success");
1774 //                      js.put("Check", "Ok");
1775 //                      js.put("url", "http://localhost:80");
1776 //                      js.put("userName", "User");
1777 //                      js.put("password", "pass");
1778 //                      js.put("downloadUri", "http://127.0.0.1:80");
1779 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1780 //                      js.put("keyStorePass", "Changeme_123");
1781 //                      js.put("keyStoreType", "PKCS12");
1782 //                      JSONArray ja = new JSONArray();
1783 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1784 //                      ja.add(str);
1785 //                      js.put("vim_info", ja);
1786 //                      return js;
1787 //              }
1788 //              };
1789 //              
1790 //              new MockUp<DownloadCsarManager>(){
1791 //              @Mock
1792 //               public int unzipCSAR(String fileName, String filePath) {
1793 //                              return 0;
1794 //              
1795 //              }
1796 //              };
1797 //              
1798 //              new MockUp<ConnectMgrVnfm>(){
1799 //                      
1800 //                      @Mock
1801 //                       public int connect(JSONObject vnfmObj, String authModel) {
1802 //                              vnfmObj.put("connToken", "accessSession");
1803 //                              vnfmObj.put("Content-Type", "Application/Json");
1804 //                              authModel = "accessSession";
1805 //                              return 200;
1806 //                      }
1807 //                      
1808 //              };
1809 //              
1810 //              new MockUp<HttpClient>(){
1811 //                      @Mock
1812 //                      public int executeMethod(HttpMethod method) {
1813 //                          return 200;
1814 //                      }
1815 //                  };
1816 //                  
1817 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1818 //              
1819 //               new MockUp<HttpMethodBase>(){
1820 //                      
1821 //                      @Mock 
1822 //                       public int getStatusCode(){
1823 //                              
1824 //                              return 200;
1825 //                      }
1826 //                      
1827 //                      @Mock 
1828 //                       public String getResponseBodyAsString()
1829 //                                         throws IOException
1830 //                                        {
1831 //                              String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1832 //                              JSONObject jobj = new JSONObject();
1833 //                              jobj.put("Status", 200);
1834 //                              jobj.put("UserName", "User");
1835 //                              jobj.put("password", "pass");
1836 //                              JSONArray ja = new JSONArray();
1837 //                              ja.add(str);
1838 //                              jobj.put("vim_info", ja);
1839 //                              String str1 = jobj.toString();
1840 //                              return str1;
1841 //                                         }
1842 //                  };
1843 //              
1844         JSONObject vnfpkg = new JSONObject();
1845         vnfpkg.put("name", "test");
1846         JSONObject obj = new JSONObject();
1847         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1848         obj.put("csar_file_name", "casrFile");
1849         vnfpkg.put("template", obj);
1850         Map<String, String> paramsMap = new HashMap<>();
1851         paramsMap.put("csarid", "csarid123");
1852         paramsMap.put("vnfmid", "vnfmid1234");
1853         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1854         assertTrue(res.get("reason").equals("RestfulResponse is null."));
1855
1856     }
1857     @Test(expected=JSONException.class)
1858     public void uploadVNFPackageTestSuccessIdFile0() {
1859         
1860 //      new MockUp<VNFRestfulUtil>(){
1861 //              @Mock
1862 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1863 //                      RestfulResponse rr = new RestfulResponse();
1864 //                      Map<String, String> header = new HashMap<>();
1865 //                      header.put("Content-Type", "Application/Json");
1866 //                      header.put("X-FormId", "jhfdl");
1867 //                      rr.setRespHeaderMap(header);
1868 //                      rr.setStatus(200);
1869 //                      rr.setResponseJson("shdfhj");
1870 //                      
1871 //                      return rr;
1872 //                      
1873 //              }
1874 //      };
1875 //      
1876 //      new MockUp<RestfulResponse>(){
1877 //              
1878 //              @Mock
1879 //               public String getResponseContent() {
1880 //                      
1881 //                              return "Success";
1882 //               }
1883 //              
1884 //      };
1885 //      
1886 //      new MockUp<DownloadCsarManager>(){
1887 //              @Mock
1888 //              public String download(String url, String filepath) {
1889 //                      return "Success";
1890 //              
1891 //              }
1892 //              };
1893 //              new MockUp<JSONObject>(){
1894 //              @Mock
1895 //              public JSONObject fromObject(Object object){
1896 //                      JSONObject js = new JSONObject();
1897 //                      js.put("id", "");
1898 //                      js.put("Result", "Success");
1899 //                      js.put("Check", "Ok");
1900 //                      js.put("url", "http://localhost:80");
1901 //                      js.put("userName", "User");
1902 //                      js.put("password", "pass");
1903 //                      js.put("downloadUri", "http://127.0.0.1:80");
1904 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/Check10.txt");
1905 //                      js.put("keyStorePass", "Changeme_123");
1906 //                      js.put("keyStoreType", "PKCS12");
1907 //                      JSONArray ja = new JSONArray();
1908 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1909 //                      ja.add(str);
1910 //                      js.put("vim_info", ja);
1911 //                      return js;
1912 //              }
1913 //              };
1914 //              
1915 //              new MockUp<DownloadCsarManager>(){
1916 //              @Mock
1917 //               public int unzipCSAR(String fileName, String filePath) {
1918 //                              return 0;
1919 //              
1920 //              }
1921 //              };
1922 //              
1923 //              new MockUp<ConnectMgrVnfm>(){
1924 //                      
1925 //                      @Mock
1926 //                       public int connect(JSONObject vnfmObj, String authModel) {
1927 //                              vnfmObj.put("connToken", "accessSession");
1928 //                              vnfmObj.put("Content-Type", "Application/Json");
1929 //                              authModel = "accessSession";
1930 //                              return 200;
1931 //                      }
1932 //                      
1933 //              };
1934 //              
1935 //              new MockUp<HttpClient>(){
1936 //                      @Mock
1937 //                      public int executeMethod(HttpMethod method) {
1938 //                          return 200;
1939 //                      }
1940 //                  };
1941 //                  
1942 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1943 //              
1944 //               new MockUp<HttpMethodBase>(){
1945 //                      
1946 //                      @Mock 
1947 //                       public int getStatusCode(){
1948 //                              
1949 //                              return 200;
1950 //                      }
1951 //                      
1952 //                      @Mock 
1953 //                       public String getResponseBodyAsString()
1954 //                                         throws IOException
1955 //                                        {
1956 //                              String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1957 //                              JSONObject jobj = new JSONObject();
1958 //                              jobj.put("Status", 200);
1959 //                              jobj.put("UserName", "User");
1960 //                              jobj.put("password", "pass");
1961 //                              JSONArray ja = new JSONArray();
1962 //                              ja.add(str);
1963 //                              jobj.put("vim_info", ja);
1964 //                              String str1 = jobj.toString();
1965 //                              return str1;
1966 //                                         }
1967 //                  };
1968                 
1969         JSONObject vnfpkg = new JSONObject();
1970         vnfpkg.put("name", "test");
1971         JSONObject obj = new JSONObject();
1972         obj.put("csar_file_path", "src/test/resources/Check10.txt");
1973         obj.put("csar_file_name", "casrFile");
1974         vnfpkg.put("template", obj);
1975         Map<String, String> paramsMap = new HashMap<>();
1976         paramsMap.put("csarid", "csarid123");
1977         paramsMap.put("vnfmid", "vnfmid1234");
1978         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1979         assertTrue(res.get("reason").equals("RestfulResponse is null."));
1980
1981     }
1982     
1983     @Test(expected=JSONException.class)
1984     public void uploadVNFPackageTestSuccessId500() {
1985         
1986 //      new MockUp<VNFRestfulUtil>(){
1987 //              @Mock
1988 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1989 //                      RestfulResponse rr = new RestfulResponse();
1990 //                      Map<String, String> header = new HashMap<>();
1991 //                      header.put("Content-Type", "Application/Json");
1992 //                      header.put("X-FormId", "jhfdl");
1993 //                      rr.setRespHeaderMap(header);
1994 //                      rr.setStatus(200);
1995 //                      rr.setResponseJson("shdfhj");
1996 //                      
1997 //                      return rr;
1998 //                      
1999 //              }
2000 //      };
2001 //      
2002 //      new MockUp<RestfulResponse>(){
2003 //              
2004 //              @Mock
2005 //               public String getResponseContent() {
2006 //                      
2007 //                              return "Success";
2008 //               }
2009 //              
2010 //      };
2011 //      
2012 //      new MockUp<DownloadCsarManager>(){
2013 //              @Mock
2014 //              public String download(String url, String filepath) {
2015 //                      return "Success";
2016 //              
2017 //              }
2018 //              };
2019 //              new MockUp<JSONObject>(){
2020 //              @Mock
2021 //              public JSONObject fromObject(Object object){
2022 //                      JSONObject js = new JSONObject();
2023 //                      js.put("id", "upload-id-123");
2024 //                      js.put("Result", "Success");
2025 //                      js.put("Check", "Ok");
2026 //                      js.put("url", "http://localhost:80");
2027 //                      js.put("userName", "User");
2028 //                      js.put("password", "pass");
2029 //                      js.put("downloadUri", "http://127.0.0.1:80");
2030 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2031 //                      js.put("keyStorePass", "Changeme_123");
2032 //                      js.put("keyStoreType", "PKCS12");
2033 //                      JSONArray ja = new JSONArray();
2034 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2035 //                      ja.add(str);
2036 //                      js.put("vim_info", ja);
2037 //                      return js;
2038 //              }
2039 //              };
2040 //              
2041 //              new MockUp<DownloadCsarManager>(){
2042 //              @Mock
2043 //               public int unzipCSAR(String fileName, String filePath) {
2044 //                              return 0;
2045 //              
2046 //              }
2047 //              };
2048 //              
2049 //              new MockUp<ConnectMgrVnfm>(){
2050 //                      
2051 //                      @Mock
2052 //                       public int connect(JSONObject vnfmObj, String authModel) {
2053 //                              vnfmObj.put("connToken", "accessSession");
2054 //                              vnfmObj.put("Content-Type", "Application/Json");
2055 //                              authModel = "accessSession";
2056 //                              return 200;
2057 //                      }
2058 //                      
2059 //              };
2060 //              
2061 //              new MockUp<HttpClient>(){
2062 //                      @Mock
2063 //                      public int executeMethod(HttpMethod method) {
2064 //                          return 200;
2065 //                      }
2066 //                  };
2067 //                  
2068 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2069 //              
2070         JSONObject vnfpkg = new JSONObject();
2071         vnfpkg.put("name", "test");
2072         JSONObject obj = new JSONObject();
2073         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2074         obj.put("csar_file_name", "casrFile");
2075         vnfpkg.put("template", obj);
2076         Map<String, String> paramsMap = new HashMap<>();
2077         paramsMap.put("csarid", "csarid123");
2078         paramsMap.put("vnfmid", "vnfmid1234");
2079         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2080         assertTrue(true);
2081
2082     }
2083     
2084     @Test(expected=JSONException.class)
2085     public void uploadVNFPackageTestSuccessIdEmpty() {
2086         
2087 //      new MockUp<VNFRestfulUtil>(){
2088 //              @Mock
2089 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2090 //                      RestfulResponse rr = new RestfulResponse();
2091 //                      Map<String, String> header = new HashMap<>();
2092 //                      header.put("Content-Type", "Application/Json");
2093 //                      header.put("X-FormId", "jhfdl");
2094 //                      rr.setRespHeaderMap(header);
2095 //                      rr.setStatus(200);
2096 //                      rr.setResponseJson("shdfhj");
2097 //                      
2098 //                      return rr;
2099 //                      
2100 //              }
2101 //      };
2102 //      
2103 //      new MockUp<RestfulResponse>(){
2104 //              
2105 //              @Mock
2106 //               public String getResponseContent() {
2107 //                      
2108 //                              return "Success";
2109 //               }
2110 //              
2111 //      };
2112 //      
2113 //      new MockUp<DownloadCsarManager>(){
2114 //              @Mock
2115 //              public String download(String url, String filepath) {
2116 //                      return "Success";
2117 //              
2118 //              }
2119 //              };
2120 //              new MockUp<JSONObject>(){
2121 //              @Mock
2122 //              public JSONObject fromObject(Object object){
2123 //                      JSONObject js = new JSONObject();
2124 //                      js.put("id", "");
2125 //                      js.put("Result", "Success");
2126 //                      js.put("Check", "Ok");
2127 //                      js.put("url", "http://localhost:80");
2128 //                      js.put("userName", "User");
2129 //                      js.put("password", "pass");
2130 //                      js.put("downloadUri", "http://127.0.0.1:80");
2131 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2132 //                      js.put("keyStorePass", "Changeme_123");
2133 //                      js.put("keyStoreType", "PKCS12");
2134 //                      JSONArray ja = new JSONArray();
2135 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2136 //                      ja.add(str);
2137 //                      js.put("vim_info", ja);
2138 //                      return js;
2139 //              }
2140 //              };
2141 //              
2142 //              new MockUp<DownloadCsarManager>(){
2143 //              @Mock
2144 //               public int unzipCSAR(String fileName, String filePath) {
2145 //                              return 0;
2146 //              
2147 //              }
2148 //              };
2149 //              
2150 //              new MockUp<ConnectMgrVnfm>(){
2151 //                      
2152 //                      @Mock
2153 //                       public int connect(JSONObject vnfmObj, String authModel) {
2154 //                              vnfmObj.put("connToken", "accessSession");
2155 //                              vnfmObj.put("Content-Type", "Application/Json");
2156 //                              authModel = "accessSession";
2157 //                              return 200;
2158 //                      }
2159 //                      
2160 //              };
2161 //              
2162 //              new MockUp<HttpClient>(){
2163 //                      @Mock
2164 //                      public int executeMethod(HttpMethod method) {
2165 //                          return 200;
2166 //                      }
2167 //                  };
2168 //                  
2169 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2170 //              
2171         JSONObject vnfpkg = new JSONObject();
2172         vnfpkg.put("name", "test");
2173         JSONObject obj = new JSONObject();
2174         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2175         obj.put("csar_file_name", "casrFile");
2176         vnfpkg.put("template", obj);
2177         Map<String, String> paramsMap = new HashMap<>();
2178         paramsMap.put("csarid", "csarid123");
2179         paramsMap.put("vnfmid", "vnfmid1234");
2180         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2181         assertTrue(res.get("reason").equals("RestfulResponse is null."));
2182
2183     }
2184     
2185     @Test(expected=JSONException.class)
2186     public void uploadVNFPackageTestSuccessTemplete() {
2187         
2188 //      new MockUp<VNFRestfulUtil>(){
2189 //              @Mock
2190 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2191 //                      RestfulResponse rr = new RestfulResponse();
2192 //                      Map<String, String> header = new HashMap<>();
2193 //                      header.put("Content-Type", "Application/Json");
2194 //                      header.put("X-FormId", "jhfdl");
2195 //                      rr.setRespHeaderMap(header);
2196 //                      rr.setStatus(200);
2197 //                      rr.setResponseJson("shdfhj");
2198 //                      
2199 //                      return rr;
2200 //                      
2201 //              }
2202 //      };
2203 //      
2204 //      new MockUp<RestfulResponse>(){
2205 //              
2206 //              @Mock
2207 //               public String getResponseContent() {
2208 //                      
2209 //                              return "Success";
2210 //               }
2211 //              
2212 //      };
2213 //      
2214 //      new MockUp<DownloadCsarManager>(){
2215 //              @Mock
2216 //              public String download(String url, String filepath) {
2217 //                      return "Success";
2218 //              
2219 //              }
2220 //              };
2221 //              new MockUp<JSONObject>(){
2222 //              @Mock
2223 //              public JSONObject fromObject(Object object){
2224 //                      JSONObject js = new JSONObject();
2225 //                      js.put("id", "upload-id-123");
2226 //                      js.put("Result", "Success");
2227 //                      js.put("Check", "Ok");
2228 //                      js.put("url", "http://localhost:80");
2229 //                      js.put("userName", "User");
2230 //                      js.put("password", "pass");
2231 //                      js.put("downloadUri", "http://127.0.0.1:80");
2232 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2233 //                      js.put("keyStorePass", "Changeme_123");
2234 //                      js.put("keyStoreType", "PKCS12");
2235 //                      JSONArray ja = new JSONArray();
2236 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2237 //                      ja.add(str);
2238 //                      JSONArray ja1 = new JSONArray();
2239 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2240 //                      ja1.add(str1);
2241 //                      js.put("vim_info", ja);
2242 //                      js.put("templates", ja1);
2243 //                      return js;
2244 //              }
2245 //              };
2246 //              
2247 //              new MockUp<DownloadCsarManager>(){
2248 //              @Mock
2249 //               public int unzipCSAR(String fileName, String filePath) {
2250 //                              return 0;
2251 //              
2252 //              }
2253 //              };
2254 //              
2255 //              new MockUp<ConnectMgrVnfm>(){
2256 //                      
2257 //                      @Mock
2258 //                       public int connect(JSONObject vnfmObj, String authModel) {
2259 //                              vnfmObj.put("connToken", "accessSession");
2260 //                              vnfmObj.put("Content-Type", "Application/Json");
2261 //                              authModel = "accessSession";
2262 //                              return 200;
2263 //                      }
2264 //                      
2265 //              };
2266 //              
2267 //              new MockUp<HttpClient>(){
2268 //                      @Mock
2269 //                      public int executeMethod(HttpMethod method) {
2270 //                          return 200;
2271 //                      }
2272 //                  };
2273 //                  
2274 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2275                 
2276         JSONObject vnfpkg = new JSONObject();
2277         vnfpkg.put("name", "test");
2278         JSONObject obj = new JSONObject();
2279         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2280         obj.put("csar_file_name", "casrFile");
2281         vnfpkg.put("template", obj);
2282         Map<String, String> paramsMap = new HashMap<>();
2283         paramsMap.put("csarid", "csarid123");
2284         paramsMap.put("vnfmid", "vnfmid1234");
2285         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2286         assertTrue(res.get("reason").equals("RestfulResponse is null."));
2287
2288     }
2289     
2290     @Test(expected=JSONException.class)
2291     public void uploadVNFPackageTestSuccessTempleteForVPlan() {
2292         
2293 //      new MockUp<VNFRestfulUtil>(){
2294 //              @Mock
2295 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2296 //                      RestfulResponse rr = new RestfulResponse();
2297 //                      Map<String, String> header = new HashMap<>();
2298 //                      header.put("Content-Type", "Application/Json");
2299 //                      header.put("X-FormId", "jhfdl");
2300 //                      rr.setRespHeaderMap(header);
2301 //                      rr.setStatus(200);
2302 //                      rr.setResponseJson("shdfhj");
2303 //                      
2304 //                      return rr;
2305 //                      
2306 //              }
2307 //      };
2308 //      
2309 //      new MockUp<RestfulResponse>(){
2310 //              
2311 //              @Mock
2312 //               public String getResponseContent() {
2313 //                      
2314 //                              return "Success";
2315 //               }
2316 //              
2317 //      };
2318 //      
2319 //      new MockUp<DownloadCsarManager>(){
2320 //              @Mock
2321 //              public String download(String url, String filepath) {
2322 //                      return "Success";
2323 //              
2324 //              }
2325 //              };
2326 //              new MockUp<JSONObject>(){
2327 //              @Mock
2328 //              public JSONObject fromObject(Object object){
2329 //                      JSONObject js = new JSONObject();
2330 //                      js.put("id", "upload-id-123");
2331 //                      js.put("Result", "Success");
2332 //                      js.put("Check", "Ok");
2333 //                      js.put("url", "http://localhost:80");
2334 //                      js.put("userName", "User");
2335 //                      js.put("password", "pass");
2336 //                      js.put("downloadUri", "http://127.0.0.1:80");
2337 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2338 //                      js.put("keyStorePass", "Changeme_123");
2339 //                      js.put("keyStoreType", "PKCS12");
2340 //                      JSONArray ja = new JSONArray();
2341 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2342 //                      ja.add(str);
2343 //                      JSONArray ja1 = new JSONArray();
2344 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2345 //                      ja1.add(str1);
2346 //                      JSONArray ja2 = new JSONArray();
2347 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2348 //                      ja2.add(str2);
2349 //                      JSONObject jsObject = new JSONObject();
2350 //                      jsObject.put("downloadUrl", "http://localhost:80");
2351 //                      jsObject.put("csarName", "Csar_Check");
2352 //                      js.put("vim_info", ja);
2353 //                      js.put("template", ja2);
2354 //                      js.put("templates", ja1);
2355 //                      js.put("packageInfo", jsObject);
2356 //                      return js;
2357 //              }
2358 //              };
2359 //              
2360 //              new MockUp<DownloadCsarManager>(){
2361 //              @Mock
2362 //               public int unzipCSAR(String fileName, String filePath) {
2363 //                              return 0;
2364 //              
2365 //              }
2366 //              };
2367 //              
2368 //              new MockUp<ConnectMgrVnfm>(){
2369 //                      
2370 //                      @Mock
2371 //                       public int connect(JSONObject vnfmObj, String authModel) {
2372 //                              vnfmObj.put("connToken", "accessSession");
2373 //                              vnfmObj.put("Content-Type", "Application/Json");
2374 //                              authModel = "accessSession";
2375 //                              return 200;
2376 //                      }
2377 //                      
2378 //              };
2379 //              
2380 //              new MockUp<HttpClient>(){
2381 //                      @Mock
2382 //                      public int executeMethod(HttpMethod method) {
2383 //                          return 200;
2384 //                      }
2385 //                  };
2386 //                  
2387 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2388                 
2389         JSONObject vnfpkg = new JSONObject();
2390         vnfpkg.put("name", "test");
2391         JSONObject obj = new JSONObject();
2392         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2393         obj.put("csar_file_name", "casrFile");
2394         vnfpkg.put("template", obj);
2395         Map<String, String> paramsMap = new HashMap<>();
2396         paramsMap.put("csarid", "csarid123");
2397         paramsMap.put("vnfmid", "vnfmid1234");
2398         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2399         assertTrue(res.get("reason").equals("RestfulResponse is null."));
2400
2401     }
2402     
2403
2404     
2405     @Test
2406     public void uploadVNFPackageTestParamMapEmpty() {
2407         
2408         JSONObject vnfpkg = new JSONObject();
2409         vnfpkg.put("name", "test");
2410         JSONObject obj = new JSONObject();
2411         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2412         obj.put("csar_file_name", "casrFile");
2413         vnfpkg.put("template", obj);
2414         Map<String, String> paramsMap = new HashMap<>();
2415         paramsMap.put("", "");
2416         paramsMap.put("", "");
2417         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2418         assertTrue(true);
2419  
2420     }
2421     
2422     @Test
2423     public void uploadVNFPackageTestVnfpkgEmpty() {
2424         
2425          JSONObject vnfpkg = new JSONObject();
2426          vnfpkg.put("", "");
2427          JSONObject obj = new JSONObject();
2428          obj.put("csar_file_path", "src/test/resources/Check10.txt");
2429          obj.put("csar_file_name", "casrFile");
2430          vnfpkg.put("template", obj);
2431          Map<String, String> paramsMap = new HashMap<>();
2432          paramsMap.put("csarid", "csarid123");
2433          paramsMap.put("vnfmid", "vnfmid1234");
2434          JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2435          assertTrue(true);
2436  
2437     }
2438     
2439         @Test
2440     public void readScaleInVmIdFromJsonTest() {
2441         
2442         System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2443         AdapterResourceManager.readScaleInVmIdFromJson();
2444     }
2445         
2446         @Test
2447     public void readScaleInVmIdFromJsonTestNoFile() {
2448         
2449                 System.setProperty("catalina.base", "src/test/resources");
2450         AdapterResourceManager.readScaleInVmIdFromJson();
2451     }
2452         
2453     @Test(expected=JSONException.class)
2454     public void uploadVNFPackageTestWithCscf() {
2455         
2456 //      new MockUp<VNFRestfulUtil>(){
2457 //              @Mock
2458 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2459 //                      RestfulResponse rr = new RestfulResponse();
2460 //                      Map<String, String> header = new HashMap<>();
2461 //                      header.put("Content-Type", "Application/Json");
2462 //                      header.put("X-FormId", "jhfdl");
2463 //                      rr.setRespHeaderMap(header);
2464 //                      rr.setStatus(200);
2465 //                      rr.setResponseJson("shdfhj");
2466 //                      
2467 //                      return rr;
2468 //                      
2469 //              }
2470 //      };
2471 //      
2472 //      new MockUp<RestfulResponse>(){
2473 //              
2474 //              @Mock
2475 //               public String getResponseContent() {
2476 //                      
2477 //                              return "Success";
2478 //               }
2479 //              
2480 //      };
2481 //      
2482 //      new MockUp<DownloadCsarManager>(){
2483 //              @Mock
2484 //              public String download(String url, String filepath) {
2485 //                      return "Success";
2486 //              
2487 //              }
2488 //              };
2489 //              new MockUp<JSONObject>(){
2490 //              @Mock
2491 //              public JSONObject fromObject(Object object){
2492 //                      JSONObject js = new JSONObject();
2493 //                      js.put("id", "upload-id-123");
2494 //                      js.put("Result", "Success");
2495 //                      js.put("Check", "Ok");
2496 //                      js.put("url", "http://localhost:80");
2497 //                      js.put("userName", "User");
2498 //                      js.put("password", "pass");
2499 //                      js.put("downloadUri", "http://127.0.0.1:80");
2500 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2501 //                      js.put("keyStorePass", "Changeme_123");
2502 //                      js.put("keyStoreType", "PKCS12");
2503 //                      JSONArray ja = new JSONArray();
2504 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2505 //                      ja.add(str);
2506 //                      JSONArray ja1 = new JSONArray();
2507 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2508 //                      ja1.add(str1);
2509 //                      JSONArray ja2 = new JSONArray();
2510 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2511 //                      ja2.add(str2);
2512 //                      JSONObject jsObject = new JSONObject();
2513 //                      jsObject.put("downloadUrl", "http://localhost:80");
2514 //                      jsObject.put("csarName", "CSCF_SI");
2515 //                      js.put("vim_info", ja);
2516 //                      js.put("template", ja2);
2517 //                      js.put("templates", ja1);
2518 //                      js.put("packageInfo", jsObject);
2519 //                      return js;
2520 //              }
2521 //              };
2522 //              
2523 //              new MockUp<DownloadCsarManager>(){
2524 //              @Mock
2525 //               public int unzipCSAR(String fileName, String filePath) {
2526 //                              return 0;
2527 //              
2528 //              }
2529 //              };
2530 //              
2531 //              new MockUp<ConnectMgrVnfm>(){
2532 //                      
2533 //                      @Mock
2534 //                       public int connect(JSONObject vnfmObj, String authModel) {
2535 //                              vnfmObj.put("connToken", "accessSession");
2536 //                              vnfmObj.put("Content-Type", "Application/Json");
2537 //                              authModel = "accessSession";
2538 //                              return 200;
2539 //                      }
2540 //                      
2541 //              };
2542 //              
2543 //              new MockUp<HttpClient>(){
2544 //                      @Mock
2545 //                      public int executeMethod(HttpMethod method) {
2546 //                          return 200;
2547 //                      }
2548 //                  };
2549 //                  
2550 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2551                 
2552         JSONObject vnfpkg = new JSONObject();
2553         vnfpkg.put("name", "test");
2554         JSONObject obj = new JSONObject();
2555         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2556         obj.put("csar_file_name", "casrFile");
2557         vnfpkg.put("template", obj);
2558         Map<String, String> paramsMap = new HashMap<>();
2559         paramsMap.put("csarid", "csarid123");
2560         paramsMap.put("vnfmid", "vnfmid1234");
2561         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2562         assertTrue(res.get("reason").equals("RestfulResponse is null."));
2563
2564     }
2565
2566     @Test(expected=JSONException.class)
2567     public void uploadVNFPackageTestWithMME() {
2568         
2569 //      new MockUp<VNFRestfulUtil>(){
2570 //              @Mock
2571 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2572 //                      RestfulResponse rr = new RestfulResponse();
2573 //                      Map<String, String> header = new HashMap<>();
2574 //                      header.put("Content-Type", "Application/Json");
2575 //                      header.put("X-FormId", "jhfdl");
2576 //                      rr.setRespHeaderMap(header);
2577 //                      rr.setStatus(200);
2578 //                      rr.setResponseJson("shdfhj");
2579 //                      
2580 //                      return rr;
2581 //                      
2582 //              }
2583 //      };
2584 //      
2585 //              new MockUp<JSONObject>(){
2586 //              @Mock
2587 //              public JSONObject fromObject(Object object){
2588 //                      JSONObject js = new JSONObject();
2589 //                      js.put("id", "upload-id-123");
2590 //                      js.put("Result", "Success");
2591 //                      js.put("Check", "Ok");
2592 //                      js.put("url", "http://localhost:80");
2593 //                      js.put("userName", "User");
2594 //                      js.put("password", "pass");
2595 //                      js.put("downloadUri", "http://127.0.0.1:80");
2596 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2597 //                      js.put("keyStorePass", "Changeme_123");
2598 //                      js.put("keyStoreType", "PKCS12");
2599 //                      JSONArray ja = new JSONArray();
2600 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2601 //                      ja.add(str);
2602 //                      JSONArray ja1 = new JSONArray();
2603 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2604 //                      ja1.add(str1);
2605 //                      JSONArray ja2 = new JSONArray();
2606 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2607 //                      ja2.add(str2);
2608 //                      JSONObject jsObject = new JSONObject();
2609 //                      jsObject.put("downloadUrl", "http://localhost:80");
2610 //                      jsObject.put("csarName", "MME");
2611 //                      js.put("vim_info", ja);
2612 //                      js.put("template", ja2);
2613 //                      js.put("templates", ja1);
2614 //                      js.put("packageInfo", jsObject);
2615 //                      return js;
2616 //              }
2617 //              };
2618 //              
2619 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2620                 
2621         JSONObject vnfpkg = new JSONObject();
2622         vnfpkg.put("name", "test");
2623         JSONObject obj = new JSONObject();
2624         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2625         obj.put("csar_file_name", "casrFile");
2626         vnfpkg.put("template", obj);
2627         Map<String, String> paramsMap = new HashMap<>();
2628         paramsMap.put("csarid", "csarid123");
2629         paramsMap.put("vnfmid", "vnfmid1234");
2630         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2631         assertTrue(res.get("reason").equals("RestfulResponse is null."));
2632
2633     }
2634     
2635     @Test(expected=JSONException.class)
2636     public void uploadVNFPackageTestWithSPGW() {
2637         
2638 //      new MockUp<VNFRestfulUtil>(){
2639 //              @Mock
2640 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2641 //                      RestfulResponse rr = new RestfulResponse();
2642 //                      Map<String, String> header = new HashMap<>();
2643 //                      header.put("Content-Type", "Application/Json");
2644 //                      header.put("X-FormId", "jhfdl");
2645 //                      rr.setRespHeaderMap(header);
2646 //                      rr.setStatus(200);
2647 //                      rr.setResponseJson("shdfhj");
2648 //                      
2649 //                      return rr;
2650 //                      
2651 //              }
2652 //      };
2653 //      
2654 //              new MockUp<JSONObject>(){
2655 //              @Mock
2656 //              public JSONObject fromObject(Object object){
2657 //                      JSONObject js = new JSONObject();
2658 //                      js.put("id", "upload-id-123");
2659 //                      js.put("Result", "Success");
2660 //                      js.put("Check", "Ok");
2661 //                      js.put("url", "http://localhost:80");
2662 //                      js.put("userName", "User");
2663 //                      js.put("password", "pass");
2664 //                      js.put("downloadUri", "http://127.0.0.1:80");
2665 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2666 //                      js.put("keyStorePass", "Changeme_123");
2667 //                      js.put("keyStoreType", "PKCS12");
2668 //                      JSONArray ja = new JSONArray();
2669 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2670 //                      ja.add(str);
2671 //                      JSONArray ja1 = new JSONArray();
2672 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2673 //                      ja1.add(str1);
2674 //                      JSONArray ja2 = new JSONArray();
2675 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2676 //                      ja2.add(str2);
2677 //                      JSONObject jsObject = new JSONObject();
2678 //                      jsObject.put("downloadUrl", "http://localhost:80");
2679 //                      jsObject.put("csarName", "SPGW");
2680 //                      js.put("vim_info", ja);
2681 //                      js.put("template", ja2);
2682 //                      js.put("templates", ja1);
2683 //                      js.put("packageInfo", jsObject);
2684 //                      return js;
2685 //              }
2686 //              };
2687 //              
2688 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2689                 
2690         JSONObject vnfpkg = new JSONObject();
2691         vnfpkg.put("name", "test");
2692         JSONObject obj = new JSONObject();
2693         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2694         obj.put("csar_file_name", "casrFile");
2695         vnfpkg.put("template", obj);
2696         Map<String, String> paramsMap = new HashMap<>();
2697         paramsMap.put("csarid", "csarid123");
2698         paramsMap.put("vnfmid", "vnfmid1234");
2699         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2700         assertTrue(res.get("reason").equals("RestfulResponse is null."));
2701
2702     }
2703     
2704     @Test(expected=JSONException.class)
2705     public void uploadVNFPackageTestWithHSS() {
2706         
2707 //      new MockUp<VNFRestfulUtil>(){
2708 //              @Mock
2709 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2710 //                      RestfulResponse rr = new RestfulResponse();
2711 //                      Map<String, String> header = new HashMap<>();
2712 //                      header.put("Content-Type", "Application/Json");
2713 //                      header.put("X-FormId", "jhfdl");
2714 //                      rr.setRespHeaderMap(header);
2715 //                      rr.setStatus(200);
2716 //                      rr.setResponseJson("shdfhj");
2717 //                      
2718 //                      return rr;
2719 //                      
2720 //              }
2721 //      };
2722 //      
2723 //              new MockUp<JSONObject>(){
2724 //              @Mock
2725 //              public JSONObject fromObject(Object object){
2726 //                      JSONObject js = new JSONObject();
2727 //                      js.put("id", "upload-id-123");
2728 //                      js.put("Result", "Success");
2729 //                      js.put("Check", "Ok");
2730 //                      js.put("url", "http://localhost:80");
2731 //                      js.put("userName", "User");
2732 //                      js.put("password", "pass");
2733 //                      js.put("downloadUri", "http://127.0.0.1:80");
2734 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2735 //                      js.put("keyStorePass", "Changeme_123");
2736 //                      js.put("keyStoreType", "PKCS12");
2737 //                      JSONArray ja = new JSONArray();
2738 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2739 //                      ja.add(str);
2740 //                      JSONArray ja1 = new JSONArray();
2741 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2742 //                      ja1.add(str1);
2743 //                      JSONArray ja2 = new JSONArray();
2744 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2745 //                      ja2.add(str2);
2746 //                      JSONObject jsObject = new JSONObject();
2747 //                      jsObject.put("downloadUrl", "http://localhost:80");
2748 //                      jsObject.put("csarName", "HSS");
2749 //                      js.put("vim_info", ja);
2750 //                      js.put("template", ja2);
2751 //                      js.put("templates", ja1);
2752 //                      js.put("packageInfo", jsObject);
2753 //                      return js;
2754 //              }
2755 //              };
2756 //              
2757 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2758                 
2759         JSONObject vnfpkg = new JSONObject();
2760         vnfpkg.put("name", "test");
2761         JSONObject obj = new JSONObject();
2762         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2763         obj.put("csar_file_name", "casrFile");
2764         vnfpkg.put("template", obj);
2765         Map<String, String> paramsMap = new HashMap<>();
2766         paramsMap.put("csarid", "csarid123");
2767         paramsMap.put("vnfmid", "vnfmid1234");
2768         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2769         assertTrue(res.get("reason").equals("RestfulResponse is null."));
2770
2771     }
2772     
2773     @Test(expected=JSONException.class)
2774     public void uploadVNFPackageTestWithSBC() {
2775         
2776 //      new MockUp<VNFRestfulUtil>(){
2777 //              @Mock
2778 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2779 //                      RestfulResponse rr = new RestfulResponse();
2780 //                      Map<String, String> header = new HashMap<>();
2781 //                      header.put("Content-Type", "Application/Json");
2782 //                      header.put("X-FormId", "jhfdl");
2783 //                      rr.setRespHeaderMap(header);
2784 //                      rr.setStatus(200);
2785 //                      rr.setResponseJson("shdfhj");
2786 //                      
2787 //                      return rr;
2788 //                      
2789 //              }
2790 //      };
2791 //      
2792 //              new MockUp<JSONObject>(){
2793 //              @Mock
2794 //              public JSONObject fromObject(Object object){
2795 //                      JSONObject js = new JSONObject();
2796 //                      js.put("id", "upload-id-123");
2797 //                      js.put("Result", "Success");
2798 //                      js.put("Check", "Ok");
2799 //                      js.put("url", "http://localhost:80");
2800 //                      js.put("userName", "User");
2801 //                      js.put("password", "pass");
2802 //                      js.put("downloadUri", "http://127.0.0.1:80");
2803 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2804 //                      js.put("keyStorePass", "Changeme_123");
2805 //                      js.put("keyStoreType", "PKCS12");
2806 //                      JSONArray ja = new JSONArray();
2807 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2808 //                      ja.add(str);
2809 //                      JSONArray ja1 = new JSONArray();
2810 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2811 //                      ja1.add(str1);
2812 //                      JSONArray ja2 = new JSONArray();
2813 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2814 //                      ja2.add(str2);
2815 //                      JSONObject jsObject = new JSONObject();
2816 //                      jsObject.put("downloadUrl", "http://localhost:80");
2817 //                      jsObject.put("csarName", "SBC");
2818 //                      js.put("vim_info", ja);
2819 //                      js.put("template", ja2);
2820 //                      js.put("templates", ja1);
2821 //                      js.put("packageInfo", jsObject);
2822 //                      return js;
2823 //              }
2824 //              };
2825 //              
2826 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2827                 
2828         JSONObject vnfpkg = new JSONObject();
2829         vnfpkg.put("name", "test");
2830         JSONObject obj = new JSONObject();
2831         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2832         obj.put("csar_file_name", "casrFile");
2833         vnfpkg.put("template", obj);
2834         Map<String, String> paramsMap = new HashMap<>();
2835         paramsMap.put("csarid", "csarid123");
2836         paramsMap.put("vnfmid", "vnfmid1234");
2837         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2838         assertTrue(res.get("reason").equals("RestfulResponse is null."));
2839
2840     }
2841     
2842     @Test(expected=JSONException.class)
2843     public void uploadVNFPackageTestWithPCRF() {
2844         
2845 //              new MockUp<VNFRestfulUtil>(){
2846 //                      @Mock
2847 //                      public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2848 //                              RestfulResponse rr = new RestfulResponse();
2849 //                              Map<String, String> header = new HashMap<>();
2850 //                              header.put("Content-Type", "Application/Json");
2851 //                              header.put("X-FormId", "jhfdl");
2852 //                              rr.setRespHeaderMap(header);
2853 //                              rr.setStatus(200);
2854 //                              rr.setResponseJson("shdfhj");
2855 //                              
2856 //                              return rr;
2857 //                              
2858 //                      }
2859 //              };
2860 //      
2861 //              new MockUp<JSONObject>(){
2862 //              @Mock
2863 //              public JSONObject fromObject(Object object){
2864 //                      JSONObject js = new JSONObject();
2865 //                      js.put("id", "upload-id-123");
2866 //                      js.put("Result", "Success");
2867 //                      js.put("Check", "Ok");
2868 //                      js.put("url", "http://localhost:80");
2869 //                      js.put("userName", "User");
2870 //                      js.put("password", "pass");
2871 //                      js.put("downloadUri", "http://127.0.0.1:80");
2872 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2873 //                      js.put("keyStorePass", "Changeme_123");
2874 //                      js.put("keyStoreType", "PKCS12");
2875 //                      JSONArray ja = new JSONArray();
2876 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2877 //                      ja.add(str);
2878 //                      JSONArray ja1 = new JSONArray();
2879 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2880 //                      ja1.add(str1);
2881 //                      JSONArray ja2 = new JSONArray();
2882 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2883 //                      ja2.add(str2);
2884 //                      JSONObject jsObject = new JSONObject();
2885 //                      jsObject.put("downloadUrl", "http://localhost:80");
2886 //                      jsObject.put("csarName", "PCRF");
2887 //                      js.put("vim_info", ja);
2888 //                      js.put("template", ja2);
2889 //                      js.put("templates", ja1);
2890 //                      js.put("packageInfo", jsObject);
2891 //                      return js;
2892 //              }
2893 //              };
2894 //              
2895 //        System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2896                 
2897         JSONObject vnfpkg = new JSONObject();
2898         vnfpkg.put("name", "test");
2899         JSONObject obj = new JSONObject();
2900         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2901         obj.put("csar_file_name", "casrFile");
2902         vnfpkg.put("template", obj);
2903         Map<String, String> paramsMap = new HashMap<>();
2904         paramsMap.put("csarid", "csarid123");
2905         paramsMap.put("vnfmid", "vnfmid1234");
2906         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2907         assertTrue(res.get("reason").equals("download csar file failed."));
2908
2909     }
2910     
2911     @Test(expected=JSONException.class)
2912     public void uploadVNFPackageTestWithTAS() {
2913         
2914 //      new MockUp<VNFRestfulUtil>(){
2915 //              @Mock
2916 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2917 //                      RestfulResponse rr = new RestfulResponse();
2918 //                      Map<String, String> header = new HashMap<>();
2919 //                      header.put("Content-Type", "Application/Json");
2920 //                      header.put("X-FormId", "jhfdl");
2921 //                      rr.setRespHeaderMap(header);
2922 //                      rr.setStatus(200);
2923 //                      rr.setResponseJson("shdfhj");
2924 //                      
2925 //                      return rr;
2926 //                      
2927 //              }
2928 //      };
2929 //      
2930 //              new MockUp<JSONObject>(){
2931 //              @Mock
2932 //              public JSONObject fromObject(Object object){
2933 //                      JSONObject js = new JSONObject();
2934 //                      js.put("id", "upload-id-123");
2935 //                      js.put("Result", "Success");
2936 //                      js.put("Check", "Ok");
2937 //                      js.put("url", "http://localhost:80");
2938 //                      js.put("userName", "User");
2939 //                      js.put("password", "pass");
2940 //                      js.put("downloadUri", "http://127.0.0.1:80");
2941 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2942 //                      js.put("keyStorePass", "Changeme_123");
2943 //                      js.put("keyStoreType", "PKCS12");
2944 //                      JSONArray ja = new JSONArray();
2945 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2946 //                      ja.add(str);
2947 //                      JSONArray ja1 = new JSONArray();
2948 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2949 //                      ja1.add(str1);
2950 //                      JSONArray ja2 = new JSONArray();
2951 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2952 //                      ja2.add(str2);
2953 //                      JSONObject jsObject = new JSONObject();
2954 //                      jsObject.put("downloadUrl", "http://localhost:80");
2955 //                      jsObject.put("csarName", "TAS");
2956 //                      js.put("vim_info", ja);
2957 //                      js.put("template", ja2);
2958 //                      js.put("templates", ja1);
2959 //                      js.put("packageInfo", jsObject);
2960 //                      return js;
2961 //              }
2962 //              };
2963 //              
2964 //              System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2965                 
2966         JSONObject vnfpkg = new JSONObject();
2967         vnfpkg.put("name", "test");
2968         JSONObject obj = new JSONObject();
2969         obj.put("csar_file_path", "src/test/resources/Check10.txt");
2970         obj.put("csar_file_name", "casrFile");
2971         vnfpkg.put("template", obj);
2972         Map<String, String> paramsMap = new HashMap<>();
2973         paramsMap.put("csarid", "csarid123");
2974         paramsMap.put("vnfmid", "vnfmid1234");
2975         JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2976         assertTrue(res.get("reason").equals("download csar file failed."));
2977
2978     }
2979     
2980     @Test
2981     public void uploadVNFPackageTestWithCSCF() {
2982         
2983 //      new MockUp<VNFRestfulUtil>(){
2984 //              @Mock
2985 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2986 //                      RestfulResponse rr = new RestfulResponse();
2987 //                      Map<String, String> header = new HashMap<>();
2988 //                      header.put("Content-Type", "Application/Json");
2989 //                      header.put("X-FormId", "jhfdl");
2990 //                      rr.setRespHeaderMap(header);
2991 //                      rr.setStatus(200);
2992 //                      rr.setResponseJson("shdfhj");
2993 //                      
2994 //                      return rr;
2995 //                      
2996 //              }
2997 //      };
2998 //      
2999 //              new MockUp<JSONObject>(){
3000 //              @Mock
3001 //              public JSONObject fromObject(Object object){
3002 //                      JSONObject js = new JSONObject();
3003 //                      js.put("id", "upload-id-123");
3004 //                      js.put("Result", "Success");
3005 //                      js.put("Check", "Ok");
3006 //                      js.put("url", "http://localhost:80");
3007 //                      js.put("userName", "User");
3008 //                      js.put("password", "pass");
3009 //                      js.put("downloadUri", "http://127.0.0.1:80");
3010 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3011 //                      js.put("keyStorePass", "Changeme_123");
3012 //                      js.put("keyStoreType", "PKCS12");
3013 //                      JSONArray ja = new JSONArray();
3014 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3015 //                      ja.add(str);
3016 //                      JSONArray ja1 = new JSONArray();
3017 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3018 //                      ja1.add(str1);
3019 //                      JSONArray ja2 = new JSONArray();
3020 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3021 //                      ja2.add(str2);
3022 //                      JSONObject jsObject = new JSONObject();
3023 //                      jsObject.put("downloadUrl", "http://localhost:80");
3024 //                      jsObject.put("csarName", "CSCF");
3025 //                      JSONObject jsEms = new JSONObject();
3026 //                      jsEms.put("emsUuid", "123erbhi-hjdek123");
3027 //                      JSONObject jsCsar = new JSONObject();
3028 //                      jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3029 //                      jsCsar.put("csar_file_name", "Csar_File");
3030 //                      jsCsar.put("emsUuid", jsEms);
3031 //                      JSONObject jsTemp = new JSONObject();
3032 //                      jsTemp.put("template", jsCsar);
3033 //                      js.put("vCSCF", jsTemp);
3034 //                      js.put("vim_info", ja);
3035 //                      js.put("template", ja2);
3036 //                      js.put("templates", ja1);
3037 //                      js.put("packageInfo", jsObject);
3038 //                      return js;
3039 //              }
3040 //              };
3041 //              
3042 //              System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3043                 
3044         JSONObject vnfpkg = new JSONObject();
3045         JSONObject vnfpkg1 = new JSONObject();
3046         vnfpkg.put("name", "test");
3047         JSONObject obj = new JSONObject();
3048         obj.put("csar_file_path", "src/test/resources/Check10.txt");
3049         obj.put("csar_file_name", "casrFile");
3050         vnfpkg.put("template", obj);
3051         Map<String, String> paramsMap = new HashMap<>();
3052         paramsMap.put("csarid", "csarid123");
3053         paramsMap.put("vnfmid", "vnfmid1234");
3054         JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3055         assertTrue(res.get("reason").equals("download csar file failed."));
3056     }
3057     
3058     @Test
3059     public void uploadVNFPackageTestWithOutEmsUid() {
3060         
3061 //      new MockUp<VNFRestfulUtil>(){
3062 //              @Mock
3063 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3064 //                      RestfulResponse rr = new RestfulResponse();
3065 //                      Map<String, String> header = new HashMap<>();
3066 //                      header.put("Content-Type", "Application/Json");
3067 //                      header.put("X-FormId", "jhfdl");
3068 //                      rr.setRespHeaderMap(header);
3069 //                      rr.setStatus(200);
3070 //                      rr.setResponseJson("shdfhj");
3071 //                      
3072 //                      return rr;
3073 //                      
3074 //              }
3075 //      };
3076 //      
3077 //              new MockUp<JSONObject>(){
3078 //              @Mock
3079 //              public JSONObject fromObject(Object object){
3080 //                      JSONObject js = new JSONObject();
3081 //                      js.put("id", "upload-id-123");
3082 //                      js.put("Result", "Success");
3083 //                      js.put("Check", "Ok");
3084 //                      js.put("url", "http://localhost:80");
3085 //                      js.put("userName", "User");
3086 //                      js.put("password", "pass");
3087 //                      js.put("downloadUri", "http://127.0.0.1:80");
3088 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3089 //                      js.put("keyStorePass", "Changeme_123");
3090 //                      js.put("keyStoreType", "PKCS12");
3091 //                      JSONArray ja = new JSONArray();
3092 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3093 //                      ja.add(str);
3094 //                      JSONArray ja1 = new JSONArray();
3095 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3096 //                      ja1.add(str1);
3097 //                      JSONArray ja2 = new JSONArray();
3098 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3099 //                      ja2.add(str2);
3100 //                      JSONObject jsObject = new JSONObject();
3101 //                      jsObject.put("downloadUrl", "http://localhost:80");
3102 //                      jsObject.put("csarName", "CSCF");
3103 //                      JSONObject jsCsar = new JSONObject();
3104 //                      jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3105 //                      jsCsar.put("csar_file_name", "Csar_File");
3106 //                      JSONObject jsTemp = new JSONObject();
3107 //                      jsTemp.put("template", jsCsar);
3108 //                      js.put("vCSCF", jsTemp);
3109 //                      js.put("vim_info", ja);
3110 //                      js.put("template", ja2);
3111 //                      js.put("templates", ja1);
3112 //                      js.put("packageInfo", jsObject);
3113 //                      return js;
3114 //              }
3115 //              };
3116 //              
3117 //              System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3118                 
3119         JSONObject vnfpkg = new JSONObject();
3120         JSONObject vnfpkg1 = new JSONObject();
3121         vnfpkg.put("name", "test");
3122         JSONObject obj = new JSONObject();
3123         obj.put("csar_file_path", "src/test/resources/Check10.txt");
3124         obj.put("csar_file_name", "casrFile");
3125         vnfpkg.put("template", obj);
3126         Map<String, String> paramsMap = new HashMap<>();
3127         paramsMap.put("csarid", "csarid123");
3128         paramsMap.put("vnfmid", "vnfmid1234");
3129         JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3130         assertTrue(res.get("reason").equals("download csar file failed."));
3131     }
3132     
3133     @Test
3134     public void uploadVNFPackageTestWithCSDowCsar() {
3135         
3136 //      new MockUp<VNFRestfulUtil>(){
3137 //              @Mock
3138 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3139 //                      RestfulResponse rr = new RestfulResponse();
3140 //                      Map<String, String> header = new HashMap<>();
3141 //                      header.put("Content-Type", "Application/Json");
3142 //                      header.put("X-FormId", "jhfdl");
3143 //                      rr.setRespHeaderMap(header);
3144 //                      rr.setStatus(200);
3145 //                      rr.setResponseJson("shdfhj");
3146 //                      
3147 //                      return rr;
3148 //                      
3149 //              }
3150 //      };
3151 //      
3152 //      new MockUp<DownloadCsarManager>(){
3153 //              @Mock
3154 //              public String download(String url, String filepath) {
3155 //                      String response = "Success";
3156 //                      return response;
3157 //              }
3158 //      };
3159 //      
3160 //              new MockUp<JSONObject>(){
3161 //              @Mock
3162 //              public JSONObject fromObject(Object object){
3163 //                      JSONObject js = new JSONObject();
3164 //                      js.put("id", "upload-id-123");
3165 //                      js.put("Result", "Success");
3166 //                      js.put("Check", "Ok");
3167 //                      js.put("url", "http://localhost:80");
3168 //                      js.put("userName", "User");
3169 //                      js.put("password", "pass");
3170 //                      js.put("downloadUri", "http://127.0.0.1:80");
3171 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3172 //                      js.put("keyStorePass", "Changeme_123");
3173 //                      js.put("keyStoreType", "PKCS12");
3174 //                      JSONArray ja = new JSONArray();
3175 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3176 //                      ja.add(str);
3177 //                      JSONArray ja1 = new JSONArray();
3178 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3179 //                      ja1.add(str1);
3180 //                      JSONArray ja2 = new JSONArray();
3181 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3182 //                      ja2.add(str2);
3183 //                      JSONObject jsObject = new JSONObject();
3184 //                      jsObject.put("downloadUrl", "http://localhost:80");
3185 //                      jsObject.put("csarName", "CSCF");
3186 //                      JSONObject jsEms = new JSONObject();
3187 //                      jsEms.put("emsUuid", "123erbhi-hjdek123");
3188 //                      JSONObject jsCsar = new JSONObject();
3189 //                      jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3190 //                      jsCsar.put("csar_file_name", "Csar_File");
3191 //                      jsCsar.put("emsUuid", jsEms);
3192 //                      JSONObject jsTemp = new JSONObject();
3193 //                      jsTemp.put("template", jsCsar);
3194 //                      js.put("vCSCF", jsTemp);
3195 //                      js.put("vim_info", ja);
3196 //                      js.put("template", ja2);
3197 //                      js.put("templates", ja1);
3198 //                      js.put("packageInfo", jsObject);
3199 //                      return js;
3200 //              }
3201 //              };
3202 //              
3203 //              System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3204                 
3205         JSONObject vnfpkg = new JSONObject();
3206         JSONObject vnfpkg1 = new JSONObject();
3207         vnfpkg.put("name", "test");
3208         JSONObject obj = new JSONObject();
3209         obj.put("csar_file_path", "src/test/resources/Check10.txt");
3210         obj.put("csar_file_name", "casrFile");
3211         vnfpkg.put("template", obj);
3212         Map<String, String> paramsMap = new HashMap<>();
3213         paramsMap.put("csarid", "csarid123");
3214         paramsMap.put("vnfmid", "vnfmid1234");
3215         JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3216         assertTrue(res.get("reason").equals("unzip csar file failed."));
3217     }
3218     
3219     @Test
3220     public void uploadVNFPackageTestWithUnZipCsar() {
3221         
3222 //      new MockUp<VNFRestfulUtil>(){
3223 //              @Mock
3224 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3225 //                      RestfulResponse rr = new RestfulResponse();
3226 //                      Map<String, String> header = new HashMap<>();
3227 //                      header.put("Content-Type", "Application/Json");
3228 //                      header.put("X-FormId", "jhfdl");
3229 //                      rr.setRespHeaderMap(header);
3230 //                      rr.setStatus(200);
3231 //                      rr.setResponseJson("shdfhj");
3232 //                      return rr;
3233 //                      
3234 //              }
3235 //      };
3236 //      
3237 //      new MockUp<VnfmUtil>(){
3238 //              @Mock
3239 //              public JSONObject getVnfmById(String vnfmId) {
3240 //                      
3241 //                      JSONObject jsonObject = new JSONObject();
3242 //                      jsonObject.put("url", "https://localhost:80");
3243 //                      jsonObject.put("userName", "ubuntu");
3244 //                      jsonObject.put("password", "******");
3245 //                      return jsonObject;
3246 //                      
3247 //              }
3248 //      };
3249 //      
3250 //      new MockUp<DownloadCsarManager>(){
3251 //              @Mock
3252 //              public String download(String url, String filepath) {
3253 //                      String response = "Success";
3254 //                      return response;
3255 //              }
3256 //              
3257 //              @Mock
3258 //               public int unzipCSAR(String fileName, String filePath) {                       
3259 //                      
3260 //                      return 0;
3261 //              }
3262 //      };
3263 //      
3264 //      new MockUp<ConnectMgrVnfm>(){
3265 //              @Mock
3266 //              public int connect(JSONObject vnfmObj, String authModel) {
3267 //                      
3268 //                      
3269 //                      return 404;
3270 //                      
3271 //              }
3272 //      };
3273 //      
3274 //        new MockUp<JSONObject>(){
3275 //              @Mock
3276 //              public JSONObject fromObject(Object object){
3277 //                      JSONObject js = new JSONObject();
3278 //                      js.put("id", "upload-id-123");
3279 //                      js.put("Result", "Success");
3280 //                      js.put("Check", "Ok");
3281 //                      js.put("url", "http://localhost:80");
3282 //                      js.put("userName", "User");
3283 //                      js.put("password", "pass");
3284 //                      js.put("downloadUri", "http://127.0.0.1:80");
3285 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3286 //                      js.put("keyStorePass", "Changeme_123");
3287 //                      js.put("keyStoreType", "PKCS12");
3288 //                      JSONArray ja = new JSONArray();
3289 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3290 //                      ja.add(str);
3291 //                      JSONArray ja1 = new JSONArray();
3292 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3293 //                      ja1.add(str1);
3294 //                      JSONArray ja2 = new JSONArray();
3295 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3296 //                      ja2.add(str2);
3297 //                      JSONObject jsObject = new JSONObject();
3298 //                      jsObject.put("downloadUrl", "http://localhost:80");
3299 //                      jsObject.put("csarName", "CSCF");
3300 //                      JSONObject jsEms = new JSONObject();
3301 //                      jsEms.put("emsUuid", "123erbhi-hjdek123");
3302 //                      JSONObject jsCsar = new JSONObject();
3303 //                      jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3304 //                      jsCsar.put("csar_file_name", "Csar_File");
3305 //                      jsCsar.put("emsUuid", jsEms);
3306 //                      JSONObject jsTemp = new JSONObject();
3307 //                      jsTemp.put("template", jsCsar);
3308 //                      js.put("vCSCF", jsTemp);
3309 //                      js.put("vim_info", ja);
3310 //                      js.put("template", ja2);
3311 //                      js.put("templates", ja1);
3312 //                      js.put("packageInfo", jsObject);
3313 //                      return js;
3314 //              }
3315 //              };
3316 //              
3317 //        System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3318                 
3319         JSONObject vnfpkg = new JSONObject();
3320         JSONObject vnfpkg1 = new JSONObject();
3321         vnfpkg.put("name", "test");
3322         JSONObject obj = new JSONObject();
3323         obj.put("csar_file_path", "src/test/resources/Check10.txt");
3324         obj.put("csar_file_name", "casrFile");
3325         vnfpkg.put("template", obj);
3326         Map<String, String> paramsMap = new HashMap<>();
3327         paramsMap.put("csarid", "csarid123");
3328         paramsMap.put("vnfmid", "vnfmid1234");
3329         JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3330         assertTrue(res.get("reason").equals("connect fail."));
3331     }
3332     
3333     @Test(expected=JSONException.class)
3334     public void uploadVNFPackageTestWithConnectMgr() {
3335         
3336 //      new MockUp<VNFRestfulUtil>(){
3337 //              @Mock
3338 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3339 //                      RestfulResponse rr = new RestfulResponse();
3340 //                      Map<String, String> header = new HashMap<>();
3341 //                      header.put("Content-Type", "Application/Json");
3342 //                      header.put("X-FormId", "jhfdl");
3343 //                      rr.setRespHeaderMap(header);
3344 //                      rr.setStatus(200);
3345 //                      rr.setResponseJson("shdfhj");
3346 //                      
3347 //                      return rr;
3348 //                      
3349 //              }
3350 //      };
3351 //      
3352 //      new MockUp<VnfmUtil>(){
3353 //              @Mock
3354 //              public JSONObject getVnfmById(String vnfmId) {
3355 //                      
3356 //                      JSONObject jsonObject = new JSONObject();
3357 //                      jsonObject.put("url", "https://localhost:80");
3358 //                      jsonObject.put("userName", "ubuntu");
3359 //                      jsonObject.put("password", "******");
3360 //                      return jsonObject;
3361 //                      
3362 //              }
3363 //      };
3364 //      
3365 //      new MockUp<DownloadCsarManager>(){
3366 //              @Mock
3367 //              public String download(String url, String filepath) {
3368 //                      String response = "Success";
3369 //                      return response;
3370 //              }
3371 //              
3372 //              @Mock
3373 //               public int unzipCSAR(String fileName, String filePath) {                       
3374 //                      
3375 //                      return 0;
3376 //              }
3377 //      };
3378 //      
3379 //      new MockUp<HttpClient>(){
3380 //              @Mock
3381 //              public int executeMethod(HttpMethod method) {
3382 //                  return 200;
3383 //              }
3384 //          };
3385 //          
3386 //          new MockUp<HttpMethodBase>(){
3387 //              
3388 //              @Mock 
3389 //               public int getStatusCode(){
3390 //                      
3391 //                      return 200;
3392 //              }
3393 //              
3394 //          };
3395 //          
3396 //      new MockUp<ConnectMgrVnfm>(){
3397 //              @Mock
3398 //              public int connect(JSONObject vnfmObj, String authModel) {
3399 //                      
3400 //                      
3401 //                      return 200;
3402 //                      
3403 //              }
3404 //              
3405 //              @Mock
3406 //              public String getAccessSession() {
3407 //                      
3408 //                      return "conn";
3409 //              }
3410 //      };
3411 //      
3412 //        new MockUp<JSONObject>(){
3413 //              @Mock
3414 //              public JSONObject fromObject(Object object){
3415 //                      JSONObject js = new JSONObject();
3416 //                      js.put("id", "upload-id-123");
3417 //                      js.put("Result", "Success");
3418 //                      js.put("Check", "Ok");
3419 //                      js.put("url", "http://localhost:80");
3420 //                      js.put("userName", "User");
3421 //                      js.put("password", "pass");
3422 //                      js.put("downloadUri", "http://127.0.0.1:80");
3423 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3424 //                      js.put("keyStorePass", "Changeme_123");
3425 //                      js.put("keyStoreType", "PKCS12");
3426 //                      JSONArray ja = new JSONArray();
3427 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3428 //                      ja.add(str);
3429 //                      JSONArray ja1 = new JSONArray();
3430 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3431 //                      ja1.add(str1);
3432 //                      JSONArray ja2 = new JSONArray();
3433 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3434 //                      ja2.add(str2);
3435 //                      JSONObject jsObject = new JSONObject();
3436 //                      jsObject.put("downloadUrl", "http://localhost:80");
3437 //                      jsObject.put("csarName", "CSCF");
3438 //                      JSONObject jsEms = new JSONObject();
3439 //                      jsEms.put("emsUuid", "123erbhi-hjdek123");
3440 //                      JSONObject jsCsar = new JSONObject();
3441 //                      jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3442 //                      jsCsar.put("csar_file_name", "Csar_File");
3443 //                      jsCsar.put("emsUuid", jsEms);
3444 //                      JSONObject jsTemp = new JSONObject();
3445 //                      jsTemp.put("template", jsCsar);
3446 //                      js.put("vCSCF", jsTemp);
3447 //                      js.put("vim_info", ja);
3448 //                      js.put("template", ja2);
3449 //                      js.put("templates", ja1);
3450 //                      js.put("packageInfo", jsObject);
3451 //                      return js;
3452 //              }
3453 //              };
3454 //              
3455 //        System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3456                 
3457         JSONObject vnfpkg = new JSONObject();
3458         JSONObject vnfpkg1 = new JSONObject();
3459         vnfpkg.put("name", "test");
3460         JSONObject obj = new JSONObject();
3461         obj.put("csar_file_path", "src/test/resources/Check10.txt");
3462         obj.put("csar_file_name", "casrFile");
3463         vnfpkg.put("template", obj);
3464         Map<String, String> paramsMap = new HashMap<>();
3465         paramsMap.put("csarid", "csarid123");
3466         paramsMap.put("vnfmid", "vnfmid1234");
3467         JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3468         assertTrue(res.get("reason").equals("RestfulResponse is null."));
3469     }
3470     
3471     @Test
3472     public void uploadVNFPackageTestWithConnectMgrGetAllFail() {
3473         
3474 //      new MockUp<VNFRestfulUtil>(){
3475 //              @Mock
3476 //              public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3477 //                      RestfulResponse rr = new RestfulResponse();
3478 //                      Map<String, String> header = new HashMap<>();
3479 //                      header.put("Content-Type", "Application/Json");
3480 //                      header.put("X-FormId", "jhfdl");
3481 //                      rr.setRespHeaderMap(header);
3482 //                      rr.setStatus(200);
3483 //                      rr.setResponseJson("shdfhj");
3484 //                      
3485 //                      return rr;
3486 //                      
3487 //              }
3488 //      };
3489 //      
3490 //      new MockUp<VnfmUtil>(){
3491 //              @Mock
3492 //              public JSONObject getVnfmById(String vnfmId) {
3493 //                      
3494 //                      JSONObject jsonObject = new JSONObject();
3495 //                      jsonObject.put("url", "https://localhost:80");
3496 //                      jsonObject.put("userName", "ubuntu");
3497 //                      jsonObject.put("password", "******");
3498 //                      return jsonObject;
3499 //                      
3500 //              }
3501 //      };
3502 //      
3503 //      new MockUp<DownloadCsarManager>(){
3504 //              @Mock
3505 //              public String download(String url, String filepath) {
3506 //                      String response = "Success";
3507 //                      return response;
3508 //              }
3509 //              
3510 //              @Mock
3511 //               public int unzipCSAR(String fileName, String filePath) {                       
3512 //                      
3513 //                      return 0;
3514 //              }
3515 //      };
3516 //      
3517 //      new MockUp<ConnectMgrVnfm>(){
3518 //              @Mock
3519 //              public int connect(JSONObject vnfmObj, String authModel) {
3520 //                      
3521 //                      
3522 //                      return 200;
3523 //                      
3524 //              }
3525 //              
3526 //              @Mock
3527 //              public String getAccessSession() {
3528 //                      
3529 //                      return "conn";
3530 //              }
3531 //      };
3532 //      
3533 //        new MockUp<JSONObject>(){
3534 //              @Mock
3535 //              public JSONObject fromObject(Object object){
3536 //                      JSONObject js = new JSONObject();
3537 //                      js.put("id", "upload-id-123");
3538 //                      js.put("Result", "Success");
3539 //                      js.put("Check", "Ok");
3540 //                      js.put("url", "http://localhost:80");
3541 //                      js.put("userName", "User");
3542 //                      js.put("password", "pass");
3543 //                      js.put("downloadUri", "http://127.0.0.1:80");
3544 //                      js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3545 //                      js.put("keyStorePass", "Changeme_123");
3546 //                      js.put("keyStoreType", "PKCS12");
3547 //                      JSONArray ja = new JSONArray();
3548 //                      String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3549 //                      ja.add(str);
3550 //                      JSONArray ja1 = new JSONArray();
3551 //                      String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3552 //                      ja1.add(str1);
3553 //                      JSONArray ja2 = new JSONArray();
3554 //                      String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3555 //                      ja2.add(str2);
3556 //                      JSONObject jsObject = new JSONObject();
3557 //                      jsObject.put("downloadUrl", "http://localhost:80");
3558 //                      jsObject.put("csarName", "CSCF");
3559 //                      JSONObject jsEms = new JSONObject();
3560 //                      jsEms.put("emsUuid", "123erbhi-hjdek123");
3561 //                      JSONObject jsCsar = new JSONObject();
3562 //                      jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3563 //                      jsCsar.put("csar_file_name", "Csar_File");
3564 //                      jsCsar.put("emsUuid", jsEms);
3565 //                      JSONObject jsTemp = new JSONObject();
3566 //                      jsTemp.put("template", jsCsar);
3567 //                      js.put("vCSCF", jsTemp);
3568 //                      js.put("vim_info", ja);
3569 //                      js.put("template", ja2);
3570 //                      js.put("templates", ja1);
3571 //                      js.put("packageInfo", jsObject);
3572 //                      return js;
3573 //              }
3574 //              };
3575 //              
3576 //        System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3577                 
3578         JSONObject vnfpkg = new JSONObject();
3579         JSONObject vnfpkg1 = new JSONObject();
3580         vnfpkg.put("name", "test");
3581         JSONObject obj = new JSONObject();
3582         obj.put("csar_file_path", "src/test/resources/Check10.txt");
3583         obj.put("csar_file_name", "casrFile");
3584         vnfpkg.put("template", obj);
3585         Map<String, String> paramsMap = new HashMap<>();
3586         paramsMap.put("csarid", "csarid123");
3587         paramsMap.put("vnfmid", "vnfmid1234");
3588         JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3589         assertTrue(res.get("reason").equals("get allcloud failed and IOException.Connection refused (Connection refused)"));
3590     }
3591
3592         @Test
3593         public void uploadVNFPackageTestVnfdPlanInfo() throws IOException {
3594
3595 //              new MockUp<VNFRestfulUtil>() {
3596 //                      @Mock
3597 //                      public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3598 //                              RestfulResponse rr = new RestfulResponse();
3599 //                              Map<String, String> header = new HashMap<>();
3600 //                              header.put("Content-Type", "Application/Json");
3601 //                              header.put("X-FormId", "jhfdl");
3602 //                              rr.setRespHeaderMap(header);
3603 //                              rr.setStatus(200);
3604 //                              rr.setResponseJson("shdfhj");
3605 //
3606 //                              return rr;
3607 //
3608 //                      }
3609 //              };
3610 //
3611 //              new MockUp<VnfmUtil>() {
3612 //                      @Mock
3613 //                      public JSONObject getVnfmById(String vnfmId) {
3614 //
3615 //                              JSONObject jsonObject = new JSONObject();
3616 //                              jsonObject.put("url", "https://localhost:80");
3617 //                              jsonObject.put("userName", "ubuntu");
3618 //                              jsonObject.put("password", "******");
3619 //                              return jsonObject;
3620 //
3621 //                      }
3622 //              };
3623 //
3624 //              new MockUp<DownloadCsarManager>() {
3625 //                      @Mock
3626 //                      public String download(String url, String filepath) {
3627 //                              String response = "Success";
3628 //                              return response;
3629 //                      }
3630 //
3631 //                      @Mock
3632 //                      public int unzipCSAR(String fileName, String filePath) {
3633 //
3634 //                              return 0;
3635 //                      }
3636 //              };
3637 //
3638 //              new MockUp<ConnectMgrVnfm>() {
3639 //                      @Mock
3640 //                      public int connect(JSONObject vnfmObj, String authModel) {
3641 //
3642 //                              return 200;
3643 //
3644 //                      }
3645 //
3646 //                      @Mock
3647 //                      public String getAccessSession() {
3648 //
3649 //                              return "conn";
3650 //                      }
3651 //              };
3652 //
3653 //              new MockUp<JSONObject>() {
3654 //                      @Mock
3655 //                      public JSONObject fromObject(Object object) {
3656 //                              JSONObject js = new JSONObject();
3657 //                              js.put("id", "upload-id-123");
3658 //                              js.put("Result", "Success");
3659 //                              js.put("Check", "Ok");
3660 //                              js.put("url", "http://localhost:80");
3661 //                              js.put("userName", "User");
3662 //                              js.put("password", "pass");
3663 //                              js.put("downloadUri", "http://127.0.0.1:80");
3664 //                              js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3665 //                              js.put("keyStorePass", "Changeme_123");
3666 //                              js.put("keyStoreType", "PKCS12");
3667 //                              JSONArray ja = new JSONArray();
3668 //                              String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3669 //                              ja.add(str);
3670 //                              JSONArray ja1 = new JSONArray();
3671 //                              String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3672 //                              ;
3673 //                              ja1.add(str1);
3674 //                              JSONArray ja2 = new JSONArray();
3675 //                              String str2 = "{\n  \"template_name\": \"vnfd-name-123\",\n  \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3676 //                              ja2.add(str2);
3677 //                              JSONObject jsObject = new JSONObject();
3678 //                              jsObject.put("downloadUrl", "http://localhost:80");
3679 //                              jsObject.put("csarName", "CSCF");
3680 //                              JSONObject jsEms = new JSONObject();
3681 //                              jsEms.put("emsUuid", "123erbhi-hjdek123");
3682 //                              JSONObject jsCsar = new JSONObject();
3683 //                              jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3684 //                              jsCsar.put("csar_file_name", "Csar_File");
3685 //                              jsCsar.put("emsUuid", jsEms);
3686 //                              JSONObject jsTemp = new JSONObject();
3687 //                              jsTemp.put("template", jsCsar);
3688 //                              js.put("vCSCF", jsTemp);
3689 //                              js.put("vim_info", ja);
3690 //                              js.put("template", ja2);
3691 //                              js.put("templates", ja1);
3692 //                              js.put("packageInfo", jsObject);
3693 //                              return js;
3694 //                      }
3695 //              };
3696 //
3697 //              System.setProperty("catalina.base",
3698 //                              "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3699
3700                 JSONObject vnfpkg = new JSONObject();
3701                 JSONObject vnfpkg1 = new JSONObject();
3702                 vnfpkg.put("name", "test");
3703                 JSONObject obj = new JSONObject();
3704                 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3705                 obj.put("csar_file_name", "casrFile");
3706                 vnfpkg.put("template", obj);
3707                 Map<String, String> paramsMap = new HashMap<>();
3708                 paramsMap.put("csarid", "csarid123");
3709                 paramsMap.put("vnfmid", "vnfmid1234");
3710                 String testString = "test\nstring";
3711                 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3712                 assertTrue(res.get("reason")
3713                                 .equals("get allcloud failed and IOException.Connection refused (Connection refused)"));
3714         }
3715
3716         @Test
3717         public void uploadVNFPackageSuccessTest() {
3718
3719 //              new MockUp<VNFRestfulUtil>() {
3720 //                      @Mock
3721 //                      public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3722 //                              RestfulResponse rr = new RestfulResponse();
3723 //                              Map<String, String> header = new HashMap<>();
3724 //                              header.put("Content-Type", "Application/Json");
3725 //                              header.put("X-FormId", "jhfdl");
3726 //                              rr.setRespHeaderMap(header);
3727 //                              rr.setStatus(200);
3728 //                              rr.setResponseJson("shdfhj");
3729 //
3730 //                              return rr;
3731 //
3732 //                      }
3733 //              };
3734 //
3735 //              new MockUp<VnfmUtil>() {
3736 //                      @Mock
3737 //                      public JSONObject getVnfmById(String vnfmId) {
3738 //
3739 //                              JSONObject jsonObject = new JSONObject();
3740 //                              jsonObject.put("url", "https://localhost:80");
3741 //                              jsonObject.put("userName", "ubuntu");
3742 //                              jsonObject.put("password", "******");
3743 //                              return jsonObject;
3744 //
3745 //                      }
3746 //              };
3747 //
3748 //              new MockUp<DownloadCsarManager>() {
3749 //                      @Mock
3750 //                      public String download(String url, String filepath) {
3751 //                              String response = "Success";
3752 //                              return response;
3753 //                      }
3754 //
3755 //                      @Mock
3756 //                      public int unzipCSAR(String fileName, String filePath) {
3757 //
3758 //                              return 0;
3759 //                      }
3760 //              };
3761 //
3762 //              new MockUp<HttpClient>() {
3763 //                      @Mock
3764 //                      public int executeMethod(HttpMethod method) {
3765 //                              return 200;
3766 //                      }
3767 //              };
3768 //
3769 //              new MockUp<HttpMethodBase>() {
3770 //
3771 //                      @Mock
3772 //                      public int getStatusCode() {
3773 //
3774 //                              return 200;
3775 //                      }
3776 //
3777 //              };
3778 //
3779 //              new MockUp<ConnectMgrVnfm>() {
3780 //                      @Mock
3781 //                      public int connect(JSONObject vnfmObj, String authModel) {
3782 //
3783 //                              return 200;
3784 //
3785 //                      }
3786 //
3787 //                      @Mock
3788 //                      public String getAccessSession() {
3789 //
3790 //                              return "conn";
3791 //                      }
3792 //              };
3793 //
3794 //              new MockUp<JSONObject>() {
3795 //                      @Mock
3796 //                      public JSONObject fromObject(Object object) {
3797 //                              JSONObject js = new JSONObject();
3798 //                              js.put("id", "upload-id-123");
3799 //                              js.put("Result", "Success");
3800 //                              js.put("Check", "Ok");
3801 //                              js.put("url", "http://localhost:80");
3802 //                              js.put("userName", "User");
3803 //                              js.put("password", "pass");
3804 //                              js.put("downloadUri", "http://127.0.0.1:80");
3805 //                              js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3806 //                              js.put("keyStorePass", "Changeme_123");
3807 //                              js.put("keyStoreType", "PKCS12");
3808 //                              JSONArray ja = new JSONArray();
3809 //                              String str = "{\n  \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3810 //                              ja.add(str);
3811 //                              JSONArray ja1 = new JSONArray();
3812 //                              String str1 = "{\n  \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3813 //                              ;
3814 //                              ja1.add(str1);
3815 //                              JSONArray ja2 = new JSONArray();
3816 //                              String str2 = "{\"template_name\": \"VNFD_vUGW\",\"topology_template\":[{\"plan_name\": \"Normal_E9K\",\"plan_id\": \"Normal_E9K\"}]}";
3817 //                              ja2.add(str2);
3818 //                              JSONObject verTmpObj = ja2.getJSONObject(0);
3819 //                              JSONObject jsObject = new JSONObject();
3820 //                              jsObject.put("downloadUrl", "http://localhost:80");
3821 //                              jsObject.put("csarName", "CSCF");
3822 //                              JSONObject jsEms = new JSONObject();
3823 //                              jsEms.put("emsUuid", "123erbhi-hjdek123");
3824 //                              JSONObject jsCsar = new JSONObject();
3825 //                              jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3826 //                              jsCsar.put("csar_file_name", "Csar_File");
3827 //                              jsCsar.put("emsUuid", jsEms);
3828 //                              JSONObject jsTemp = new JSONObject();
3829 //                              jsTemp.put("template", jsCsar);
3830 //                              js.put("vCSCF", jsTemp);
3831 //                              js.put("vim_info", ja);
3832 //                              js.put("template", verTmpObj);
3833 //                              js.put("templates", ja1);
3834 //                              js.put("packageInfo", jsObject);
3835 //                              return js;
3836 //                      }
3837 //              };
3838 //
3839 //              System.setProperty("catalina.base",
3840 //                              "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3841
3842                 JSONObject vnfpkg = new JSONObject();
3843                 JSONObject vnfpkg1 = new JSONObject();
3844                 vnfpkg.put("name", "test");
3845                 JSONObject obj = new JSONObject();
3846                 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3847                 obj.put("csar_file_name", "casrFile");
3848                 vnfpkg.put("template", obj);
3849                 Map<String, String> paramsMap = new HashMap<>();
3850                 paramsMap.put("csarid", "csarid123");
3851                 paramsMap.put("vnfmid", "vnfmid1234");
3852                 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3853                 assertEquals(res.get("retCode"), 200);
3854         }
3855         
3856         
3857         @Test
3858         public void transferFromCsarSI() throws Exception {
3859                 
3860                 AdapterResourceManager arManager = new AdapterResourceManager();
3861                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3862                 m.setAccessible(true);
3863                 m.invoke(arManager, "CSCF_SI");
3864         } 
3865         
3866         @Test
3867         public void transferFromCsarCSCF() throws Exception {
3868                 
3869                 AdapterResourceManager arManager = new AdapterResourceManager();
3870                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3871                 m.setAccessible(true);
3872                 m.invoke(arManager, "CSCF");
3873         }
3874         
3875         @Test
3876         public void transferFromCsarMME() throws Exception {
3877                 
3878                 AdapterResourceManager arManager = new AdapterResourceManager();
3879                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3880                 m.setAccessible(true);
3881                 m.invoke(arManager, "MME");
3882         } 
3883         
3884         @Test
3885         public void transferFromCsarSPGW() throws Exception {
3886                 
3887                 AdapterResourceManager arManager = new AdapterResourceManager();
3888                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3889                 m.setAccessible(true);
3890                 m.invoke(arManager, "SPGW");
3891         } 
3892         
3893         @Test
3894         public void transferFromCsarHSS() throws Exception {
3895                 
3896                 AdapterResourceManager arManager = new AdapterResourceManager();
3897                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3898                 m.setAccessible(true);
3899                 m.invoke(arManager, "HSS");
3900         } 
3901         
3902         @Test
3903         public void transferFromCsarSBC() throws Exception {
3904                 
3905                 AdapterResourceManager arManager = new AdapterResourceManager();
3906                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3907                 m.setAccessible(true);
3908                 m.invoke(arManager, "SBC");
3909         }
3910         
3911         @Test
3912         public void transferFromCsarPCRF() throws Exception {
3913                 
3914                 AdapterResourceManager arManager = new AdapterResourceManager();
3915                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3916                 m.setAccessible(true);
3917                 m.invoke(arManager, "PCRF");
3918         }
3919         
3920         @Test
3921         public void transferFromCsarTAS() throws Exception {
3922                 
3923                 AdapterResourceManager arManager = new AdapterResourceManager();
3924                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3925                 m.setAccessible(true);
3926                 m.invoke(arManager, "TAS");
3927         }
3928         
3929         @Test
3930         public void transferFromCsar() throws Exception {
3931                 
3932                 AdapterResourceManager arManager = new AdapterResourceManager();
3933                 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3934                 m.setAccessible(true);
3935                 m.invoke(arManager, "transferFromCsar");
3936         }
3937         
3938         @Test
3939         public void uploadCsar()  throws Exception {
3940                 JSONObject vnfpkg = new JSONObject();
3941                 vnfpkg.put("ftp_server_ip","127.0.0.1");
3942                 vnfpkg.put("ftp_username","ftp_username");
3943                 vnfpkg.put("ftp_password","ftp_password");
3944                 AdapterResourceManager arManager = new AdapterResourceManager();
3945                 Method m =AdapterResourceManager.class.getDeclaredMethod("uploadCsar", new Class[] {JSONObject.class,String.class});
3946                 m.setAccessible(true);
3947                 m.invoke(arManager, vnfpkg,"csarfilepath");
3948                 
3949         }
3950         
3951         
3952         @Test
3953         public void readVnfdIdInfoFromJson() throws Exception{
3954                 AdapterResourceManager arManager = new AdapterResourceManager();
3955                 Method m =AdapterResourceManager.class.getDeclaredMethod("readVnfdIdInfoFromJson");     
3956                 m.setAccessible(true);
3957                 m.invoke(arManager);
3958         }
3959         
3960 }