summaryrefslogtreecommitdiffstats
path: root/esr-mgr/src/test
diff options
context:
space:
mode:
authorLizi <li.zi30@zte.com.cn>2018-01-12 02:20:56 +0000
committerLizi <li.zi30@zte.com.cn>2018-01-12 02:21:07 +0000
commit486ed42762fedbc7cd0cc43704389ed41434eacd (patch)
treeff77b4dd4af47d10d33f678292b0ad64e50a9785 /esr-mgr/src/test
parented26992f976741031237ead3a5dc0565d4318b05 (diff)
Add unit test for ems management.
Change-Id: I21baa89e1517e0f5f208e2ed64d86c4b9c47c6b8 Issue-ID: AAI-637 Signed-off-by: Lizi <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr/src/test')
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java181
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java22
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java22
3 files changed, 204 insertions, 21 deletions
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java
index 78237d7..affd66f 100644
--- a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java
@@ -15,9 +15,21 @@
*/
package org.onap.aai.esr.wrapper;
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.core.Response;
+import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.aai.esr.common.MsbConfig;
+import org.onap.aai.esr.entity.rest.AlarmAddr;
+import org.onap.aai.esr.entity.rest.EmsRegisterInfo;
+import org.onap.aai.esr.entity.rest.FtpAddr;
+import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
+import org.onap.aai.esr.util.ExtsysUtil;
public class EmsManagerWrapperTest {
private static EmsManagerWrapper emsManagerWrapper;
@@ -25,6 +37,16 @@ public class EmsManagerWrapperTest {
MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
}
+ @BeforeClass
+ public static void beforeClass() {
+ ExternalSystemProxy.isTest = true;
+ };
+
+ @AfterClass
+ public static void afterClass() {
+ ExternalSystemProxy.isTest = false;
+ };
+
@Before
public void setUp() throws Exception {
emsManagerWrapper = EmsManagerWrapper.getInstance();
@@ -32,6 +54,163 @@ public class EmsManagerWrapperTest {
@Test
public void test_registerEms() {
-
+
+ EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo();
+ AlarmAddr alarmAddr = new AlarmAddr();
+ FtpAddr resourceAddr = new FtpAddr();
+ FtpAddr performanceAddr = new FtpAddr();
+ alarmAddr.setIp("127.0.0.1");
+ alarmAddr.setPassword("987654");
+ alarmAddr.setPort("5000");
+ alarmAddr.setUser("nancy");
+ resourceAddr.setFtptype("sftp");
+ resourceAddr.setIp("127.0.0.1");
+ resourceAddr.setPassive(true);
+ resourceAddr.setPassword("asdf");
+ resourceAddr.setPort("5000");
+ resourceAddr.setRemotepath("/home/per");
+ resourceAddr.setUser("nancy");
+ performanceAddr.setFtptype("sftp");
+ performanceAddr.setIp("127.0.0.1");
+ performanceAddr.setPassive(true);
+ performanceAddr.setPassword("asdf");
+ performanceAddr.setPort("5000");
+ performanceAddr.setRemotepath("/home/per");
+ performanceAddr.setUser("nancy");
+ emsRegisterInfo.setName("EMS_TEST");
+ emsRegisterInfo.setVendor("ZTE");
+ emsRegisterInfo.setVersion("V1");
+ emsRegisterInfo.setAlarmAddr(alarmAddr);
+ emsRegisterInfo.setResourceAddr(resourceAddr);
+ emsRegisterInfo.setPerformanceAddr(performanceAddr);
+ Response response = emsManagerWrapper.registerEms(emsRegisterInfo);
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 200);
+ }
+ }
+
+ @Test
+ public void test_queryEmsById() {
+ ExtsysUtil extsysUtil = new ExtsysUtil();
+ EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo();
+ AlarmAddr alarmAddr = new AlarmAddr();
+ FtpAddr resourceAddr = new FtpAddr();
+ FtpAddr performanceAddr = new FtpAddr();
+ alarmAddr.setIp("127.0.0.1");
+ alarmAddr.setPassword("987654");
+ alarmAddr.setPort("5000");
+ alarmAddr.setUser("nancy");
+ resourceAddr.setFtptype("sftp");
+ resourceAddr.setIp("127.0.0.1");
+ resourceAddr.setPassive(true);
+ resourceAddr.setPassword("asdf");
+ resourceAddr.setPort("5000");
+ resourceAddr.setRemotepath("/home/per");
+ resourceAddr.setUser("nancy");
+ performanceAddr.setFtptype("sftp");
+ performanceAddr.setIp("127.0.0.1");
+ performanceAddr.setPassive(true);
+ performanceAddr.setPassword("asdf");
+ performanceAddr.setPort("5000");
+ performanceAddr.setRemotepath("/home/per");
+ performanceAddr.setUser("nancy");
+ emsRegisterInfo.setName("EMS_TEST");
+ emsRegisterInfo.setVendor("ZTE");
+ emsRegisterInfo.setVersion("V1");
+ emsRegisterInfo.setAlarmAddr(alarmAddr);
+ emsRegisterInfo.setResourceAddr(resourceAddr);
+ emsRegisterInfo.setPerformanceAddr(performanceAddr);
+ emsRegisterInfo.setEmsId("123456");
+ Response response = emsManagerWrapper.queryEmsById("123456");
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 200);
+ assertEquals(extsysUtil.objectToString(emsRegisterInfo), extsysUtil.objectToString(response.getEntity()));
+ }
+ }
+
+ @Test
+ public void test_queryEmsList() {
+ ExtsysUtil extsysUtil = new ExtsysUtil();
+ List<EmsRegisterInfo> emsList = new ArrayList<>();
+ EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo();
+ AlarmAddr alarmAddr = new AlarmAddr();
+ FtpAddr resourceAddr = new FtpAddr();
+ FtpAddr performanceAddr = new FtpAddr();
+ alarmAddr.setIp("127.0.0.1");
+ alarmAddr.setPassword("987654");
+ alarmAddr.setPort("5000");
+ alarmAddr.setUser("nancy");
+ resourceAddr.setFtptype("sftp");
+ resourceAddr.setIp("127.0.0.1");
+ resourceAddr.setPassive(true);
+ resourceAddr.setPassword("asdf");
+ resourceAddr.setPort("5000");
+ resourceAddr.setRemotepath("/home/per");
+ resourceAddr.setUser("nancy");
+ performanceAddr.setFtptype("sftp");
+ performanceAddr.setIp("127.0.0.1");
+ performanceAddr.setPassive(true);
+ performanceAddr.setPassword("asdf");
+ performanceAddr.setPort("5000");
+ performanceAddr.setRemotepath("/home/per");
+ performanceAddr.setUser("nancy");
+ emsRegisterInfo.setName("EMS_TEST");
+ emsRegisterInfo.setVendor("ZTE");
+ emsRegisterInfo.setVersion("V1");
+ emsRegisterInfo.setAlarmAddr(alarmAddr);
+ emsRegisterInfo.setResourceAddr(resourceAddr);
+ emsRegisterInfo.setPerformanceAddr(performanceAddr);
+ emsRegisterInfo.setEmsId("123456");
+ emsList.add(emsRegisterInfo);
+ Response response = emsManagerWrapper.queryEmsList();
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 200);
+ assertEquals(extsysUtil.objectToString(emsList), extsysUtil.objectToString(response.getEntity()));
+ }
+ }
+
+ @Test
+ public void test_updateEms() {
+ EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo();
+ AlarmAddr alarmAddr = new AlarmAddr();
+ FtpAddr resourceAddr = new FtpAddr();
+ FtpAddr performanceAddr = new FtpAddr();
+ alarmAddr.setIp("127.0.0.1");
+ alarmAddr.setPassword("987654");
+ alarmAddr.setPort("5000");
+ alarmAddr.setUser("nancy");
+ resourceAddr.setFtptype("sftp");
+ resourceAddr.setIp("127.0.0.1");
+ resourceAddr.setPassive(true);
+ resourceAddr.setPassword("asdf");
+ resourceAddr.setPort("5000");
+ resourceAddr.setRemotepath("/home/per");
+ resourceAddr.setUser("nancy");
+ performanceAddr.setFtptype("sftp");
+ performanceAddr.setIp("127.0.0.1");
+ performanceAddr.setPassive(true);
+ performanceAddr.setPassword("asdf");
+ performanceAddr.setPort("5000");
+ performanceAddr.setRemotepath("/home/per");
+ performanceAddr.setUser("nancy");
+ emsRegisterInfo.setName("EMS_TEST");
+ emsRegisterInfo.setVendor("ZTE");
+ emsRegisterInfo.setVersion("V1");
+ emsRegisterInfo.setAlarmAddr(alarmAddr);
+ emsRegisterInfo.setResourceAddr(resourceAddr);
+ emsRegisterInfo.setPerformanceAddr(performanceAddr);
+ emsRegisterInfo.setEmsId("123456");
+ Response response = emsManagerWrapper.updateEms(emsRegisterInfo, "123456");
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 200);
+ }
+ }
+
+ @Test
+ public void test_delEms() {
+ Response response = emsManagerWrapper.delEms("123456");
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 204);
+ }
}
}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java
index e39adc7..0ece8a0 100644
--- a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java
@@ -19,8 +19,10 @@ import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.Response;
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.aai.esr.common.MsbConfig;
import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
@@ -34,6 +36,16 @@ public class ThirdpartySdncWrapperTest {
MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
}
+ @BeforeClass
+ public static void beforeClass() {
+ ExternalSystemProxy.isTest = true;
+ };
+
+ @AfterClass
+ public static void afterClass() {
+ ExternalSystemProxy.isTest = false;
+ };
+
@Before
public void setUp() throws Exception {
thirdpartySdncWrapper = ThirdpartySdncWrapper.getInstance();
@@ -41,7 +53,6 @@ public class ThirdpartySdncWrapperTest {
@Test
public void test_registerThirdpartySdnc() {
- ExternalSystemProxy.isTest = true;
ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
sdncRegisterInfo.setLocation("edge");
sdncRegisterInfo.setName("SDNC_TEST");
@@ -58,22 +69,18 @@ public class ThirdpartySdncWrapperTest {
if (response != null) {
Assert.assertTrue(response.getStatus() == 200);
}
- ExternalSystemProxy.isTest = false;
}
@Test
public void test_delThirdpartySdnc() {
- ExternalSystemProxy.isTest = true;
Response response = thirdpartySdncWrapper.delThirdpartySdnc("123456");
if (response != null) {
Assert.assertTrue(response.getStatus() == 204);
}
- ExternalSystemProxy.isTest = false;
}
@Test
public void test_queryThirdpartySdncById() {
- ExternalSystemProxy.isTest = true;
ExtsysUtil extsysUtil = new ExtsysUtil();
ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
sdncRegisterInfo.setLocation("edge");
@@ -92,12 +99,10 @@ public class ThirdpartySdncWrapperTest {
Assert.assertTrue(response.getStatus() == 200);
assertEquals(extsysUtil.objectToString(sdncRegisterInfo), extsysUtil.objectToString(response.getEntity()));
}
- ExternalSystemProxy.isTest = false;
}
@Test
public void test_queryThirdpartySdncList() {
- ExternalSystemProxy.isTest = true;
ExtsysUtil extsysUtil = new ExtsysUtil();
List<ThirdpartySdncRegisterInfo> sdncList = new ArrayList<>();
ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
@@ -118,12 +123,10 @@ public class ThirdpartySdncWrapperTest {
Assert.assertTrue(response.getStatus() == 200);
assertEquals(extsysUtil.objectToString(sdncList), extsysUtil.objectToString(response.getEntity()));
}
- ExternalSystemProxy.isTest = false;
}
@Test
public void test_updateThirdpartySdnc() {
- ExternalSystemProxy.isTest = true;
ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
sdncRegisterInfo.setLocation("edge");
sdncRegisterInfo.setName("SDNC_TEST");
@@ -140,6 +143,5 @@ public class ThirdpartySdncWrapperTest {
if (response != null) {
Assert.assertTrue(response.getStatus() == 200);
}
- ExternalSystemProxy.isTest = false;
}
}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java
index bfc9afd..1e2abed 100644
--- a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java
@@ -19,8 +19,10 @@ import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.Response;
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.aai.esr.common.MsbConfig;
import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
@@ -34,6 +36,16 @@ public class VnfmManagerWrapperTest {
MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
}
+ @BeforeClass
+ public static void beforeClass() {
+ ExternalSystemProxy.isTest = true;
+ };
+
+ @AfterClass
+ public static void afterClass() {
+ ExternalSystemProxy.isTest = false;
+ };
+
@Before
public void setUp() throws Exception {
vnfmManagerWrapper = VnfmManagerWrapper.getInstance();
@@ -41,7 +53,6 @@ public class VnfmManagerWrapperTest {
@Test
public void test_registerVnfm() {
- ExternalSystemProxy.isTest = true;
VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
vnfmRegisterInfo.setVimId("987654");
vnfmRegisterInfo.setVersion("v1");
@@ -56,12 +67,10 @@ public class VnfmManagerWrapperTest {
if (response != null) {
Assert.assertTrue(response.getStatus() == 200);
}
- ExternalSystemProxy.isTest = false;
}
@Test
public void test_queryVnfmById() {
- ExternalSystemProxy.isTest = true;
ExtsysUtil extsysUtil = new ExtsysUtil();
VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
vnfmRegisterInfo.setVimId("987654");
@@ -79,12 +88,10 @@ public class VnfmManagerWrapperTest {
Assert.assertTrue(response.getStatus() == 200);
assertEquals(extsysUtil.objectToString(vnfmRegisterInfo), extsysUtil.objectToString(response.getEntity()));
}
- ExternalSystemProxy.isTest = false;
}
@Test
public void test_queryVnfmList() {
- ExternalSystemProxy.isTest = true;
ExtsysUtil extsysUtil = new ExtsysUtil();
List<VnfmRegisterInfo> vnfmList = new ArrayList<>();
VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
@@ -104,22 +111,18 @@ public class VnfmManagerWrapperTest {
Assert.assertTrue(response.getStatus() == 200);
assertEquals(extsysUtil.objectToString(vnfmList), extsysUtil.objectToString(response.getEntity()));
}
- ExternalSystemProxy.isTest = false;
}
@Test
public void test_delVnfm() {
- ExternalSystemProxy.isTest = true;
Response response = vnfmManagerWrapper.delVnfm("123456");
if (response != null) {
Assert.assertTrue(response.getStatus() == 204);
}
- ExternalSystemProxy.isTest = false;
}
@Test
public void test_updateVnfm() {
- ExternalSystemProxy.isTest = true;
VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo();
vnfmRegisterInfo.setVimId("987654");
vnfmRegisterInfo.setVersion("v1");
@@ -135,6 +138,5 @@ public class VnfmManagerWrapperTest {
if (response != null) {
Assert.assertTrue(response.getStatus() == 200);
}
- ExternalSystemProxy.isTest = false;
}
}