X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fesr-server.git;a=blobdiff_plain;f=esr-mgr%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Futil%2FPnfManagerUtilTest.java;fp=esr-mgr%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Futil%2FPnfManagerUtilTest.java;h=115e8d15cd24e4a3b1a60d8388e5a51ffd1ba8d9;hp=0000000000000000000000000000000000000000;hb=d8db76d816a659b91085d4ae0614895ba1e78b65;hpb=65c65b4e71f73304af2166d6a3021e2c264db60f diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/util/PnfManagerUtilTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/util/PnfManagerUtilTest.java new file mode 100644 index 0000000..115e8d1 --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/util/PnfManagerUtilTest.java @@ -0,0 +1,81 @@ +/** + * Copyright 2018 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.Pnf; +import org.onap.aai.esr.entity.rest.PnfRegisterInfo; +import com.google.gson.Gson; + +public class PnfManagerUtilTest { + + @Test + public void pnf2pnfRegisterInfoTest() { + PnfManagerUtil pnfManagerUtil = new PnfManagerUtil(); + String pnfStr = "{\"pnf-name\": \"pnf1\"," + + "\"pnf-name2\": \"PNF test\"," + + "\"pnf-id\": \"subnetId1-neId1\"," + + "\"equip-type\": \"Test\"," + + "\"equip-vendor\": \"ZTE\"," + + "\"equip-model\": \"pnfdId1\"," + + "\"management-option\": \"emsId1\"," + + "\"in-maint\": false," + + "\"frame-id\": \"121.546-14.22\"}"; + Pnf pnf = new Gson().fromJson(pnfStr, Pnf.class); + PnfRegisterInfo pnfRegisterInfo = pnfManagerUtil.pnf2PnfRegisterInfo(pnf); + String pnfRegisterInfoStr = new ExtsysUtil().objectToString(pnfRegisterInfo); + String expectResult = "{\"pnfId\":\"pnf1\"," + + "\"userLabel\":\"PNF test\"," + + "\"subnetId\":\"subnetId1\"," + + "\"neId\":\"neId1\"," + + "\"managementType\":\"Test\"," + + "\"vendor\":\"ZTE\"," + + "\"pnfdId\":\"pnfdId1\"," + + "\"emsId\":\"emsId1\"," + + "\"lattitude\":\"121.546\"," + + "\"longitude\":\"14.22\"}"; + assertEquals(expectResult, pnfRegisterInfoStr); + } + + @Test + public void pnfRegisterInfo2pnfTest() { + PnfManagerUtil pnfManagerUtil = new PnfManagerUtil(); + PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo(); + pnfRegisterInfo.setPnfId("pnf1"); + pnfRegisterInfo.setUserLabel("PNF test"); + pnfRegisterInfo.setSubnetId("subnetId1"); + pnfRegisterInfo.setNeId("neId1"); + pnfRegisterInfo.setManagementType("Test"); + pnfRegisterInfo.setVendor("ZTE"); + pnfRegisterInfo.setPnfdId("pnfdId1"); + pnfRegisterInfo.setEmsId("emsId1"); + pnfRegisterInfo.setLattitude("121.546"); + pnfRegisterInfo.setLongitude("14.22"); + Pnf pnf = pnfManagerUtil.pnfRegisterInfo2pnf(pnfRegisterInfo); + String expectResult = "{\"pnf-name\":\"pnf1\"," + + "\"pnf-name2\":\"PNF test\"," + + "\"pnf-id\":\"subnetId1-neId1\"," + + "\"equip-type\":\"Test\"," + + "\"equip-vendor\":\"ZTE\"," + + "\"equip-model\":\"pnfdId1\"," + + "\"management-option\":\"emsId1\"," + + "\"in-maint\":false," + + "\"frame-id\":\"121.546-14.22\"}"; + String pnfStr = new ExtsysUtil().objectToString(pnf); + assertEquals(expectResult, pnfStr); + } +}