diff options
author | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-22 15:41:29 +0800 |
---|---|---|
committer | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-22 15:41:29 +0800 |
commit | 63d1b487d078d1828b9dbe6e927f8dc8158d9f3a (patch) | |
tree | df191ac911a3f4e2d216c931d0a31eb711da77f4 /esr-mgr/src/test | |
parent | 8d82ff464d1facf9a948c5a503f1e0245a9182f2 (diff) |
Add unit test for EmsManagerUtil.
Change-Id: Id7e733aa1c7bf8f34c75ecb7fdbf33de0e48e7de
Issue-ID: AAI-367
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr/src/test')
-rw-r--r-- | esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/CloudRegionDetailTest.java | 1 | ||||
-rw-r--r-- | esr-mgr/src/test/java/org/onap/aai/esr/util/EmsManagerUtilTest.java | 179 |
2 files changed, 179 insertions, 1 deletions
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/CloudRegionDetailTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/CloudRegionDetailTest.java index a567901..89cbd95 100644 --- a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/CloudRegionDetailTest.java +++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/CloudRegionDetailTest.java @@ -30,7 +30,6 @@ public class CloudRegionDetailTest { assertEquals(cloudRegion.getCloudOwner(), cloudOwner); } - @Test public void getterAndSetter4CloudRegionId(){ final String cloudRegionId = "cloud-region-id-test"; diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/util/EmsManagerUtilTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/util/EmsManagerUtilTest.java new file mode 100644 index 0000000..ba16be7 --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/util/EmsManagerUtilTest.java @@ -0,0 +1,179 @@ +/** + * Copyright 2017 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.EsrEmsDetail; +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 com.google.gson.Gson; + +public class EmsManagerUtilTest { + + @Test + public void getEsrSystemInfoListFromAuthInfoTest() { + EmsManagerUtil emsManagerUtil = new EmsManagerUtil(); + EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo(); + EsrEmsDetail esrEms = new EsrEmsDetail(); + 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); + esrEms = emsManagerUtil.emsRegisterInfo2EsrEms(emsRegisterInfo); + esrEms.setEmsId("123456"); + esrEms.getEsrSystemInfoList().getEsrSystemInfo().get(0).setEsrSystemInfoId("234567"); + esrEms.getEsrSystemInfoList().getEsrSystemInfo().get(1).setEsrSystemInfoId("345678"); + esrEms.getEsrSystemInfoList().getEsrSystemInfo().get(2).setEsrSystemInfoId("456789"); + String esremsStr = new ExtsysUtil().objectToString(esrEms); + String expect = "{\"ems-id\":\"123456\"," + + "\"esr-system-info-list\":" + + "{\"esr-system-info\":" + + "[{\"esr-system-info-id\":\"234567\"," + + "\"system-name\":\"EMS_TEST\"," + + "\"type\":\"sftp\"," + + "\"vendor\":\"ZTE\"," + + "\"version\":\"V1\"," + + "\"user-name\":\"nancy\"," + + "\"password\":\"asdf\"," + + "\"system-type\":\"EMS_RESOUCE\"," + + "\"ip-address\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"passive\":true," + + "\"remote-path\":\"/home/per\"}," + + "{\"esr-system-info-id\":\"345678\"," + + "\"system-name\":\"EMS_TEST\"," + + "\"type\":\"sftp\"," + + "\"vendor\":\"ZTE\"," + + "\"version\":\"V1\"," + + "\"user-name\":\"nancy\"," + + "\"password\":\"asdf\"," + + "\"system-type\":\"EMS_PERFORMANCE\"," + + "\"ip-address\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"passive\":true," + + "\"remote-path\":\"/home/per\"}," + + "{\"esr-system-info-id\":\"456789\"," + + "\"system-name\":\"EMS_TEST\"," + + "\"vendor\":\"ZTE\"," + + "\"version\":\"V1\"," + + "\"user-name\":\"nancy\"," + + "\"password\":\"987654\"," + + "\"system-type\":\"EMS_ALARM\"," + + "\"ip-address\":\"127.0.0.1\"," + + "\"port\":\"5000\"}]}}"; + assertEquals(expect, esremsStr); + } + + @Test + public void EsrEms2EmsRegisterInfoTest() { + EsrEmsDetail esrEms = new EsrEmsDetail(); + EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo(); + EmsManagerUtil emsManagerUtil = new EmsManagerUtil(); + String esrEmsStr = "{\"ems-id\":\"123456\"," + + "\"esr-system-info-list\":" + + "{\"esr-system-info\":" + + "[{\"esr-system-info-id\":\"234567\"," + + "\"system-name\":\"EMS_TEST\"," + + "\"type\":\"sftp\"," + + "\"vendor\":\"ZTE\"," + + "\"version\":\"V1\"," + + "\"user-name\":\"nancy\"," + + "\"password\":\"asdf\"," + + "\"system-type\":\"EMS_RESOUCE\"," + + "\"ip-address\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"passive\":true," + + "\"remote-path\":\"/home/per\"}," + + "{\"esr-system-info-id\":\"345678\"," + + "\"system-name\":\"EMS_TEST\"," + + "\"type\":\"sftp\"," + + "\"vendor\":\"ZTE\"," + + "\"version\":\"V1\"," + + "\"user-name\":\"nancy\"," + + "\"password\":\"asdf\"," + + "\"system-type\":\"EMS_PERFORMANCE\"," + + "\"ip-address\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"passive\":true," + + "\"remote-path\":\"/home/per\"}," + + "{\"esr-system-info-id\":\"456789\"," + + "\"system-name\":\"EMS_TEST\"," + + "\"vendor\":\"ZTE\"," + + "\"version\":\"V1\"," + + "\"user-name\":\"nancy\"," + + "\"password\":\"987654\"," + + "\"system-type\":\"EMS_ALARM\"," + + "\"ip-address\":\"127.0.0.1\"," + + "\"port\":\"5000\"}]}}"; + esrEms = new Gson().fromJson(esrEmsStr, EsrEmsDetail.class); + emsRegisterInfo = emsManagerUtil.EsrEms2EmsRegisterInfo(esrEms); + String registerInfoStr = new ExtsysUtil().objectToString(emsRegisterInfo); + String expectRegisterInfo = "{\"emsId\":\"123456\"," + + "\"name\":\"EMS_TEST\"," + + "\"vendor\":\"ZTE\"," + + "\"version\":\"V1\"," + + "\"resourceAddr\":{" + + "\"ftptype\":\"sftp\"," + + "\"ip\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"user\":\"nancy\"," + + "\"password\":\"asdf\"," + + "\"remotepath\":\"/home/per\"," + + "\"passive\":true}," + + "\"performanceAddr\":{" + + "\"ftptype\":\"sftp\"," + + "\"ip\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"user\":\"nancy\"," + + "\"password\":\"asdf\"," + + "\"remotepath\":\"/home/per\"," + + "\"passive\":true}," + + "\"alarmAddr\":{" + + "\"ip\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"user\":\"nancy\"," + + "\"password\":\"987654\"}}"; + assertEquals(registerInfoStr, expectRegisterInfo); + } +} |