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.util;
18 import static org.junit.Assert.assertEquals;
19 import org.junit.Test;
20 import org.onap.aai.esr.entity.aai.Pnf;
21 import org.onap.aai.esr.entity.rest.PnfRegisterInfo;
22 import com.google.gson.Gson;
24 public class PnfManagerUtilTest {
27 public void pnf2pnfRegisterInfoTest() {
28 PnfManagerUtil pnfManagerUtil = new PnfManagerUtil();
29 String pnfStr = "{\"pnf-name\": \"pnf1\","
30 + "\"pnf-name2\": \"PNF test\","
31 + "\"pnf-id\": \"subnetId1-neId1\","
32 + "\"equip-type\": \"Test\","
33 + "\"equip-vendor\": \"ZTE\","
34 + "\"equip-model\": \"pnfdId1\","
35 + "\"management-option\": \"emsId1\","
36 + "\"in-maint\": false,"
37 + "\"frame-id\": \"121.546-14.22\"}";
38 Pnf pnf = new Gson().fromJson(pnfStr, Pnf.class);
39 PnfRegisterInfo pnfRegisterInfo = pnfManagerUtil.pnf2PnfRegisterInfo(pnf);
40 String pnfRegisterInfoStr = new ExtsysUtil().objectToString(pnfRegisterInfo);
41 String expectResult = "{\"pnfId\":\"pnf1\","
42 + "\"userLabel\":\"PNF test\","
43 + "\"subnetId\":\"subnetId1\","
44 + "\"neId\":\"neId1\","
45 + "\"managementType\":\"Test\","
46 + "\"vendor\":\"ZTE\","
47 + "\"pnfdId\":\"pnfdId1\","
48 + "\"emsId\":\"emsId1\","
49 + "\"lattitude\":\"121.546\","
50 + "\"longitude\":\"14.22\"}";
51 assertEquals(expectResult, pnfRegisterInfoStr);
55 public void pnfRegisterInfo2pnfTest() {
56 PnfManagerUtil pnfManagerUtil = new PnfManagerUtil();
57 PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
58 pnfRegisterInfo.setPnfId("pnf1");
59 pnfRegisterInfo.setUserLabel("PNF test");
60 pnfRegisterInfo.setSubnetId("subnetId1");
61 pnfRegisterInfo.setNeId("neId1");
62 pnfRegisterInfo.setManagementType("Test");
63 pnfRegisterInfo.setVendor("ZTE");
64 pnfRegisterInfo.setPnfdId("pnfdId1");
65 pnfRegisterInfo.setEmsId("emsId1");
66 pnfRegisterInfo.setLattitude("121.546");
67 pnfRegisterInfo.setLongitude("14.22");
68 Pnf pnf = pnfManagerUtil.pnfRegisterInfo2pnf(pnfRegisterInfo);
69 String expectResult = "{\"pnf-name\":\"pnf1\","
70 + "\"pnf-name2\":\"PNF test\","
71 + "\"pnf-id\":\"subnetId1-neId1\","
72 + "\"equip-type\":\"Test\","
73 + "\"equip-vendor\":\"ZTE\","
74 + "\"equip-model\":\"pnfdId1\","
75 + "\"management-option\":\"emsId1\","
76 + "\"in-maint\":false,"
77 + "\"frame-id\":\"121.546-14.22\"}";
78 String pnfStr = new ExtsysUtil().objectToString(pnf);
79 assertEquals(expectResult, pnfStr);