diff options
author | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-23 15:11:36 +0800 |
---|---|---|
committer | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-23 15:11:36 +0800 |
commit | d0d48600112f9f2341a48f5970d5879c048415a6 (patch) | |
tree | 5a34ccdbf1946c955cf8da835336b21e5f37128d /esr-mgr/src/test | |
parent | e5810e581bfb1fa7fb7783e16a41eb79564e9934 (diff) |
Add unit test case for VNFM register util.
Change-Id: I1324d641812330732a5634c5d7cd74d9aed206c2
Issue-ID: AAI-376
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr/src/test')
-rw-r--r-- | esr-mgr/src/test/java/org/onap/aai/esr/util/VnfmManagerUtilTest.java | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/util/VnfmManagerUtilTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/util/VnfmManagerUtilTest.java new file mode 100644 index 0000000..bc7eea1 --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/util/VnfmManagerUtilTest.java @@ -0,0 +1,97 @@ +/** + * Copyright 2017 ZTE Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.aai.esr.util; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.aai.esr.entity.aai.EsrVnfmDetail; +import org.onap.aai.esr.entity.rest.VnfmRegisterInfo; + +import com.google.gson.Gson; + +public class VnfmManagerUtilTest { + + @Test + public void vnfmRegisterInfo2EsrVnfmTest() { + VnfmManagerUtil vnfmManagerUtil = new VnfmManagerUtil(); + VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo(); + EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail(); + vnfmRegisterInfo.setVimId("987654"); + vnfmRegisterInfo.setVersion("v1"); + vnfmRegisterInfo.setVendor("zte"); + vnfmRegisterInfo.setUserName("onap"); + vnfmRegisterInfo.setUrl("http://10.11.22.33:8000"); + vnfmRegisterInfo.setType("vnfm"); + vnfmRegisterInfo.setPassword("987654"); + vnfmRegisterInfo.setName("ONAP VNFM"); + vnfmRegisterInfo.setCertificateUrl("http://11.22.33.44:5000/v3"); + esrVnfmDetail = vnfmManagerUtil.vnfmRegisterInfo2EsrVnfm(vnfmRegisterInfo); + esrVnfmDetail.setVnfmId("123456"); + esrVnfmDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0).setEsrSystemInfoId("qwerty"); + String esrVnfmDetailStr = new ExtsysUtil().objectToString(esrVnfmDetail); + String expectResult = "{\"vnfm-id\":\"123456\"," + + "\"vim-id\":\"987654\"," + + "\"certificate-url\":\"http://11.22.33.44:5000/v3\"," + + "\"esr-system-info-list\":{" + + "\"esr-system-info\":[{" + + "\"esr-system-info-id\":\"qwerty\"," + + "\"system-name\":\"ONAP VNFM\"," + + "\"type\":\"vnfm\"," + + "\"vendor\":\"zte\"," + + "\"version\":\"v1\"," + + "\"service-url\":\"http://10.11.22.33:8000\"," + + "\"user-name\":\"onap\"," + + "\"password\":\"987654\"," + + "\"system-type\":\"VNFM\"}]}}"; + assertEquals(expectResult, esrVnfmDetailStr); + } + + @Test + public void esrVnfm2VnfmRegisterInfoTest() { + VnfmManagerUtil vnfmManagerUtil = new VnfmManagerUtil(); + VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo(); + EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail(); + String esrVnfmDetailStr = "{\"vnfm-id\":\"123456\"," + + "\"vim-id\":\"987654\"," + + "\"certificate-url\":\"http://11.22.33.44:5000/v3\"," + + "\"esr-system-info-list\":{" + + "\"esr-system-info\":[{" + + "\"esr-system-info-id\":\"qwerty\"," + + "\"system-name\":\"ONAP VNFM\"," + + "\"type\":\"vnfm\"," + + "\"vendor\":\"zte\"," + + "\"version\":\"v1\"," + + "\"service-url\":\"http://10.11.22.33:8000\"," + + "\"user-name\":\"onap\"," + + "\"password\":\"987654\"," + + "\"system-type\":\"VNFM\"}]}}"; + esrVnfmDetail = new Gson().fromJson(esrVnfmDetailStr, EsrVnfmDetail.class); + vnfmRegisterInfo = vnfmManagerUtil.esrVnfm2VnfmRegisterInfo(esrVnfmDetail); + String vnfmRegisterInfoStr = new ExtsysUtil().objectToString(vnfmRegisterInfo); + String expectResult = "{\"vnfmId\":\"123456\"," + + "\"name\":\"ONAP VNFM\"," + + "\"type\":\"vnfm\"," + + "\"vimId\":\"987654\"," + + "\"vendor\":\"zte\"," + + "\"version\":\"v1\"," + + "\"certificateUrl\":\"http://11.22.33.44:5000/v3\"," + + "\"url\":\"http://10.11.22.33:8000\"," + + "\"userName\":\"onap\"," + + "\"password\":\"987654\"}"; + assertEquals(expectResult, vnfmRegisterInfoStr); + } +} |