summaryrefslogtreecommitdiffstats
path: root/esr-mgr
diff options
context:
space:
mode:
Diffstat (limited to 'esr-mgr')
-rw-r--r--esr-mgr/dependency-reduced-pom.xml4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java18
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java21
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java58
4 files changed, 81 insertions, 20 deletions
diff --git a/esr-mgr/dependency-reduced-pom.xml b/esr-mgr/dependency-reduced-pom.xml
index 6feab2a..baf06ac 100644
--- a/esr-mgr/dependency-reduced-pom.xml
+++ b/esr-mgr/dependency-reduced-pom.xml
@@ -3,12 +3,12 @@
<parent>
<artifactId>aai-esr-server</artifactId>
<groupId>org.onap.aai.esr-server</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>esr-mgr</artifactId>
<name>esr-server/esr-mgr</name>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
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 a571369..6c34265 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
@@ -80,6 +80,14 @@ public class ExternalSystemProxy {
}
public static String queryVnfmList() throws ExtsysException {
+ if(isTest) {
+ String vnfmListStr = "{\"esr-vnfm\": "
+ + "[{\"vnfm-id\": \"123456\","
+ + "\"vim-id\": \"987654\","
+ + "\"certificate-url\": \"http://11.22.33.44:5000/v3\","
+ + "\"resource-version\": \"1\"}]}";
+ return vnfmListStr;
+ }
try {
return externalSystemproxy.queryVNFMList(transactionId, fromAppId, authorization);
} catch (Exception e) {
@@ -88,10 +96,12 @@ public class ExternalSystemProxy {
}
public static void deleteVnfm(String vnfmId, String resourceVersion) throws ExtsysException {
- try {
- externalSystemproxy.deleteVNFM(transactionId, fromAppId, authorization, vnfmId, resourceVersion);
- } catch (Exception e) {
- throw new ExtsysException("Delete VNFM from A&AI failed.", e);
+ if(!isTest) {
+ try {
+ externalSystemproxy.deleteVNFM(transactionId, fromAppId, authorization, vnfmId, resourceVersion);
+ } catch (Exception e) {
+ throw new ExtsysException("Delete VNFM from A&AI failed.", e);
+ }
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
index c53a1c8..d46a846 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
@@ -53,8 +53,7 @@ public class VnfmManagerWrapper {
public Response registerVnfm(VnfmRegisterInfo vnfm) {
CommonRegisterResponse result = new CommonRegisterResponse();
- EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail();
- esrVnfmDetail = vnfmManagerUtil.vnfmRegisterInfo2EsrVnfm(vnfm);
+ EsrVnfmDetail esrVnfmDetail = vnfmManagerUtil.vnfmRegisterInfo2EsrVnfm(vnfm);
String vnfmId = esrVnfmDetail.getVnfmId();
try {
ExternalSystemProxy.registerVnfm(vnfmId, esrVnfmDetail);
@@ -68,15 +67,12 @@ public class VnfmManagerWrapper {
public Response updateVnfm(VnfmRegisterInfo vnfm, String vnfmId) {
CommonRegisterResponse result = new CommonRegisterResponse();
- EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail();
- EsrVnfmDetail originalEsrVnfmDetail = new EsrVnfmDetail();
- EsrSystemInfo originalEsrSystemInfo = new EsrSystemInfo();
- originalEsrVnfmDetail = queryEsrVnfmDetail(vnfmId);
- esrVnfmDetail = vnfmManagerUtil.vnfmRegisterInfo2EsrVnfm(vnfm);
+ EsrVnfmDetail originalEsrVnfmDetail = queryEsrVnfmDetail(vnfmId);
+ EsrVnfmDetail esrVnfmDetail = vnfmManagerUtil.vnfmRegisterInfo2EsrVnfm(vnfm);
String resourceVersion = getResourceVersion(vnfmId);
esrVnfmDetail.setResourceVersion(resourceVersion);
esrVnfmDetail.setVnfmId(vnfmId);
- originalEsrSystemInfo = originalEsrVnfmDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0);
+ EsrSystemInfo originalEsrSystemInfo = originalEsrVnfmDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0);
esrVnfmDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0)
.setEsrSystemInfoId(originalEsrSystemInfo.getEsrSystemInfoId());
esrVnfmDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0)
@@ -107,8 +103,7 @@ public class VnfmManagerWrapper {
}
public Response queryVnfmById(String vnfmId) {
- VnfmRegisterInfo vnfm = new VnfmRegisterInfo();
- vnfm = queryVnfmDetail(vnfmId);
+ VnfmRegisterInfo vnfm = queryVnfmDetail(vnfmId);
if (vnfm != null) {
return Response.ok(vnfm).build();
} else {
@@ -145,10 +140,9 @@ public class VnfmManagerWrapper {
private ArrayList<VnfmRegisterInfo> getVnfmDetailList(EsrVnfmList esrVnfm) {
ArrayList<VnfmRegisterInfo> vnfmInfoList = new ArrayList<VnfmRegisterInfo>();
- VnfmRegisterInfo vnfmInfo = new VnfmRegisterInfo();
for (int i = 0; i < esrVnfm.getEsrVnfm().size(); i++) {
String vnfmId = esrVnfm.getEsrVnfm().get(i).getVnfmId();
- vnfmInfo = queryVnfmDetail(vnfmId);
+ VnfmRegisterInfo vnfmInfo = queryVnfmDetail(vnfmId);
if (vnfmInfo != null) {
vnfmInfoList.add(vnfmInfo);
}
@@ -157,9 +151,8 @@ public class VnfmManagerWrapper {
}
private String getResourceVersion (String vnfmId) {
- EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail();
String resourceVersion = null;
- esrVnfmDetail = queryEsrVnfmDetail(vnfmId);
+ EsrVnfmDetail esrVnfmDetail = queryEsrVnfmDetail(vnfmId);
if (esrVnfmDetail != null && esrVnfmDetail.getResourceVersion() != null) {
resourceVersion = esrVnfmDetail.getResourceVersion();
}
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 917fac4..00dc1f7 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
@@ -17,6 +17,8 @@ package org.onap.aai.esr.wrapper;
import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+
import javax.ws.rs.core.Response;
import org.junit.Assert;
@@ -81,4 +83,60 @@ public class VnfmManagerWrapperTest {
}
ExternalSystemProxy.isTest = false;
}
+
+ @Test
+ public void test_queryVnfmList() {
+ ExternalSystemProxy.isTest = true;
+ ExtsysUtil extsysUtil = new ExtsysUtil();
+ ArrayList<VnfmRegisterInfo> vnfmList = new ArrayList<VnfmRegisterInfo>();
+ 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");
+ vnfmList.add(vnfmRegisterInfo);
+ Response response = vnfmManagerWrapper.queryVnfmList();
+ if (response != null) {
+ 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");
+ 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.updateVnfm(vnfmRegisterInfo, "123456");
+ if(response != null) {
+ Assert.assertTrue(response.getStatus() == 200);
+ }
+ ExternalSystemProxy.isTest = false;
+ }
}