diff options
author | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-22 14:29:58 +0800 |
---|---|---|
committer | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-22 14:29:58 +0800 |
commit | 8d82ff464d1facf9a948c5a503f1e0245a9182f2 (patch) | |
tree | 39254b7a1a02bbe087fa78a5f05f4b06fd80245e /esr-mgr/src | |
parent | 500519857b2a3fe08cf812fdae78d81944f5e0c4 (diff) |
Add unit test for ExtsysUtil.
Change-Id: Ie241ce2ae04686c7b30b8873bc336369f60a4727
Issue-ID: AAI-366
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr/src')
-rw-r--r-- | esr-mgr/src/test/java/org/onap/aai/esr/util/ExtsysUtilTest.java | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/util/ExtsysUtilTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/util/ExtsysUtilTest.java new file mode 100644 index 0000000..1bd8a62 --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/util/ExtsysUtilTest.java @@ -0,0 +1,139 @@ +/** + * 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 java.util.ArrayList; + +import org.junit.Test; +import org.onap.aai.esr.entity.aai.EsrSystemInfo; +import org.onap.aai.esr.entity.aai.EsrSystemInfoList; +import org.onap.aai.esr.externalservice.cloud.Tenant; + +public class ExtsysUtilTest { + + @Test + public void objectToStringTest() { + ExtsysUtil extsysUtil = new ExtsysUtil(); + Tenant tenant = new Tenant(); + tenant.setDefaultTenant("admin"); + String tenantStr = "{\"defaultTenant\":\"admin\"}"; + String result = extsysUtil.objectToString(tenant); + assertEquals(tenantStr, result); + } + + + @Test + public void getEsrSystemInfoListFromAuthInfoTest() { + EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo(); + ExtsysUtil extsysUtil = new ExtsysUtil(); + EsrSystemInfoList result = new EsrSystemInfoList(); + esrSystemInfoObj.setCloudDomain("cloudDomain"); + esrSystemInfoObj.setDefaultTenant("admin"); + esrSystemInfoObj.setEsrSystemInfoId("123456"); + esrSystemInfoObj.setIpAddress("127.0.0.1"); + esrSystemInfoObj.setPassive(true); + esrSystemInfoObj.setPassword("qwelk"); + esrSystemInfoObj.setPort("5000"); + esrSystemInfoObj.setProtocol("http"); + esrSystemInfoObj.setRemotePath("/root/test"); + esrSystemInfoObj.setServiceUrl("http://127.0.0.1:8080"); + esrSystemInfoObj.setSslCassert("sslCassert"); + esrSystemInfoObj.setSslInsecure(false); + esrSystemInfoObj.setSystemName("vnfm"); + esrSystemInfoObj.setSystemStatus("normal"); + esrSystemInfoObj.setSystemType("VNFM"); + esrSystemInfoObj.setType("test"); + esrSystemInfoObj.setUserName("root"); + esrSystemInfoObj.setVendor("zte"); + esrSystemInfoObj.setVersion("v1.0"); + result = extsysUtil.getEsrSystemInfoListFromAuthInfo(esrSystemInfoObj); + + String listStr = "{\"esr-system-info\":[{" + + "\"esr-system-info-id\":\"123456\"," + + "\"system-name\":\"vnfm\"," + + "\"type\":\"test\"," + + "\"vendor\":\"zte\"," + + "\"version\":\"v1.0\"," + + "\"service-url\":\"http://127.0.0.1:8080\"," + + "\"user-name\":\"root\"," + + "\"password\":\"qwelk\"," + + "\"system-type\":\"VNFM\"," + + "\"protocol\":\"http\"," + + "\"ssl-cassert\":\"sslCassert\"," + + "\"ssl-insecure\":false," + + "\"ip-address\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"cloud-domain\":\"cloudDomain\"," + + "\"default-tenant\":\"admin\"," + + "\"passive\":true," + + "\"remote-path\":\"/root/test\"," + + "\"system-status\":\"normal\"}]}"; + assertEquals(extsysUtil.objectToString(result), listStr); + } + + @Test + public void getEsrSystemInfoListFromAuthInfoListTest() { + ArrayList<EsrSystemInfo> esrSystemInfos = new ArrayList<EsrSystemInfo>(); + EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList(); + EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo(); + ExtsysUtil extsysUtil = new ExtsysUtil(); + esrSystemInfoObj.setCloudDomain("cloudDomain"); + esrSystemInfoObj.setDefaultTenant("admin"); + esrSystemInfoObj.setEsrSystemInfoId("123456"); + esrSystemInfoObj.setIpAddress("127.0.0.1"); + esrSystemInfoObj.setPassive(true); + esrSystemInfoObj.setPassword("qwelk"); + esrSystemInfoObj.setPort("5000"); + esrSystemInfoObj.setProtocol("http"); + esrSystemInfoObj.setRemotePath("/root/test"); + esrSystemInfoObj.setServiceUrl("http://127.0.0.1:8080"); + esrSystemInfoObj.setSslCassert("sslCassert"); + esrSystemInfoObj.setSslInsecure(false); + esrSystemInfoObj.setSystemName("vnfm"); + esrSystemInfoObj.setSystemStatus("normal"); + esrSystemInfoObj.setSystemType("VNFM"); + esrSystemInfoObj.setType("test"); + esrSystemInfoObj.setUserName("root"); + esrSystemInfoObj.setVendor("zte"); + esrSystemInfoObj.setVersion("v1.0"); + esrSystemInfos.add(esrSystemInfoObj); + esrSystemInfoList.setEsrSystemInfo(esrSystemInfos); + + String listStr = "{\"esr-system-info\":[{" + + "\"esr-system-info-id\":\"123456\"," + + "\"system-name\":\"vnfm\"," + + "\"type\":\"test\"," + + "\"vendor\":\"zte\"," + + "\"version\":\"v1.0\"," + + "\"service-url\":\"http://127.0.0.1:8080\"," + + "\"user-name\":\"root\"," + + "\"password\":\"qwelk\"," + + "\"system-type\":\"VNFM\"," + + "\"protocol\":\"http\"," + + "\"ssl-cassert\":\"sslCassert\"," + + "\"ssl-insecure\":false," + + "\"ip-address\":\"127.0.0.1\"," + + "\"port\":\"5000\"," + + "\"cloud-domain\":\"cloudDomain\"," + + "\"default-tenant\":\"admin\"," + + "\"passive\":true," + + "\"remote-path\":\"/root/test\"," + + "\"system-status\":\"normal\"}]}"; + assertEquals(extsysUtil.objectToString(esrSystemInfoList), listStr); + } +} |