2 * Copyright 2018 ZTE Corporation.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onap.aai.esr.wrapper;
18 import static org.junit.Assert.assertEquals;
19 import java.util.ArrayList;
20 import java.util.List;
21 import javax.ws.rs.core.Response;
22 import org.junit.Assert;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.onap.aai.esr.common.MsbConfig;
26 import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
27 import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
28 import org.onap.aai.esr.util.ExtsysUtil;
30 public class VnfmManagerWrapperTest {
32 private static VnfmManagerWrapper vnfmManagerWrapper;
34 MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
38 public void setUp() throws Exception {
39 vnfmManagerWrapper = VnfmManagerWrapper.getInstance();
43 public void test_registerVnfm() {
44 ExternalSystemProxy.isTest = true;
45 VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
46 vnfmRegisterInfo.setVimId("987654");
47 vnfmRegisterInfo.setVersion("v1");
48 vnfmRegisterInfo.setVendor("zte");
49 vnfmRegisterInfo.setUserName("onap");
50 vnfmRegisterInfo.setUrl("http://10.11.22.33:8000");
51 vnfmRegisterInfo.setType("vnfm");
52 vnfmRegisterInfo.setPassword("987654");
53 vnfmRegisterInfo.setName("ONAP VNFM");
54 vnfmRegisterInfo.setCertificateUrl("http://11.22.33.44:5000/v3");
55 Response response = vnfmManagerWrapper.registerVnfm(vnfmRegisterInfo);
56 if (response != null) {
57 Assert.assertTrue(response.getStatus() == 200);
59 ExternalSystemProxy.isTest = false;
63 public void test_queryVnfmById() {
64 ExternalSystemProxy.isTest = true;
65 ExtsysUtil extsysUtil = new ExtsysUtil();
66 VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
67 vnfmRegisterInfo.setVimId("987654");
68 vnfmRegisterInfo.setVersion("v1");
69 vnfmRegisterInfo.setVendor("zte");
70 vnfmRegisterInfo.setUserName("onap");
71 vnfmRegisterInfo.setUrl("http://10.11.22.33:8000");
72 vnfmRegisterInfo.setType("vnfm");
73 vnfmRegisterInfo.setPassword("987654");
74 vnfmRegisterInfo.setName("ONAP VNFM");
75 vnfmRegisterInfo.setCertificateUrl("http://11.22.33.44:5000/v3");
76 vnfmRegisterInfo.setVnfmId("123456");
77 Response response = vnfmManagerWrapper.queryVnfmById("123456");
78 if (response != null) {
79 Assert.assertTrue(response.getStatus() == 200);
80 assertEquals(extsysUtil.objectToString(vnfmRegisterInfo), extsysUtil.objectToString(response.getEntity()));
82 ExternalSystemProxy.isTest = false;
86 public void test_queryVnfmList() {
87 ExternalSystemProxy.isTest = true;
88 ExtsysUtil extsysUtil = new ExtsysUtil();
89 List<VnfmRegisterInfo> vnfmList = new ArrayList<>();
90 VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
91 vnfmRegisterInfo.setVimId("987654");
92 vnfmRegisterInfo.setVersion("v1");
93 vnfmRegisterInfo.setVendor("zte");
94 vnfmRegisterInfo.setUserName("onap");
95 vnfmRegisterInfo.setUrl("http://10.11.22.33:8000");
96 vnfmRegisterInfo.setType("vnfm");
97 vnfmRegisterInfo.setPassword("987654");
98 vnfmRegisterInfo.setName("ONAP VNFM");
99 vnfmRegisterInfo.setCertificateUrl("http://11.22.33.44:5000/v3");
100 vnfmRegisterInfo.setVnfmId("123456");
101 vnfmList.add(vnfmRegisterInfo);
102 Response response = vnfmManagerWrapper.queryVnfmList();
103 if (response != null) {
104 Assert.assertTrue(response.getStatus() == 200);
105 assertEquals(extsysUtil.objectToString(vnfmList), extsysUtil.objectToString(response.getEntity()));
107 ExternalSystemProxy.isTest = false;
111 public void test_delVnfm() {
112 ExternalSystemProxy.isTest = true;
113 Response response = vnfmManagerWrapper.delVnfm("123456");
114 if (response != null) {
115 Assert.assertTrue(response.getStatus() == 204);
117 ExternalSystemProxy.isTest = false;
121 public void test_updateVnfm() {
122 ExternalSystemProxy.isTest = true;
123 VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
124 vnfmRegisterInfo.setVimId("987654");
125 vnfmRegisterInfo.setVersion("v1");
126 vnfmRegisterInfo.setVendor("zte");
127 vnfmRegisterInfo.setUserName("onap");
128 vnfmRegisterInfo.setUrl("http://10.11.22.33:8000");
129 vnfmRegisterInfo.setType("vnfm");
130 vnfmRegisterInfo.setPassword("987654");
131 vnfmRegisterInfo.setName("ONAP VNFM");
132 vnfmRegisterInfo.setCertificateUrl("http://11.22.33.44:5000/v3");
133 vnfmRegisterInfo.setVnfmId("123456");
134 Response response = vnfmManagerWrapper.updateVnfm(vnfmRegisterInfo, "123456");
135 if (response != null) {
136 Assert.assertTrue(response.getStatus() == 200);
138 ExternalSystemProxy.isTest = false;