diff options
author | 2018-01-09 12:43:30 +0000 | |
---|---|---|
committer | 2018-01-09 12:44:26 +0000 | |
commit | 4bc5af16cefb4c33f83bf499b385c94e0c850595 (patch) | |
tree | 781151b7460fac7b82998e2c3caa95e46a5b27d3 | |
parent | 84c2147a46842e37c4e73c3bf19af9036371253f (diff) |
Add unit test for query vnfm by ID.
Change-Id: I9ad13cf69cff5764173e3c78ed97f4e44df9dcc2
Issue-ID: AAI-500
Signed-off-by: Lizi <li.zi30@zte.com.cn>
-rw-r--r-- | esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java | 17 | ||||
-rw-r--r-- | esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java | 28 |
2 files changed, 43 insertions, 2 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java index a4c80eb..a571369 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java @@ -55,6 +55,23 @@ public class ExternalSystemProxy { } public static String queryVnfmDetail(String vnfmId) throws ExtsysException { + if(isTest) { + String esrVnfmDetailStr = "{\"vnfm-id\":\"123456\"," + + "\"vim-id\":\"987654\"," + + "\"certificate-url\":\"http://11.22.33.44:5000/v3\"," + + "\"esr-system-info-list\":{" + + "\"esr-system-info\":[{" + + "\"esr-system-info-id\":\"qwerty\"," + + "\"system-name\":\"ONAP VNFM\"," + + "\"type\":\"vnfm\"," + + "\"vendor\":\"zte\"," + + "\"version\":\"v1\"," + + "\"service-url\":\"http://10.11.22.33:8000\"," + + "\"user-name\":\"onap\"," + + "\"password\":\"987654\"," + + "\"system-type\":\"VNFM\"}]}}"; + return esrVnfmDetailStr; + } try { return externalSystemproxy.queryVNFMDetail(transactionId, fromAppId, authorization, vnfmId); } catch (Exception e) { 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 5952763..917fac4 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 @@ -15,6 +15,8 @@ */ package org.onap.aai.esr.wrapper; +import static org.junit.Assert.assertEquals; + import javax.ws.rs.core.Response; import org.junit.Assert; @@ -23,6 +25,7 @@ import org.junit.Test; import org.onap.aai.esr.common.MsbConfig; import org.onap.aai.esr.entity.rest.VnfmRegisterInfo; import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy; +import org.onap.aai.esr.util.ExtsysUtil; public class VnfmManagerWrapperTest { @@ -55,6 +58,27 @@ public class VnfmManagerWrapperTest { } ExternalSystemProxy.isTest = false; } - - + + @Test + public void test_queryVnfmById() { + ExternalSystemProxy.isTest = true; + ExtsysUtil extsysUtil = new ExtsysUtil(); + VnfmRegisterInfo vnfmRegisterInfo = new VnfmRegisterInfo(); + vnfmRegisterInfo.setVimId("987654"); + vnfmRegisterInfo.setVersion("v1"); + vnfmRegisterInfo.setVendor("zte"); + vnfmRegisterInfo.setUserName("onap"); + vnfmRegisterInfo.setUrl("http://10.11.22.33:8000"); + vnfmRegisterInfo.setType("vnfm"); + vnfmRegisterInfo.setPassword("987654"); + vnfmRegisterInfo.setName("ONAP VNFM"); + vnfmRegisterInfo.setCertificateUrl("http://11.22.33.44:5000/v3"); + vnfmRegisterInfo.setVnfmId("123456"); + Response response = vnfmManagerWrapper.queryVnfmById("123456"); + if (response != null) { + Assert.assertTrue(response.getStatus() == 200); + assertEquals(extsysUtil.objectToString(vnfmRegisterInfo), extsysUtil.objectToString(response.getEntity())); + } + ExternalSystemProxy.isTest = false; + } } |