From: HePeng Date: Tue, 12 Nov 2019 01:29:28 +0000 (+0800) Subject: Close AAI-2618 Issue X-Git-Tag: 1.5.1~6^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fesr-server.git;a=commitdiff_plain;h=7c717d9b4f466b86ab534682096e4d5075965756 Close AAI-2618 Issue No non-vulnerable version exists. AAI does not use default typing. Issue-ID: AAI-2618 Change-Id: I5a78eb2d76d43b4d065f3d998b914d6eca13972a Signed-off-by: HePeng --- diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/util/NfvoManagerUtilTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/util/NfvoManagerUtilTest.java new file mode 100644 index 0000000..1a7e4c8 --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/util/NfvoManagerUtilTest.java @@ -0,0 +1,71 @@ +/** + * Copyright 2019 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. + * Submit by HePeng 10064135 + */ +package org.onap.aai.esr.util; + +import com.google.gson.Gson; +import org.junit.Test; +import org.onap.aai.esr.entity.aai.EsrNfvoDetail; +import org.onap.aai.esr.entity.rest.NfvoRegisterInfo; + +import static org.junit.Assert.assertEquals; + +public class NfvoManagerUtilTest { + @Test + public void nfvoRegisterInfo2EsrNfvoTest() + { + NfvoManagerUtil nfvoManagerUtil=new NfvoManagerUtil(); + NfvoRegisterInfo nfvoRegisterInfo=new NfvoRegisterInfo(); + ExtsysUtil extsysUtil=new ExtsysUtil(); + nfvoRegisterInfo.setNfvoId("123456"); + nfvoRegisterInfo.setApiroot("/api/v1/test"); + nfvoRegisterInfo.setName("NFVO_TEST"); + nfvoRegisterInfo.setVendor("ZTE"); + nfvoRegisterInfo.setVersion("v1"); + nfvoRegisterInfo.setUrl("127.0.0.1"); + nfvoRegisterInfo.setUserName("root"); + nfvoRegisterInfo.setPassword("root"); + EsrNfvoDetail esrNfvoDetail=nfvoManagerUtil.nfvoRegisterInfo2EsrNfvo(nfvoRegisterInfo); + esrNfvoDetail.setNfvoId("123456"); + esrNfvoDetail.setResourceVersion("v2"); + esrNfvoDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0).setEsrSystemInfoId("654321"); + String esrnfvoStr = extsysUtil.objectToString(esrNfvoDetail); + String expect = "{\"nfvo-id\":\"123456\"," + "\"resource-version\":\"v2\"," +"\"api-root\":\"/api/v1/test\"," + + "\"esr-system-info-list\":" + "{\"esr-system-info\":" + "[{\"esr-system-info-id\":\"654321\"," + + "\"system-name\":\"NFVO_TEST\"," + "\"vendor\":\"ZTE\"," + "\"version\":\"v1\"," + "\"service-url\":\"127.0.0.1\"," + + "\"user-name\":\"root\"," + "\"password\":\"root\","+ "\"system-type\":\"NFVO\"}]}}"; + assertEquals(expect,esrnfvoStr); + + } + @Test + public void esrNfvo2NfvoRegisterInfoTest() + { + EsrNfvoDetail esrNfvoDetail=new EsrNfvoDetail(); + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + NfvoManagerUtil nfvoManagerUtil = new NfvoManagerUtil(); + String esrnfvoStr = "{\"nfvo-id\":\"123456\"," + "\"resource-version\":\"v2\"," +"\"api-root\":\"/api/v1/test\"," + + "\"esr-system-info-list\":" + "{\"esr-system-info\":" + "[{\"esr-system-info-id\":\"654321\"," + + "\"system-name\":\"NFVO_TEST\"," + "\"vendor\":\"ZTE\","+ "\"version\":\"v1\"," + "\"service-url\":\"127.0.0.1\"," + + "\"user-name\":\"root\"," + "\"password\":\"root\","+ "\"system-type\":\"NFVO\"}]}}"; + esrNfvoDetail=new Gson().fromJson(esrnfvoStr,EsrNfvoDetail.class); + nfvoRegisterInfo=nfvoManagerUtil.esrNfvo2NfvoRegisterInfo(esrNfvoDetail); + String registerInfoStr = new ExtsysUtil().objectToString(nfvoRegisterInfo); + String expect= "{\"nfvoId\":\"123456\"," + "\"name\":\"NFVO_TEST\"," + "\"apiroot\":\"/api/v1/test\"," + + "\"vendor\":\"ZTE\"," + "\"version\":\"v1\"," +"\"url\":\"127.0.0.1\","+"\"userName\":\"root\"," + + "\"password\":\"root\"}"; + assertEquals(registerInfoStr, expect); + } +}