summaryrefslogtreecommitdiffstats
path: root/esr-mgr
diff options
context:
space:
mode:
authorudhaya chandran <udhayachandran.m@verizon.com>2019-03-21 19:10:06 +0530
committerudhaya chandran <udhayachandran.m@verizon.com>2019-03-21 20:33:56 +0530
commitc0fcc4e347af8ec435cf6e33f50c47a865902f5c (patch)
tree3361d757071155d9bb56fef4836262eba9b219a9 /esr-mgr
parent1864177da8c2b3794204c22e0ba1a54320c4281d (diff)
Add Nfvo external system backend changes in ESR4.0.0-ONAP1.4.0dublin
Change-Id: I6a2bbebf5f750c9e89bb9d88caba9e8bcfa35c25 Signed-off-by: udhaya chandran <udhayachandran.m@verizon.com> Issue-ID: AAI-2206 Depends-on: I71601180d47fe3de71ddbc07a4c54db7b398f520
Diffstat (limited to 'esr-mgr')
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java5
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvo.java61
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoDetail.java69
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoList.java37
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfo.java100
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java44
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java36
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/NfvoRegisterProvider.java54
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/resource/NfvoManager.java142
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/NfvoManagerUtil.java68
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/NfvoManagerWrapper.java175
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoDetailTest.java60
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoListTest.java34
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoTest.java45
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfoTest.java84
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java25
-rw-r--r--esr-mgr/src/test/java/org/onap/aai/esr/wrapper/NfvoManagerWrapperTest.java128
19 files changed, 1169 insertions, 2 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
index 290df15..b45692f 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
@@ -24,6 +24,7 @@ import org.onap.aai.esr.resource.ServiceTest;
import org.onap.aai.esr.resource.ThirdpartySdncManager;
import org.onap.aai.esr.resource.VimManager;
import org.onap.aai.esr.resource.VnfmManager;
+import org.onap.aai.esr.resource.NfvoManager;
import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,6 +59,7 @@ public class ExtsysApp extends Application<ExtsysAppConfiguration> {
environment.jersey().register(new ThirdpartySdncManager());
environment.jersey().register(new VimManager());
environment.jersey().register(new VnfmManager());
+ environment.jersey().register(new NfvoManager());
environment.jersey().register(new PnfManager());
environment.jersey().register(new ServiceTest());
initSwaggerConfig(environment, configuration);
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java b/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java
index a9858e3..4b48c12 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java
@@ -47,6 +47,11 @@ public class MsbConfig {
return msbServerAddr + "/api/aai-externalSystem/v11";
}
+ public static String getExternalSystemAddrV16() {
+ return msbServerAddr + "/api/aai-externalSystem/v16";
+ }
+
+
public static void setExternalSystemAddr(String Addr) {
externalSystemAddr = Addr;
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java b/esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java
index c637c5e..dda54fe 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/common/SystemType.java
@@ -17,5 +17,5 @@
package org.onap.aai.esr.common;
public enum SystemType {
- VNFM, EMS_RESOUCE, EMS_PERFORMANCE, EMS_ALARM, thirdparty_SDNC, VIM
+ VNFM, EMS_RESOUCE, EMS_PERFORMANCE, EMS_ALARM, thirdparty_SDNC, VIM, NFVO
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvo.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvo.java
new file mode 100644
index 0000000..6632db6
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvo.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import java.io.Serializable;
+import com.google.gson.annotations.SerializedName;
+
+public class EsrNfvo implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("nfvo-id")
+ private String nfvoId;
+
+ @SerializedName("resource-version")
+ private String resourceVersion;
+
+ @SerializedName("api-root")
+ private String apiroot;
+
+ public String getNfvoId() {
+ return nfvoId;
+ }
+
+ public void setNfvoId(String nfvoId) {
+ this.nfvoId = nfvoId;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getApiroot() {
+ return apiroot;
+ }
+
+ public void setApiroot(String apiroot) {
+ this.apiroot = apiroot;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoDetail.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoDetail.java
new file mode 100644
index 0000000..89528ff
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoDetail.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import java.io.Serializable;
+import com.google.gson.annotations.SerializedName;
+
+public class EsrNfvoDetail implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("nfvo-id")
+ private String nfvoId;
+
+ @SerializedName("resource-version")
+ private String resourceVersion;
+
+ @SerializedName("api-root")
+ private String apiroot;
+
+ @SerializedName("esr-system-info-list")
+ private EsrSystemInfoList esrSystemInfoList;
+
+ public String getNfvoId() {
+ return nfvoId;
+ }
+
+ public void setNfvoId(String nfvoId) {
+ this.nfvoId = nfvoId;
+ }
+
+ public void setApiroot(String apiroot) {
+ this.apiroot = apiroot;
+ }
+
+ public EsrSystemInfoList getEsrSystemInfoList() {
+ return esrSystemInfoList;
+ }
+
+ public void setEsrSystemInfoList(EsrSystemInfoList esrSystemInfoList) {
+ this.esrSystemInfoList = esrSystemInfoList;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public String getApiroot() {
+ return apiroot;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoList.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoList.java
new file mode 100644
index 0000000..af3cad3
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrNfvoList.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import java.io.Serializable;
+import java.util.List;
+import com.google.gson.annotations.SerializedName;
+
+public class EsrNfvoList implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("esr-nfvo")
+ private List<EsrNfvo> esrNfvo;
+
+ public List<EsrNfvo> getEsrNfvo() {
+ return esrNfvo;
+ }
+
+ public void setEsrNfvo(List<EsrNfvo> esrNfvo) {
+ this.esrNfvo = esrNfvo;
+ }
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfo.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfo.java
new file mode 100644
index 0000000..575cf20
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfo.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.rest;
+
+public class NfvoRegisterInfo {
+
+ private String nfvoId;
+
+ private String name;
+
+ private String apiroot;
+
+ private String vendor;
+
+ private String version;
+
+ private String url;
+
+ private String userName;
+
+ private String password;
+
+ public String getNfvoId() {
+ return nfvoId;
+ }
+
+ public void setNfvoId(String nfvoId) {
+ this.nfvoId = nfvoId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getApiroot() {
+ return apiroot;
+ }
+
+ public void setApiroot(String apiroot) {
+ this.apiroot = apiroot;
+ }
+
+ public String getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(String vendor) {
+ this.vendor = vendor;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
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 bd8c77d..e5b49d6 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
@@ -20,12 +20,13 @@ import org.onap.aai.esr.common.MsbConfig;
import org.onap.aai.esr.entity.aai.EsrEmsDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
import org.onap.aai.esr.exception.ExtsysException;
import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
public class ExternalSystemProxy {
- private static IExternalSystem externalSystem;
+ private static IExternalSystem externalSystem, externalSystemV16;
private static String transactionId = "9999";
private static String fromAppId = "esr-server";
private static String authorization = AaiCommon.getAuthenticationCredentials();
@@ -33,6 +34,8 @@ public class ExternalSystemProxy {
ClientConfig config = new ClientConfig();
externalSystem =
ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class);
+ externalSystemV16 =
+ ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddrV16(), config, IExternalSystem.class);
}
public void registerVnfm(String vnfmId, EsrVnfmDetail esrVnfmDetail) throws ExtsysException {
@@ -70,6 +73,45 @@ public class ExternalSystemProxy {
}
}
+ public void registerNfvo(String nfvoId, EsrNfvoDetail esrNfvoDetail) throws ExtsysException {
+ ClientConfig config = new ClientConfig(new NfvoRegisterProvider());
+ IExternalSystem registerNfvoServiceproxy =
+ ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddrV16(), config, IExternalSystem.class);
+ try {
+ registerNfvoServiceproxy.registerNFVO(transactionId, fromAppId, authorization, nfvoId, esrNfvoDetail);
+ } catch (Exception e) {
+ throw new ExtsysException("PUT NFVO to A&AI failed.", e);
+ }
+ }
+
+ public String queryNfvoDetail(String nfvoId) throws ExtsysException {
+ try {
+ return externalSystemV16.queryNFVODetail(transactionId, fromAppId, authorization, nfvoId);
+ } catch (Exception e) {
+ throw new ExtsysException("Query NFVO detail from A&AI failed.", e);
+ }
+ }
+
+ public String queryNfvoList() throws ExtsysException {
+ try {
+ return externalSystemV16.queryNFVOList(transactionId, fromAppId, authorization);
+ } catch (Exception e) {
+ throw new ExtsysException("Query NFVO list from A&AI failed.", e);
+ }
+ }
+
+ public void deleteNfvo(String nfvoId, String resourceVersion) throws ExtsysException {
+ try {
+ externalSystemV16.deleteNFVO(transactionId, fromAppId, authorization, nfvoId, resourceVersion);
+ } catch (Exception e) {
+ throw new ExtsysException("Delete NFVO from A&AI failed.", e);
+ }
+ }
+
+
+
+
+
public void registerSdnc(String thirdpartySdncId, EsrThirdpartySdncDetail esrSdncDetail) throws ExtsysException {
ClientConfig config = new ClientConfig(new ThirdpartySdncRegisterProvider());
IExternalSystem registerSdncServiceproxy =
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java
index c066654..7e1a425 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java
@@ -28,6 +28,7 @@ import javax.ws.rs.core.MediaType;
import org.onap.aai.esr.entity.aai.EsrEmsDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
import org.onap.aai.esr.exception.ExtsysException;
@Path("/")
@@ -67,6 +68,41 @@ public interface IExternalSystem {
throws ExtsysException;
@PUT
+ @Path("/esr-nfvo-list/esr-nfvo/{nfvo_id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public void registerNFVO(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization,
+ @PathParam("nfvo_id") String nfvoId, EsrNfvoDetail esrNfvoDetail) throws ExtsysException;
+
+ @GET
+ @Path("/esr-nfvo-list/esr-nfvo/{nfvo_id}?depth=all")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public String queryNFVODetail(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization,
+ @PathParam("nfvo_id") String nfvoId) throws ExtsysException;
+
+ @GET
+ @Path("/esr-nfvo-list")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public String queryNFVOList(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization)
+ throws ExtsysException;
+
+ @DELETE
+ @Path("/esr-nfvo-list/esr-nfvo/{nfvo_id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public void deleteNFVO(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization,
+ @PathParam("nfvo_id") String nfvoId, @QueryParam("resource-version") String resourceVersion)
+ throws ExtsysException;
+
+
+
+ @PUT
@Path("/esr-ems-list/esr-ems/{ems_id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/NfvoRegisterProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/NfvoRegisterProvider.java
new file mode 100644
index 0000000..119c8f4
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/NfvoRegisterProvider.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.externalservice.aai;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.gson.Gson;
+
+public class NfvoRegisterProvider implements MessageBodyWriter<EsrNfvoDetail> {
+
+ private static final Logger logger = LoggerFactory.getLogger(NfvoRegisterProvider.class);
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return EsrNfvoDetail.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(EsrNfvoDetail t, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(EsrNfvoDetail t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
+ throws IOException, WebApplicationException {
+ String json = new Gson().toJson(t, EsrNfvoDetail.class);
+ logger.info("the param to register NFVO input is:" + json);
+ entityStream.write(json.getBytes("UTF-8"));
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/NfvoManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/NfvoManager.java
new file mode 100644
index 0000000..412cbf0
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/NfvoManager.java
@@ -0,0 +1,142 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.resource;
+
+import com.codahale.metrics.annotation.Timed;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.eclipse.jetty.http.HttpStatus;
+import org.onap.aai.esr.entity.rest.NfvoRegisterInfo;
+import org.onap.aai.esr.util.ExtsysUtil;
+import org.onap.aai.esr.wrapper.NfvoManagerWrapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("/nfvos")
+@Api(tags = {" nfvo Management "})
+public class NfvoManager {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NfvoManager.class);
+
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
+
+ /**
+ * query all nfvo.
+ */
+ @GET
+ @ApiOperation(value = "get all nfvo ")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response queryNfvoList() {
+ LOGGER.info("start query all nfvo!");
+ return NfvoManagerWrapper.getInstance().queryNfvoList();
+ }
+
+ /**
+ * query nfvo by id.
+ */
+ @Path("/{nfvoId}")
+ @GET
+ @ApiOperation(value = "get nfvo by id")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response queryNfvoById(@ApiParam(value = "nfvo id") @PathParam("nfvoId") String nfvoId) {
+ LOGGER.info("start query nfvo by id." + nfvoId);
+ return NfvoManagerWrapper.getInstance().queryNfvoById(nfvoId);
+ }
+
+ /**
+ * delete nfvo by id.
+ */
+ @Path("/{nfvoId}")
+ @DELETE
+ @ApiOperation(value = "delete a nfvo")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response delNfvo(@ApiParam(value = "nfvo id") @PathParam("nfvoId") String nfvoId) {
+ LOGGER.info("start delete nfvo .id:" + nfvoId);
+ return NfvoManagerWrapper.getInstance().delNfvo(nfvoId);
+ }
+
+ /**
+ * update nfvo by id.
+ */
+ @PUT
+ @Path("/{nfvoId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "update a nfvo")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response updateNfvo(@ApiParam(value = "nfvo", required = true) NfvoRegisterInfo nfvo,
+ @ApiParam(value = "nfvo id", required = true) @PathParam("nfvoId") String nfvoId) {
+ LOGGER.info("start update nfvo .id:" + nfvoId + " info:" + extsysUtil.objectToString(nfvo));
+ return NfvoManagerWrapper.getInstance().updateNfvo(nfvo, nfvoId);
+ }
+
+ /**
+ * add nfvo .
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "create a nfvo")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+ response = String.class)})
+ @Timed
+ public Response registerNfvo(@ApiParam(value = "nfvo", required = true) NfvoRegisterInfo nfvo) {
+ return NfvoManagerWrapper.getInstance().registerNfvo(nfvo);
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/NfvoManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/NfvoManagerUtil.java
new file mode 100644
index 0000000..2768201
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/NfvoManagerUtil.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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 org.onap.aai.esr.common.SystemType;
+import org.onap.aai.esr.entity.aai.EsrSystemInfo;
+import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
+import org.onap.aai.esr.entity.rest.NfvoRegisterInfo;
+
+public class NfvoManagerUtil {
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
+
+ public EsrNfvoDetail nfvoRegisterInfo2EsrNfvo(NfvoRegisterInfo nfvoRegisterInfo) {
+ EsrNfvoDetail esrNfvo = new EsrNfvoDetail();
+ esrNfvo.setNfvoId(extsysUtil.generateId());
+ esrNfvo.setApiroot(nfvoRegisterInfo.getApiroot());
+ EsrSystemInfo authInfo = getAuthInfoFromNfvoRegisterInfo(nfvoRegisterInfo);
+ EsrSystemInfoList esrSystemInfo = extsysUtil.getEsrSystemInfoListFromAuthInfo(authInfo);
+ esrNfvo.setEsrSystemInfoList(esrSystemInfo);
+ return esrNfvo;
+ }
+
+ /**
+ * @param nfvoRegisterInfo nfvo register informantion from portal
+ * @return
+ */
+ private EsrSystemInfo getAuthInfoFromNfvoRegisterInfo(NfvoRegisterInfo nfvoRegisterInfo) {
+ EsrSystemInfo authInfo = new EsrSystemInfo();
+ authInfo.setEsrSystemInfoId(extsysUtil.generateId());
+ authInfo.setSystemName(nfvoRegisterInfo.getName());
+ authInfo.setVendor(nfvoRegisterInfo.getVendor());
+ authInfo.setVersion(nfvoRegisterInfo.getVersion());
+ authInfo.setServiceUrl(nfvoRegisterInfo.getUrl());
+ authInfo.setUserName(nfvoRegisterInfo.getUserName());
+ authInfo.setPassword(nfvoRegisterInfo.getPassword());
+ authInfo.setSystemType(SystemType.NFVO.toString());
+ return authInfo;
+ }
+
+ public NfvoRegisterInfo esrNfvo2NfvoRegisterInfo(EsrNfvoDetail esrNfvo) {
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setNfvoId(esrNfvo.getNfvoId());
+ nfvoRegisterInfo.setApiroot(esrNfvo.getApiroot());
+ EsrSystemInfo authInfo = esrNfvo.getEsrSystemInfoList().getEsrSystemInfo().get(0);
+ nfvoRegisterInfo.setName(authInfo.getSystemName());
+ nfvoRegisterInfo.setPassword(authInfo.getPassword());
+ nfvoRegisterInfo.setUrl(authInfo.getServiceUrl());
+ nfvoRegisterInfo.setUserName(authInfo.getUserName());
+ nfvoRegisterInfo.setVendor(authInfo.getVendor());
+ nfvoRegisterInfo.setVersion(authInfo.getVersion());
+ return nfvoRegisterInfo;
+ }
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/NfvoManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/NfvoManagerWrapper.java
new file mode 100644
index 0000000..f546320
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/NfvoManagerWrapper.java
@@ -0,0 +1,175 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.wrapper;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.core.Response;
+import org.onap.aai.esr.entity.aai.EsrSystemInfo;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
+import org.onap.aai.esr.entity.aai.EsrNfvoList;
+import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
+import org.onap.aai.esr.entity.rest.NfvoRegisterInfo;
+import org.onap.aai.esr.exception.ExceptionUtil;
+import org.onap.aai.esr.exception.ExtsysException;
+import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
+import org.onap.aai.esr.util.NfvoManagerUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.gson.Gson;
+
+public class NfvoManagerWrapper {
+ private static NfvoManagerWrapper NfvoManagerWrapper;
+ private static final Logger LOG = LoggerFactory.getLogger(NfvoManagerWrapper.class);
+
+ private static NfvoManagerUtil nfvoManagerUtil = new NfvoManagerUtil();
+ private static ExternalSystemProxy externalSystemProxy = new ExternalSystemProxy();
+
+ /**
+ * get NfvoManagerWrapper instance.
+ *
+ * @return nfvo manager wrapper instance
+ */
+ public static NfvoManagerWrapper getInstance() {
+ if (NfvoManagerWrapper == null) {
+ NfvoManagerWrapper = new NfvoManagerWrapper(externalSystemProxy);
+ }
+ return NfvoManagerWrapper;
+ }
+
+ public NfvoManagerWrapper(ExternalSystemProxy externalSystemProxy){
+ NfvoManagerWrapper.externalSystemProxy = externalSystemProxy;
+ }
+
+ public Response registerNfvo(NfvoRegisterInfo nfvo) {
+ CommonRegisterResponse result = new CommonRegisterResponse();
+ EsrNfvoDetail esrNfvoDetail = nfvoManagerUtil.nfvoRegisterInfo2EsrNfvo(nfvo);
+ String nfvoId = esrNfvoDetail.getNfvoId();
+ try {
+ externalSystemProxy.registerNfvo(nfvoId, esrNfvoDetail);
+ result.setId(nfvoId);
+ return Response.ok(result).build();
+ } catch (ExtsysException e) {
+ LOG.error("Register NFVO failed !", e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
+ }
+ }
+
+ public Response updateNfvo(NfvoRegisterInfo nfvo, String nfvoId) {
+ CommonRegisterResponse result = new CommonRegisterResponse();
+ EsrNfvoDetail originalEsrNfvoDetail = queryEsrNfvoDetail(nfvoId);
+ EsrNfvoDetail esrNfvoDetail = nfvoManagerUtil.nfvoRegisterInfo2EsrNfvo(nfvo);
+ String resourceVersion = getResourceVersion(nfvoId);
+ esrNfvoDetail.setResourceVersion(resourceVersion);
+ esrNfvoDetail.setNfvoId(nfvoId);
+ EsrSystemInfo originalEsrSystemInfo = originalEsrNfvoDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0);
+ esrNfvoDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0)
+ .setEsrSystemInfoId(originalEsrSystemInfo.getEsrSystemInfoId());
+ esrNfvoDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0)
+ .setResouceVersion(originalEsrSystemInfo.getResouceVersion());
+ try {
+ externalSystemProxy.registerNfvo(nfvoId, esrNfvoDetail);
+ result.setId(nfvoId);
+ return Response.ok(result).build();
+ } catch (ExtsysException e) {
+ LOG.error("Update NFVO failed !", e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
+ }
+ }
+
+ public Response queryNfvoList() {
+ List<NfvoRegisterInfo> nfvoList = new ArrayList<>();
+ EsrNfvoList esrNfvo = new EsrNfvoList();
+ try {
+ String esrNfvoStr = externalSystemProxy.queryNfvoList();
+ esrNfvo = new Gson().fromJson(esrNfvoStr, EsrNfvoList.class);
+ LOG.info("Response from AAI by query NFVO list: " + esrNfvo);
+ nfvoList = getNfvoDetailList(esrNfvo);
+ return Response.ok(nfvoList).build();
+ } catch (ExtsysException e) {
+ LOG.error("Query NFVO list failed !", e);
+ return Response.ok(nfvoList).build();
+ }
+ }
+
+ public Response queryNfvoById(String nfvoId) {
+ NfvoRegisterInfo nfvo = queryNfvoDetail(nfvoId);
+ if (nfvo != null) {
+ return Response.ok(nfvo).build();
+ } else {
+ return Response.ok(nfvo).build();
+ }
+ }
+
+ public Response delNfvo(String nfvoId) {
+ String resourceVersion = getResourceVersion(nfvoId);
+ try {
+ externalSystemProxy.deleteNfvo(nfvoId, resourceVersion);
+ return Response.noContent().build();
+ } catch (ExtsysException e) {
+ LOG.error("Delete NFVO from A&AI failed! NFVO ID: " + nfvoId + "resouce-version:" + resourceVersion, e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
+ }
+ }
+
+ private NfvoRegisterInfo queryNfvoDetail(String nfvoId) {
+ NfvoRegisterInfo nfvo = new NfvoRegisterInfo();
+ EsrNfvoDetail esrNfvoDetail = new EsrNfvoDetail();
+ try {
+ String esrNfvostr = externalSystemProxy.queryNfvoDetail(nfvoId);
+ LOG.info("Response from AAI by query NFVO: " + esrNfvostr);
+ esrNfvoDetail = new Gson().fromJson(esrNfvostr, EsrNfvoDetail.class);
+ nfvo = nfvoManagerUtil.esrNfvo2NfvoRegisterInfo(esrNfvoDetail);
+ } catch (ExtsysException e) {
+ LOG.error("Query NFVO detail failed! NFVO ID: " + nfvoId, e);
+ }
+ return nfvo;
+ }
+
+ private List<NfvoRegisterInfo> getNfvoDetailList(EsrNfvoList esrNfvo) {
+ List<NfvoRegisterInfo> nfvoInfoList = new ArrayList<>();
+ for (int i = 0; i < esrNfvo.getEsrNfvo().size(); i++) {
+ String nfvoId = esrNfvo.getEsrNfvo().get(i).getNfvoId();
+ NfvoRegisterInfo nfvoInfo = queryNfvoDetail(nfvoId);
+ if (nfvoInfo != null) {
+ nfvoInfoList.add(nfvoInfo);
+ }
+ }
+ return nfvoInfoList;
+ }
+
+ private String getResourceVersion(String nfvoId) {
+ String resourceVersion = null;
+ EsrNfvoDetail esrNfvoDetail = queryEsrNfvoDetail(nfvoId);
+ if (esrNfvoDetail != null && esrNfvoDetail.getResourceVersion() != null) {
+ resourceVersion = esrNfvoDetail.getResourceVersion();
+ }
+ return resourceVersion;
+ }
+
+ private EsrNfvoDetail queryEsrNfvoDetail(String nfvoId) {
+ EsrNfvoDetail esrNfvoDetail = new EsrNfvoDetail();
+ try {
+ String esrNfvostr = externalSystemProxy.queryNfvoDetail(nfvoId);
+ LOG.info("Response from AAI by query NFVO: " + esrNfvostr);
+ esrNfvoDetail = new Gson().fromJson(esrNfvostr, EsrNfvoDetail.class);
+ } catch (ExtsysException e) {
+ LOG.error("Query NFVO detail failed! NFVO ID: " + nfvoId, e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
+ }
+ return esrNfvoDetail;
+ }
+}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoDetailTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoDetailTest.java
new file mode 100644
index 0000000..02948cc
--- /dev/null
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoDetailTest.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+
+public class EsrNfvoDetailTest {
+ @Test
+ public void getterAndSetter4nfvoId() {
+ final String nfvoId = "nfvoId-test";
+ EsrNfvoDetail esrNfvo = new EsrNfvoDetail();
+ esrNfvo.setNfvoId(nfvoId);
+ assertEquals(esrNfvo.getNfvoId(), nfvoId);
+ }
+
+ @Test
+ public void getterAndSetter4resourceVersion() {
+ final String resourceVersion = "resourceVersion-test";
+ EsrNfvoDetail esrNfvo = new EsrNfvoDetail();
+ esrNfvo.setResourceVersion(resourceVersion);
+ assertEquals(esrNfvo.getResourceVersion(), resourceVersion);
+ }
+
+ @Test
+ public void getterAndSetter4apiRoot() {
+ final String apiRoot = "apiRoot-test";
+ EsrNfvoDetail esrNfvo = new EsrNfvoDetail();
+ esrNfvo.setApiroot(apiRoot);
+ assertEquals(esrNfvo.getApiroot(), apiRoot);
+ }
+
+ @Test
+ public void getterAndSetter4esrSystemInfoList() {
+ final EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
+ List<EsrSystemInfo> esrSystemInfo = new ArrayList<>();
+ EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo();
+ esrSystemInfoObj.setEsrSystemInfoId("123");
+ esrSystemInfo.add(esrSystemInfoObj);
+ esrSystemInfoList.setEsrSystemInfo(esrSystemInfo);
+ EsrNfvoDetail esrNfvoDetail = new EsrNfvoDetail();
+ esrNfvoDetail.setEsrSystemInfoList(esrSystemInfoList);
+ assertEquals(esrNfvoDetail.getEsrSystemInfoList(), esrSystemInfoList);
+ }
+}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoListTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoListTest.java
new file mode 100644
index 0000000..23ade6a
--- /dev/null
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoListTest.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+
+public class EsrNfvoListTest {
+ @Test
+ public void getterAndSetter4EsrNfvoList() {
+ EsrNfvoList esrNfvoList = new EsrNfvoList();
+ List<EsrNfvo> esrNfvos = new ArrayList<>();
+ EsrNfvo esrNfvo = new EsrNfvo();
+ esrNfvo.setNfvoId("fadasf");
+ esrNfvos.add(esrNfvo);
+ esrNfvoList.setEsrNfvo(esrNfvos);
+ assertEquals(esrNfvoList.getEsrNfvo(), esrNfvos);
+ }
+}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoTest.java
new file mode 100644
index 0000000..70885be
--- /dev/null
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoTest.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.aai;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class EsrNfvoTest {
+ @Test
+ public void getterAndSetter4nfvoId() {
+ final String nfvoId = "nfvoId-test";
+ EsrNfvo esrNfvo = new EsrNfvo();
+ esrNfvo.setNfvoId(nfvoId);
+ assertEquals(esrNfvo.getNfvoId(), nfvoId);
+ }
+
+ @Test
+ public void getterAndSetter4resourceVersion() {
+ final String resourceVersion = "resourceVersion-test";
+ EsrNfvo esrNfvo = new EsrNfvo();
+ esrNfvo.setResourceVersion(resourceVersion);
+ assertEquals(esrNfvo.getResourceVersion(), resourceVersion);
+ }
+
+ @Test
+ public void getterAndSetter4apiRoot() {
+ final String apiRoot = "apiRoot-test";
+ EsrNfvo esrNfvo = new EsrNfvo();
+ esrNfvo.setApiroot(apiRoot);
+ assertEquals(esrNfvo.getApiroot(), apiRoot);
+ }
+}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfoTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfoTest.java
new file mode 100644
index 0000000..74cc36b
--- /dev/null
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfoTest.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.entity.rest;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class NfvoRegisterInfoTest {
+
+ @Test
+ public void getterAndSetter4nfvoId() {
+ final String nfvoId = "dafadf";
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setNfvoId(nfvoId);
+ assertEquals(nfvoRegisterInfo.getNfvoId(), nfvoId);
+ }
+
+ @Test
+ public void getterAndSetter4name() {
+ final String name = "name-test";
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setName(name);
+ assertEquals(nfvoRegisterInfo.getName(), name);
+ }
+ @Test
+ public void getterAndSetter4apiRoot() {
+ final String apiRoot = "dafadf";
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setApiroot(apiRoot);
+ assertEquals(nfvoRegisterInfo.getApiroot(), apiRoot);
+ }
+
+ @Test
+ public void getterAndSetter4vendor() {
+ final String vendor = "zte";
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setVendor(vendor);
+ assertEquals(nfvoRegisterInfo.getVendor(), vendor);
+ }
+
+ @Test
+ public void getterAndSetter4version() {
+ final String version = "v1.0";
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setVersion(version);
+ assertEquals(nfvoRegisterInfo.getVersion(), version);
+ }
+ @Test
+ public void getterAndSetter4url() {
+ final String url = "/home";
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setUrl(url);
+ assertEquals(nfvoRegisterInfo.getUrl(), url);
+ }
+
+ @Test
+ public void getterAndSetter4userName() {
+ final String userName = "li";
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setUserName(userName);
+ assertEquals(nfvoRegisterInfo.getUserName(), userName);
+ }
+
+ @Test
+ public void getterAndSetter4password() {
+ final String password = "dfaaf";
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setPassword(password);
+ assertEquals(nfvoRegisterInfo.getPassword(), password);
+ }
+}
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java
index da5d27e..fbfc68a 100644
--- a/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java
@@ -21,6 +21,7 @@ import org.onap.aai.esr.common.MsbConfig;
import org.onap.aai.esr.entity.aai.EsrEmsDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
import org.onap.aai.esr.exception.ExtsysException;
public class ExternalSystemProxyTest {
@@ -55,6 +56,30 @@ public class ExternalSystemProxyTest {
}
@Test(expected = ExtsysException.class)
+ public void testRegisterNfvo() throws ExtsysException {
+ EsrNfvoDetail detail = new EsrNfvoDetail();
+ externalSystemProxy.registerNfvo("nfvo-1", detail);
+ }
+
+ @Test(expected = ExtsysException.class)
+ public void testQueryNfvoDetail() throws ExtsysException {
+ externalSystemProxy.queryNfvoDetail("nfvo-1");
+ }
+
+ @Test(expected = ExtsysException.class)
+ public void testQueryNfvoList() throws ExtsysException {
+ externalSystemProxy.queryNfvoList();
+ }
+
+ @Test(expected = ExtsysException.class)
+ public void testDeleteNfvo() throws ExtsysException {
+ externalSystemProxy.deleteNfvo("nfvo-1", "version-1");
+ }
+
+
+
+
+ @Test(expected = ExtsysException.class)
public void testRegisterSdnc() throws ExtsysException {
EsrThirdpartySdncDetail detail = new EsrThirdpartySdncDetail();
externalSystemProxy.registerSdnc("sdnc-1", detail);
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/NfvoManagerWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/NfvoManagerWrapperTest.java
new file mode 100644
index 0000000..b16006a
--- /dev/null
+++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/NfvoManagerWrapperTest.java
@@ -0,0 +1,128 @@
+/**
+ * Copyright 2019 Verizon. All Rights Reserved.
+ *
+ * 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.wrapper;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.core.Response;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.esr.common.MsbConfig;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
+import org.onap.aai.esr.entity.rest.NfvoRegisterInfo;
+import org.onap.aai.esr.exception.ExtsysException;
+import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
+import org.onap.aai.esr.util.ExtsysUtil;
+
+public class NfvoManagerWrapperTest {
+
+ static {
+ MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
+ }
+
+ @Test
+ public void test_registerNfvo() throws ExtsysException {
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setApiroot("abcd/");
+ nfvoRegisterInfo.setVersion("v1");
+ nfvoRegisterInfo.setVendor("zte");
+ nfvoRegisterInfo.setUserName("onap");
+ nfvoRegisterInfo.setUrl("http://ip:8000");
+ nfvoRegisterInfo.setPassword("987654");
+ nfvoRegisterInfo.setName("ONAP NFVO");
+ ExternalSystemProxy mockExternalSystemProxy = Mockito.mock(ExternalSystemProxy.class);
+ Mockito.doNothing().when(mockExternalSystemProxy).registerNfvo(Mockito.anyString(), (EsrNfvoDetail)Mockito.anyObject());
+ NfvoManagerWrapper nfvoManagerWrapper = new NfvoManagerWrapper(mockExternalSystemProxy);
+ Response response = nfvoManagerWrapper.registerNfvo(nfvoRegisterInfo);
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 200);
+ }
+ }
+
+ @Test
+ public void test_queryNfvoById() throws ExtsysException {
+ ExtsysUtil extsysUtil = new ExtsysUtil();
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setApiroot("abcd/");
+ nfvoRegisterInfo.setVersion("v1");
+ nfvoRegisterInfo.setVendor("zte");
+ nfvoRegisterInfo.setUserName("onap");
+ nfvoRegisterInfo.setUrl("http://ip:8000");
+ nfvoRegisterInfo.setPassword("987654");
+ nfvoRegisterInfo.setName("ONAP NFVO");
+ nfvoRegisterInfo.setNfvoId("123456");
+ String esrNfvoDetailStr = "{\"nfvo-id\":\"123456\",\"api-root\":\"abcd/\","
+ + "\"esr-system-info-list\":{"
+ + "\"esr-system-info\":[{\"esr-system-info-id\":\"qwerty\",\"system-name\":\"ONAP NFVO\","
+ + "\"vendor\":\"zte\",\"version\":\"v1\","
+ + "\"service-url\":\"http://ip:8000\",\"user-name\":\"onap\","
+ + "\"password\":\"987654\",\"system-type\":\"NFVO\"}]}}";
+ ExternalSystemProxy mockExternalSystemProxy = Mockito.mock(ExternalSystemProxy.class);
+ Mockito.when(mockExternalSystemProxy.queryNfvoDetail(Mockito.anyString())).thenReturn(esrNfvoDetailStr);
+ NfvoManagerWrapper nfvoManagerWrapper = new NfvoManagerWrapper(mockExternalSystemProxy);
+ Response response = nfvoManagerWrapper.queryNfvoById("123456");
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 200);
+ assertEquals(extsysUtil.objectToString(nfvoRegisterInfo), extsysUtil.objectToString(response.getEntity()));
+ }
+ }
+
+ @Test
+ public void test_queryNfvoList() throws ExtsysException {
+ ExtsysUtil extsysUtil = new ExtsysUtil();
+ List<NfvoRegisterInfo> nfvoList = new ArrayList<>();
+ NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo();
+ nfvoRegisterInfo.setApiroot("abcd/");
+ nfvoRegisterInfo.setVersion("v1");
+ nfvoRegisterInfo.setVendor("zte");
+ nfvoRegisterInfo.setUserName("onap");
+ nfvoRegisterInfo.setUrl("http://ip:8000");
+ nfvoRegisterInfo.setPassword("987654");
+ nfvoRegisterInfo.setName("ONAP NFVO");
+ nfvoRegisterInfo.setNfvoId("123456");
+ nfvoList.add(nfvoRegisterInfo);
+ String nfvoListStr = "{\"esr-nfvo\": [{\"nfvo-id\": \"123456\",\"api-root\": \"abcd/\","
+ + "\"resource-version\": \"1\"}]}";
+ String esrNfvoDetailStr = "{\"nfvo-id\":\"123456\",\"api-root\":\"abcd/\","
+ + "\"esr-system-info-list\":{"
+ + "\"esr-system-info\":[{\"esr-system-info-id\":\"qwerty\",\"system-name\":\"ONAP NFVO\","
+ + "\"vendor\":\"zte\",\"version\":\"v1\","
+ + "\"service-url\":\"http://ip:8000\",\"user-name\":\"onap\","
+ + "\"password\":\"987654\",\"system-type\":\"NFVO\"}]}}";
+ ExternalSystemProxy mockExternalSystemProxy = Mockito.mock(ExternalSystemProxy.class);
+ Mockito.when(mockExternalSystemProxy.queryNfvoList()).thenReturn(nfvoListStr);
+ Mockito.when(mockExternalSystemProxy.queryNfvoDetail(Mockito.anyString())).thenReturn(esrNfvoDetailStr);
+ NfvoManagerWrapper nfvoManagerWrapper = new NfvoManagerWrapper(mockExternalSystemProxy);
+ Response response = nfvoManagerWrapper.queryNfvoList();
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 200);
+ assertEquals(extsysUtil.objectToString(nfvoList), extsysUtil.objectToString(response.getEntity()));
+ }
+ }
+
+ @Test
+ public void test_delNfvo() throws ExtsysException {
+ ExternalSystemProxy mockExternalSystemProxy = Mockito.mock(ExternalSystemProxy.class);
+ Mockito.doNothing().when(mockExternalSystemProxy).deleteNfvo(Mockito.anyString(), Mockito.anyString());
+ NfvoManagerWrapper nfvoManagerWrapper = new NfvoManagerWrapper(mockExternalSystemProxy);
+ Response response = nfvoManagerWrapper.delNfvo("123456");
+ if (response != null) {
+ Assert.assertTrue(response.getStatus() == 204);
+ }
+ }
+}