summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZi Li <li.zi30@zte.com.cn>2018-08-21 08:28:42 +0000
committerZi Li <li.zi30@zte.com.cn>2018-08-21 08:28:50 +0000
commitd8db76d816a659b91085d4ae0614895ba1e78b65 (patch)
treebe78105db26092888dffd5ca6cf037d5cab5bb3d
parent65c65b4e71f73304af2166d6a3021e2c264db60f (diff)
Add unit test for PNF registration function.
Issue-ID: AAI-1500 Change-Id: I2eca9b2baf5be61009c1ad72c91a056107c72bde Signed-off-by: Zi Li <li.zi30@zte.com.cn>
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/PnfListTest.java34
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/PnfTest.java102
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/PnfRegisterInfoTest.java102
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/util/PnfManagerUtilTest.java81
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/wrapper/PnfManagerWrapperTest.java8
5 files changed, 323 insertions, 4 deletions
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/PnfListTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/PnfListTest.java
new file mode 100644
index 0000000..92826b4
--- /dev/null
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/PnfListTest.java
@@ -0,0 +1,34 @@
+/**
+ * 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.entity.aai;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+
+public class PnfListTest {
+ @Test
+ public void getterAndSetter4PnfList() {
+ PnfList pnfList = new PnfList();
+ List<Pnf> pnfs = new ArrayList<>();
+ Pnf pnf = new Pnf();
+ pnf.setPnfName("PNF1");
+ pnfs.add(pnf);
+ pnfList.setPnf(pnfs);
+ assertEquals(pnfList.getPnf(), pnfs);
+ }
+}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/PnfTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/PnfTest.java
new file mode 100644
index 0000000..fbb60e7
--- /dev/null
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/PnfTest.java
@@ -0,0 +1,102 @@
+/**
+ * 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.entity.aai;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class PnfTest {
+
+ @Test
+ public void getterAndSetter4pnfName() {
+ final String pnfName = "pnf1";
+ Pnf pnf = new Pnf();
+ pnf.setPnfName(pnfName);
+ assertEquals(pnf.getPnfName(), pnfName);
+ }
+
+ @Test
+ public void getterAndSetter4pnfName2() {
+ final String pnfName2 = "pnf2";
+ Pnf pnf = new Pnf();
+ pnf.setPnfName2(pnfName2);
+ assertEquals(pnf.getPnfName2(), pnfName2);
+ }
+
+ @Test
+ public void getterAndSetter4pnfId() {
+ final String pnfId = "123";
+ Pnf pnf = new Pnf();
+ pnf.setPnfId(pnfId);
+ assertEquals(pnf.getPnfId(), pnfId);
+ }
+
+ @Test
+ public void getterAndSetter4equipType() {
+ final String equipType = "pnf1";
+ Pnf pnf = new Pnf();
+ pnf.setEquipType(equipType);
+ assertEquals(pnf.getEquipType(), equipType);
+ }
+
+ @Test
+ public void getterAndSetter4equipVendor() {
+ final String equipVendor = "ZTE";
+ Pnf pnf = new Pnf();
+ pnf.setEquipVendor(equipVendor);
+ assertEquals(pnf.getEquipVendor(), equipVendor);
+ }
+
+ @Test
+ public void getterAndSetter4equipModel() {
+ final String equipModel = "pnfdId1";
+ Pnf pnf = new Pnf();
+ pnf.setEquipModel(equipModel);
+ assertEquals(pnf.getEquipModel(), equipModel);
+ }
+
+ @Test
+ public void getterAndSetter4managementOption() {
+ final String managementOption = "emsId1";
+ Pnf pnf = new Pnf();
+ pnf.setManagementOption(managementOption);
+ assertEquals(pnf.getManagementOption(), managementOption);
+ }
+
+ @Test
+ public void getterAndSetter4inMaint() {
+ final boolean inMaint = false;
+ Pnf pnf = new Pnf();
+ pnf.setInMaint(inMaint);
+ assertEquals(pnf.isInMaint(), inMaint);
+ }
+
+ @Test
+ public void getterAndSetter4frameId() {
+ final String frameId = "123.14-41.25";
+ Pnf pnf = new Pnf();
+ pnf.setFrameId(frameId);
+ assertEquals(pnf.getFrameId(), frameId);
+ }
+
+ @Test
+ public void getterAndSetter4resourceVersion() {
+ final String resourceVersion = "1234";
+ Pnf pnf = new Pnf();
+ pnf.setResourceVersion(resourceVersion);
+ assertEquals(pnf.getResourceVersion(), resourceVersion);
+ }
+}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/PnfRegisterInfoTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/PnfRegisterInfoTest.java
new file mode 100644
index 0000000..edc6810
--- /dev/null
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/PnfRegisterInfoTest.java
@@ -0,0 +1,102 @@
+/**
+ * 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.entity.rest;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class PnfRegisterInfoTest {
+
+ @Test
+ public void getterAndSetter4pnfId() {
+ final String pnfId = "PNF1";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setPnfId(pnfId);
+ assertEquals(pnfRegisterInfo.getPnfId(), pnfId);
+ }
+
+ @Test
+ public void getterAndSetter4userLabel() {
+ final String userLabel = "PNF test";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setUserLabel(userLabel);
+ assertEquals(pnfRegisterInfo.getUserLabel(), userLabel);
+ }
+
+ @Test
+ public void getterAndSetter4subnetId() {
+ final String subnetId = "subnetId1";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setSubnetId(subnetId);
+ assertEquals(pnfRegisterInfo.getSubnetId(), subnetId);
+ }
+
+ @Test
+ public void getterAndSetter4neId() {
+ final String neId = "neId1";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setNeId(neId);
+ assertEquals(pnfRegisterInfo.getNeId(), neId);
+ }
+
+ @Test
+ public void getterAndSetter4managementType() {
+ final String managementType = "test";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setManagementType(managementType);
+ assertEquals(pnfRegisterInfo.getManagementType(), managementType);
+ }
+
+ @Test
+ public void getterAndSetter4vendor() {
+ final String vendor = "ZTE";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setVendor(vendor);
+ assertEquals(pnfRegisterInfo.getVendor(), vendor);
+ }
+
+ @Test
+ public void getterAndSetter4pnfdId() {
+ final String pnfdId = "PNFDID1";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setPnfdId(pnfdId);
+ assertEquals(pnfRegisterInfo.getPnfdId(), pnfdId);
+ }
+
+ @Test
+ public void getterAndSetter4emsId() {
+ final String emsId = "emsId1";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setEmsId(emsId);
+ assertEquals(pnfRegisterInfo.getEmsId(), emsId);
+ }
+
+ @Test
+ public void getterAndSetter4lattitude() {
+ final String lattitude = "124.12";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setLattitude(lattitude);
+ assertEquals(pnfRegisterInfo.getLattitude(), lattitude);
+ }
+
+ @Test
+ public void getterAndSetter4longitude() {
+ final String longitude = "145.21";
+ PnfRegisterInfo pnfRegisterInfo = new PnfRegisterInfo();
+ pnfRegisterInfo.setLongitude(longitude);
+ assertEquals(pnfRegisterInfo.getLongitude(), longitude);
+ }
+}
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);
+ }
+}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/PnfManagerWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/PnfManagerWrapperTest.java
index fe944d4..97604ee 100644
--- a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/PnfManagerWrapperTest.java
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/PnfManagerWrapperTest.java
@@ -71,7 +71,7 @@ public class PnfManagerWrapperTest {
pnfRegisterInfo.setEmsId("emsId1");
pnfRegisterInfo.setLattitude("121.546");
pnfRegisterInfo.setLongitude("14.22");
- String PnfStr = "{\"pnf-name\": \"pnf1\","
+ String pnfStr = "{\"pnf-name\": \"pnf1\","
+ "\"pnf-name2\": \"PNF test\","
+ "\"pnf-id\": \"subnetId1-neId1\","
+ "\"equip-type\": \"Test\","
@@ -81,7 +81,7 @@ public class PnfManagerWrapperTest {
+ "\"in-maint\": false,"
+ "\"frame-id\": \"121.546-14.22\"}";
NetworkProxy mockNetworkProxy = Mockito.mock(NetworkProxy.class);
- Mockito.when(mockNetworkProxy.queryPNF(Mockito.anyString())).thenReturn(PnfStr);
+ Mockito.when(mockNetworkProxy.queryPNF(Mockito.anyString())).thenReturn(pnfStr);
PnfManagerWrapper pnfManagerWrapper = new PnfManagerWrapper(mockNetworkProxy);
Response response = pnfManagerWrapper.queryPnfById("pnf1");
if (response != null) {
@@ -149,7 +149,7 @@ public class PnfManagerWrapperTest {
pnfRegisterInfo.setEmsId("emsId1");
pnfRegisterInfo.setLattitude("121.546");
pnfRegisterInfo.setLongitude("14.22");
- String PnfStr = "{\"pnf-name\": \"pnf1\","
+ String pnfStr = "{\"pnf-name\": \"pnf1\","
+ "\"pnf-name2\": \"PNF test\","
+ "\"pnf-id\": \"subnetId1-neId1\","
+ "\"equip-type\": \"Test\","
@@ -160,7 +160,7 @@ public class PnfManagerWrapperTest {
+ "\"frame-id\": \"121.546-14.22\"}";
NetworkProxy mockNetworkProxy = Mockito.mock(NetworkProxy.class);
Mockito.doNothing().when(mockNetworkProxy).registerPnf(Mockito.anyString(), (Pnf)Mockito.anyObject());
- Mockito.when(mockNetworkProxy.queryPNF(Mockito.anyString())).thenReturn(PnfStr);
+ Mockito.when(mockNetworkProxy.queryPNF(Mockito.anyString())).thenReturn(pnfStr);
PnfManagerWrapper vnfmManagerWrapper = new PnfManagerWrapper(mockNetworkProxy);
Response response = vnfmManagerWrapper.updatePnf(pnfRegisterInfo, "pnf1");
if (response != null) {