X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fesr-server.git;a=blobdiff_plain;f=esr-mgr%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Futil%2FExtsysUtilTest.java;h=08468edc482c9f4822e808cc246ece77f81c49b1;hp=7e71571c2a8f4bdae0f67fe9ba0623edbdd10bf3;hb=ed26992f976741031237ead3a5dc0565d4318b05;hpb=f73ad41f58f1f60d00d42a8bc5fc2502a46d62dd 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 index 7e71571..08468ed 100644 --- 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 @@ -16,125 +16,97 @@ package org.onap.aai.esr.util; import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.List; - 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() { - List esrSystemInfos = new ArrayList<>(); - 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); - } + + @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() { + List esrSystemInfos = new ArrayList<>(); + 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); + } }