aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java100
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java147
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java20
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java17
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java99
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java43
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java148
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java63
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java8
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/ShallowBeanCopy.java89
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java77
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java144
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java23
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java31
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java13
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/esr-system-info.json12
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/esr-vnfm.json5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf.json3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/vServer.json5
21 files changed, 1032 insertions, 21 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java
index d7635f2b..f5b411d1 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java
@@ -19,19 +19,23 @@
*/
package org.onap.so.aaisimulator.controller;
+import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGION;
import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGIONS;
+import static org.onap.so.aaisimulator.utils.Constants.ESR_SYSTEM_INFO_LIST;
import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getHeaders;
-import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.CloudRegion;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.Tenant;
+import org.onap.aai.domain.yang.Vserver;
import org.onap.so.aaisimulator.models.CloudRegionKey;
import org.onap.so.aaisimulator.service.providers.CloudRegionCacheServiceProvider;
import org.onap.so.aaisimulator.utils.HttpServiceUtils;
@@ -144,7 +148,7 @@ public class CloudRegionsController {
if (tenant.getResourceVersion() == null || tenant.getResourceVersion().isEmpty()) {
tenant.setResourceVersion(getResourceVersion());
}
- if (cacheServiceProvider.putTenant(key, tenant)) {
+ if (cacheServiceProvider.putTenant(key, tenantId, tenant)) {
return ResponseEntity.accepted().build();
}
}
@@ -187,7 +191,7 @@ public class CloudRegionsController {
if (relationship.getRelatedLink() != null) {
final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
final HttpHeaders incomingHeader = getHeaders(request);
- boolean result = cacheServiceProvider.addRelationShip(incomingHeader, targetBaseUrl,
+ final boolean result = cacheServiceProvider.addRelationShip(incomingHeader, targetBaseUrl,
request.getRequestURI(), key, tenantId, relationship);
if (result) {
LOGGER.info("added created bi directional relationship with {}", relationship.getRelatedLink());
@@ -198,4 +202,94 @@ public class CloudRegionsController {
LOGGER.error("Unable to add relationship for related link: {}", relationship.getRelatedLink());
return getRequestErrorResponseEntity(request, CLOUD_REGION);
}
+
+ @PutMapping(value = "{cloud-owner}/{cloud-region-id}/esr-system-info-list/esr-system-info/{esr-system-info-id}",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putEsrSystemInfo(@RequestBody final EsrSystemInfo esrSystemInfo,
+ @PathVariable("esr-system-info-id") final String esrSystemInfoId,
+ @PathVariable("cloud-owner") final String cloudOwner,
+ @PathVariable("cloud-region-id") final String cloudRegionId, final HttpServletRequest request) {
+
+ final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+
+ LOGGER.info("Will put esrSystemInfo for 'key': {} ...", key);
+
+ if (esrSystemInfo.getResourceVersion() == null || esrSystemInfo.getResourceVersion().isEmpty()) {
+ esrSystemInfo.setResourceVersion(getResourceVersion());
+
+ }
+
+ if (cacheServiceProvider.putEsrSystemInfo(key, esrSystemInfoId, esrSystemInfo)) {
+ LOGGER.info("Successfully added EsrSystemInfo key : {} ...", key, esrSystemInfo);
+ return ResponseEntity.accepted().build();
+ }
+ LOGGER.error("Unable to add EsrSystemInfo in cache for key : {} ...", key);
+
+ return getRequestErrorResponseEntity(request, ESR_SYSTEM_INFO_LIST);
+ }
+
+ @GetMapping(value = "{cloud-owner}/{cloud-region-id}/esr-system-info-list",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getEsrSystemInfoList(@PathVariable("cloud-owner") final String cloudOwner,
+ @PathVariable("cloud-region-id") final String cloudRegionId, final HttpServletRequest request) {
+ final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+ LOGGER.info("Retrieving EsrSystemInfoList using key : {} ...", key);
+ if (key.isValid()) {
+ final Optional<EsrSystemInfoList> optional = cacheServiceProvider.getEsrSystemInfoList(key);
+ if (optional.isPresent()) {
+ final EsrSystemInfoList esrSystemInfoList = optional.get();
+ LOGGER.info("found EsrSystemInfoList {} in cache", esrSystemInfoList);
+ return ResponseEntity.ok(esrSystemInfoList);
+ }
+ }
+ LOGGER.error("Unable to find EsrSystemInfoList in cache using key : {} ...", key);
+ return getRequestErrorResponseEntity(request, CLOUD_REGION);
+ }
+
+ @PutMapping(value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putVserver(@RequestBody final Vserver vServer,
+ @PathVariable("cloud-owner") final String cloudOwner,
+ @PathVariable("cloud-region-id") final String cloudRegionId,
+ @PathVariable("tenant-id") final String tenantId, @PathVariable("vserver-id") final String vServerId,
+ final HttpServletRequest request) {
+
+ final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+ if (vServer.getResourceVersion() == null || vServer.getResourceVersion().isEmpty()) {
+ vServer.setResourceVersion(getResourceVersion());
+ }
+ LOGGER.info("Will put Vserver in cache using using key: {}, tenantId: {}, vServerId: {} ...", key, tenantId,
+ vServerId);
+
+ if (cacheServiceProvider.putVserver(key, tenantId, vServerId, vServer)) {
+ LOGGER.info("Successfully added Vserver for key: {}, tenantId: {}, vServerId: {} ...", key, tenantId,
+ vServerId);
+ return ResponseEntity.accepted().build();
+ }
+ LOGGER.error("Unable to add Vserver in cache using key: {}, tenantId: {}, vServerId: {}", key, tenantId,
+ vServerId);
+ return getRequestErrorResponseEntity(request, CLOUD_REGION);
+ }
+
+ @GetMapping(value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getVserver(@PathVariable("cloud-owner") final String cloudOwner,
+ @PathVariable("cloud-region-id") final String cloudRegionId,
+ @PathVariable("tenant-id") final String tenantId, @PathVariable("vserver-id") final String vServerId,
+ final HttpServletRequest request) {
+
+ final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+ LOGGER.info("Retrieving Vserver using key: {}, tenant-id: {} and vserver-id: {}...", key, tenantId, vServerId);
+ final Optional<Vserver> optional = cacheServiceProvider.getVserver(key, tenantId, vServerId);
+ if (optional.isPresent()) {
+ final Vserver vServer = optional.get();
+ LOGGER.info("found Vserver {} in cache", vServer);
+ return ResponseEntity.ok(vServer);
+ }
+ LOGGER.error("Unable to find Vserver in cache using key: {}, tenant-id: {} and vserver-id: {}...", key,
+ tenantId, vServerId);
+ return getRequestErrorResponseEntity(request, CLOUD_REGION);
+ }
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java
new file mode 100644
index 00000000..efe5b207
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.controller;
+
+import static org.onap.so.aaisimulator.utils.Constants.ESR_SYSTEM_INFO;
+import static org.onap.so.aaisimulator.utils.Constants.ESR_SYSTEM_INFO_LIST;
+import static org.onap.so.aaisimulator.utils.Constants.ESR_VNFM;
+import static org.onap.so.aaisimulator.utils.Constants.EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL;
+import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
+import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
+import java.util.List;
+import java.util.Optional;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrVnfm;
+import org.onap.aai.domain.yang.EsrVnfmList;
+import org.onap.so.aaisimulator.service.providers.ExternalSystemCacheServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Controller
+@RequestMapping(path = EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL)
+public class ExternalSystemEsrController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ExternalSystemEsrController.class);
+
+ private final ExternalSystemCacheServiceProvider cacheServiceProvider;
+
+ @Autowired
+ public ExternalSystemEsrController(final ExternalSystemCacheServiceProvider cacheServiceProvider) {
+ this.cacheServiceProvider = cacheServiceProvider;
+ }
+
+ @PutMapping(value = "esr-vnfm/{vnfm-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putEsrVnfm(@RequestBody final EsrVnfm esrVnfm,
+ @PathVariable("vnfm-id") final String vnfmId, final HttpServletRequest request) {
+ LOGGER.info("Will put esr-vnfm to cache for 'vnfm id': {} ...", esrVnfm.getVnfmId());
+
+ if (esrVnfm.getResourceVersion() == null || esrVnfm.getResourceVersion().isEmpty()) {
+ esrVnfm.setResourceVersion(getResourceVersion());
+
+ }
+ cacheServiceProvider.putEsrVnfm(vnfmId, esrVnfm);
+ return ResponseEntity.accepted().build();
+ }
+
+ @GetMapping(value = "esr-vnfm/{vnfm-id}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getEsrVnfm(@PathVariable("vnfm-id") final String vnfmId,
+ final HttpServletRequest request) {
+ LOGGER.info("Will retrieve ESR VNFM for 'vnfm id': {} ...", vnfmId);
+
+ final Optional<EsrVnfm> optional = cacheServiceProvider.getEsrVnfm(vnfmId);
+ if (optional.isPresent()) {
+ final EsrVnfm esrVnfm = optional.get();
+ LOGGER.info("found esrVnfm {} in cache", esrVnfm);
+ return ResponseEntity.ok(esrVnfm);
+ }
+
+ LOGGER.error("Couldn't Esr Vnfm for 'vnfm id': {} ...", vnfmId);
+ return getRequestErrorResponseEntity(request, ESR_VNFM);
+ }
+
+ @GetMapping(produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getEsrVnfmList(final HttpServletRequest request) {
+ LOGGER.info("Will retrieve a list of all ESR VNFMs");
+
+ final List<EsrVnfm> esrVnfms = cacheServiceProvider.getAllEsrVnfm();
+ LOGGER.info("found {} Esr Vnfms in cache", esrVnfms.size());
+
+ final EsrVnfmList esrVnfmList = new EsrVnfmList();
+ esrVnfmList.getEsrVnfm().addAll(esrVnfms);
+
+ return ResponseEntity.ok(esrVnfmList);
+ }
+
+ @PutMapping(value = "esr-vnfm/{vnfm-id}/esr-system-info-list/esr-system-info/{esr-system-info-id}",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putEsrSystemInfo(@RequestBody final EsrSystemInfo esrSystemInfo,
+ @PathVariable("vnfm-id") final String vnfmId,
+ @PathVariable("esr-system-info-id") final String esrSystemInfoId, final HttpServletRequest request) {
+ LOGGER.info("Will put esrSystemInfo for 'vnfm id': {} and 'esr-system-info-id': {} ...", vnfmId, esrSystemInfo);
+
+ if (esrSystemInfo.getResourceVersion() == null || esrSystemInfo.getResourceVersion().isEmpty()) {
+ esrSystemInfo.setResourceVersion(getResourceVersion());
+
+ }
+
+ if (cacheServiceProvider.putEsrSystemInfo(vnfmId, esrSystemInfoId, esrSystemInfo)) {
+ LOGGER.info("Successfully added EsrSystemInfo for 'vnfm id': {} and 'esr-system-info-id': {} ...", vnfmId,
+ esrSystemInfo);
+ return ResponseEntity.accepted().build();
+ }
+ LOGGER.error("Unable to add esrSystemInfo for 'vnfm id': {} and 'esr-system-info-id': {} ...", vnfmId,
+ esrSystemInfo);
+ return getRequestErrorResponseEntity(request, ESR_SYSTEM_INFO_LIST);
+ }
+
+ @GetMapping(value = "esr-vnfm/{vnfm-id}/esr-system-info-list",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getEsrSystemInfoList(@PathVariable("vnfm-id") final String vnfmId,
+ final HttpServletRequest request) {
+ LOGGER.info("Will retrieve esrSystemInfoList for 'vnfm id': {} ...", vnfmId);
+
+ final Optional<EsrSystemInfoList> optional = cacheServiceProvider.getEsrSystemInfoList(vnfmId);
+ if (optional.isPresent()) {
+ final EsrSystemInfoList esrSystemInfoList = optional.get();
+ LOGGER.info("found esrSystemInfoList {} in cache", esrSystemInfoList);
+ return ResponseEntity.ok(esrSystemInfoList);
+ }
+
+ LOGGER.error("Couldn't find esrSystemInfoList for 'vnfm id': {} ...", vnfmId);
+ return getRequestErrorResponseEntity(request, ESR_SYSTEM_INFO);
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java
index 216ff13a..67e1c4b6 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java
@@ -27,10 +27,12 @@ import static org.onap.so.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getHeaders;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
+import java.util.List;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
import org.onap.so.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
import org.onap.so.aaisimulator.utils.HttpServiceUtils;
@@ -172,4 +174,22 @@ public class GenericVnfsController {
return getRequestErrorResponseEntity(request, GENERIC_VNF);
}
+ @GetMapping(produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getGenericVnfs(@RequestParam(name = "selflink") final String selflink,
+ final HttpServletRequest request) {
+ LOGGER.info("will retrieve GenericVnfs using selflink: {}", selflink);
+
+ final List<GenericVnf> genericVnfList = cacheServiceProvider.getGenericVnfs(selflink);
+
+ if (genericVnfList.isEmpty()) {
+ LOGGER.error("No matching generic vnfs found using selflink: {}", selflink);
+ return getRequestErrorResponseEntity(request, GENERIC_VNF);
+ }
+
+ LOGGER.info("found {} GenericVnfs in cache", genericVnfList.size());
+ final GenericVnfs genericVnfs = new GenericVnfs();
+ genericVnfs.getGenericVnf().addAll(genericVnfList);
+ return ResponseEntity.ok(genericVnfs);
+ }
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java
index a53da3f5..082130b7 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java
@@ -21,8 +21,11 @@ package org.onap.so.aaisimulator.service.providers;
import java.util.Optional;
import org.onap.aai.domain.yang.CloudRegion;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.Tenant;
+import org.onap.aai.domain.yang.Vserver;
import org.onap.so.aaisimulator.models.CloudRegionKey;
import org.springframework.http.HttpHeaders;
@@ -39,10 +42,18 @@ public interface CloudRegionCacheServiceProvider extends Clearable {
Optional<Relationship> addRelationShip(final CloudRegionKey key, final Relationship relationship,
final String requestUri);
- boolean putTenant(final CloudRegionKey key, Tenant tenant);
+ boolean putTenant(final CloudRegionKey key, final String tenantId, Tenant tenant);
Optional<Tenant> getTenant(final CloudRegionKey key, final String tenantId);
- boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl, final String requestURI, final CloudRegionKey key,
- final String tenantId, final Relationship relationship);
+ boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl, final String requestURI,
+ final CloudRegionKey key, final String tenantId, final Relationship relationship);
+
+ Optional<EsrSystemInfoList> getEsrSystemInfoList(final CloudRegionKey key);
+
+ boolean putEsrSystemInfo(final CloudRegionKey key, final String esrSystemInfoId, final EsrSystemInfo esrSystemInfo);
+
+ boolean putVserver(final CloudRegionKey key, final String tenantId, final String vServerId, Vserver vServer);
+
+ Optional<Vserver> getVserver(final CloudRegionKey key, final String tenantId, final String vServerId);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java
index be1c1ad4..5024cc79 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java
@@ -35,12 +35,16 @@ import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl;
import java.util.List;
import java.util.Optional;
import org.onap.aai.domain.yang.CloudRegion;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.Tenant;
import org.onap.aai.domain.yang.Tenants;
+import org.onap.aai.domain.yang.Vserver;
+import org.onap.aai.domain.yang.Vservers;
import org.onap.so.aaisimulator.models.CloudRegionKey;
import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
@@ -130,7 +134,7 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
}
@Override
- public boolean putTenant(final CloudRegionKey key, final Tenant tenant) {
+ public boolean putTenant(final CloudRegionKey key, final String tenantId, final Tenant tenant) {
final Optional<CloudRegion> optional = getCloudRegion(key);
if (optional.isPresent()) {
final CloudRegion cloudRegion = optional.get();
@@ -141,11 +145,13 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
}
final Optional<Tenant> existingTenantOptional = tenants.getTenant().stream()
- .filter(existing -> existing.getTenantId().equals(tenant.getTenantId())).findFirst();
+ .filter(existing -> existing.getTenantId() != null && existing.getTenantId().equals(tenantId))
+ .findFirst();
if (!existingTenantOptional.isPresent()) {
return tenants.getTenant().add(tenant);
}
+
LOGGER.warn("Tenant already exists ...");
return false;
}
@@ -207,6 +213,95 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
return false;
}
+ @Override
+ public Optional<EsrSystemInfoList> getEsrSystemInfoList(final CloudRegionKey key) {
+ final Optional<CloudRegion> optional = getCloudRegion(key);
+ if (optional.isPresent()) {
+ final CloudRegion cloudRegion = optional.get();
+ final EsrSystemInfoList esrSystemInfoList = cloudRegion.getEsrSystemInfoList();
+ if (esrSystemInfoList != null) {
+ return Optional.of(esrSystemInfoList);
+ }
+ }
+ LOGGER.error("Unable to find EsrSystemInfoList in cache for CloudRegion: {} ", key);
+
+ return Optional.empty();
+ }
+
+ @Override
+ public boolean putEsrSystemInfo(final CloudRegionKey key, final String esrSystemInfoId,
+ final EsrSystemInfo esrSystemInfo) {
+ final Optional<CloudRegion> optional = getCloudRegion(key);
+ if (optional.isPresent()) {
+ final CloudRegion cloudRegion = optional.get();
+ final List<EsrSystemInfo> esrSystemInfoList = getEsrSystemInfoList(cloudRegion);
+
+ final Optional<EsrSystemInfo> existingEsrSystemInfo =
+ esrSystemInfoList.stream().filter(existing -> existing.getEsrSystemInfoId() != null
+ && existing.getEsrSystemInfoId().equals(esrSystemInfoId)).findFirst();
+ if (existingEsrSystemInfo.isPresent()) {
+ LOGGER.error("EsrSystemInfo already exists {}", existingEsrSystemInfo.get());
+ return false;
+ }
+
+ return esrSystemInfoList.add(esrSystemInfo);
+
+ }
+ return false;
+ }
+
+ @Override
+ public boolean putVserver(final CloudRegionKey key, final String tenantId, final String vServerId,
+ final Vserver vServer) {
+ final Optional<Tenant> optional = getTenant(key, tenantId);
+ if (optional.isPresent()) {
+ final Tenant tenant = optional.get();
+ Vservers vServers = tenant.getVservers();
+ if (vServers == null) {
+ vServers = new Vservers();
+ tenant.setVservers(vServers);
+ }
+ final List<Vserver> vServerList = vServers.getVserver();
+
+ final Optional<Vserver> existingVserver = vServerList.stream()
+ .filter(existing -> existing.getVserverId() != null && existing.getVserverId().equals(vServerId))
+ .findFirst();
+
+ if (existingVserver.isPresent()) {
+ LOGGER.error("Vserver already exists {}", existingVserver.get());
+ return false;
+ }
+ return vServerList.add(vServer);
+
+ }
+ return false;
+ }
+
+ @Override
+ public Optional<Vserver> getVserver(final CloudRegionKey key, final String tenantId, final String vServerId) {
+ final Optional<Tenant> optional = getTenant(key, tenantId);
+ if (optional.isPresent()) {
+ final Tenant tenant = optional.get();
+ Vservers vServers = tenant.getVservers();
+ if (vServers != null) {
+ return vServers.getVserver().stream()
+ .filter(vServer -> vServer.getVserverId() != null && vServer.getVserverId().equals(vServerId))
+ .findFirst();
+ }
+ }
+ LOGGER.error("Unable to find vServer in cache ... ");
+ return Optional.empty();
+ }
+
+ private List<EsrSystemInfo> getEsrSystemInfoList(final CloudRegion cloudRegion) {
+ EsrSystemInfoList esrSystemInfoList = cloudRegion.getEsrSystemInfoList();
+ if (esrSystemInfoList == null) {
+ esrSystemInfoList = new EsrSystemInfoList();
+ cloudRegion.setEsrSystemInfoList(esrSystemInfoList);
+ }
+ return esrSystemInfoList.getEsrSystemInfo();
+ }
+
private Relationship getRelationship(final String requestUriString, final CloudRegionKey cloudRegionKey,
final Tenant tenant) {
final Relationship relationShip = new Relationship();
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java
new file mode 100644
index 00000000..5589ff43
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.service.providers;
+
+import java.util.List;
+import java.util.Optional;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrVnfm;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface ExternalSystemCacheServiceProvider extends Clearable {
+
+ void putEsrVnfm(final String vnfmId, final EsrVnfm esrVnfm);
+
+ Optional<EsrVnfm> getEsrVnfm(final String vnfmId);
+
+ List<EsrVnfm> getAllEsrVnfm();
+
+ Optional<EsrSystemInfoList> getEsrSystemInfoList(final String vnfmId);
+
+ boolean putEsrSystemInfo(final String vnfmId, final String esrSystemInfoId, final EsrSystemInfo esrSystemInfo);
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java
new file mode 100644
index 00000000..3c44bed4
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java
@@ -0,0 +1,148 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.service.providers;
+
+import static org.onap.so.aaisimulator.utils.CacheName.ESR_VNFM_CACHE;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrVnfm;
+import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Service
+public class ExternalSystemCacheServiceProviderImpl extends AbstractCacheServiceProvider
+ implements ExternalSystemCacheServiceProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ExternalSystemCacheServiceProviderImpl.class);
+
+ @Autowired
+ public ExternalSystemCacheServiceProviderImpl(final CacheManager cacheManager) {
+ super(cacheManager);
+ }
+
+ @Override
+ public void putEsrVnfm(final String vnfmId, final EsrVnfm esrVnfm) {
+ LOGGER.info("Adding esrVnfm: {} with name to cache", esrVnfm);
+ final Cache cache = getCache(ESR_VNFM_CACHE.getName());
+ cache.put(vnfmId, esrVnfm);
+ }
+
+ @Override
+ public Optional<EsrVnfm> getEsrVnfm(final String vnfmId) {
+ LOGGER.info("getting EsrVnfm from cache using key: {}", vnfmId);
+ final Cache cache = getCache(ESR_VNFM_CACHE.getName());
+ final EsrVnfm value = cache.get(vnfmId, EsrVnfm.class);
+ if (value != null) {
+ return Optional.of(value);
+ }
+ LOGGER.error("Unable to find EsrVnfm in cache using vnfmId: {} ", vnfmId);
+ return Optional.empty();
+ }
+
+ @Override
+ public List<EsrVnfm> getAllEsrVnfm() {
+ final Cache cache = getCache(ESR_VNFM_CACHE.getName());
+ if (cache != null) {
+ final Object nativeCache = cache.getNativeCache();
+ if (nativeCache instanceof ConcurrentHashMap) {
+ @SuppressWarnings("unchecked")
+ final ConcurrentHashMap<Object, Object> concurrentHashMap =
+ (ConcurrentHashMap<Object, Object>) nativeCache;
+ final List<EsrVnfm> result = new ArrayList<>();
+ concurrentHashMap.keySet().stream().forEach(key -> {
+ final Optional<EsrVnfm> optional = getEsrVnfm(key.toString());
+ if (optional.isPresent()) {
+ result.add(optional.get());
+ }
+ });
+ return result;
+ }
+ }
+ LOGGER.error("Unable to get all esr vnfms ... ");
+ return Collections.emptyList();
+
+ }
+
+ @Override
+ public Optional<EsrSystemInfoList> getEsrSystemInfoList(final String vnfmId) {
+ final Optional<EsrVnfm> optional = getEsrVnfm(vnfmId);
+ if (optional.isPresent()) {
+ final EsrVnfm esrVnfm = optional.get();
+ if (esrVnfm.getEsrSystemInfoList() != null) {
+ return Optional.of(esrVnfm.getEsrSystemInfoList());
+ }
+ LOGGER.error("EsrSystemInfoList is null for vnfmId: {} ", vnfmId);
+ }
+ LOGGER.error("Unable to find EsrVnfm in cache using vnfmId: {} ", vnfmId);
+ return Optional.empty();
+ }
+
+ @Override
+ public boolean putEsrSystemInfo(final String vnfmId, final String esrSystemInfoId,
+ final EsrSystemInfo esrSystemInfo) {
+ final Optional<EsrVnfm> optional = getEsrVnfm(vnfmId);
+ if (optional.isPresent()) {
+ final EsrVnfm esrVnfm = optional.get();
+ final List<EsrSystemInfo> esrSystemInfoList = getEsrSystemInfoList(esrVnfm);
+
+ final Optional<EsrSystemInfo> existingEsrSystemInfo =
+ esrSystemInfoList.stream().filter(existing -> existing.getEsrSystemInfoId() != null
+ && existing.getEsrSystemInfoId().equals(esrSystemInfoId)).findFirst();
+ if (existingEsrSystemInfo.isPresent()) {
+ LOGGER.error("EsrSystemInfo already exists {}", existingEsrSystemInfo.get());
+ return false;
+ }
+
+ return esrSystemInfoList.add(esrSystemInfo);
+ }
+ LOGGER.error("Unable to add EsrSystemInfo in cache for vnfmId: {} ", vnfmId);
+ return false;
+ }
+
+ private List<EsrSystemInfo> getEsrSystemInfoList(final EsrVnfm esrVnfm) {
+ EsrSystemInfoList esrSystemInfoList = esrVnfm.getEsrSystemInfoList();
+ if (esrSystemInfoList == null) {
+ esrSystemInfoList = new EsrSystemInfoList();
+ esrVnfm.setEsrSystemInfoList(esrSystemInfoList);
+ }
+ return esrSystemInfoList.getEsrSystemInfo();
+ }
+
+ @Override
+ public void clearAll() {
+ clearCache(ESR_VNFM_CACHE.getName());
+
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java
index 20c0f223..8dd19cfa 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java
@@ -19,6 +19,7 @@
*/
package org.onap.so.aaisimulator.service.providers;
+import java.util.List;
import java.util.Optional;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Relationship;
@@ -44,5 +45,7 @@ public interface GenericVnfCacheServiceProvider extends Clearable {
boolean patchGenericVnf(final String vnfId, final GenericVnf genericVnf);
+ List<GenericVnf> getGenericVnfs(final String selflink);
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java
index 0c64d3d1..81a74f25 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java
@@ -27,6 +27,9 @@ import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_NAME;
import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBiDirectionalRelationShipListRelatedLink;
import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getRelationShipListRelatedLink;
import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import org.onap.aai.domain.yang.GenericVnf;
@@ -34,6 +37,7 @@ import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
+import org.onap.so.aaisimulator.utils.ShallowBeanCopy;
import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -91,17 +95,20 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
final ConcurrentHashMap<Object, Object> concurrentHashMap =
(ConcurrentHashMap<Object, Object>) nativeCache;
for (final Object key : concurrentHashMap.keySet()) {
- final GenericVnf value = cache.get(key, GenericVnf.class);
- final String genericVnfName = value.getVnfName();
- if (value != null && genericVnfName.equals(vnfName)) {
- final String genericVnfId = value.getVnfId();
- LOGGER.info("Found matching vnf for name: {}, vnf-id: {}", genericVnfName, genericVnfId);
- return Optional.of(genericVnfId);
+ final Optional<GenericVnf> optional = getGenericVnf(key.toString());
+ if (optional.isPresent()) {
+ final GenericVnf value = optional.get();
+ final String genericVnfName = value.getVnfName();
+ if (genericVnfName != null && genericVnfName.equals(vnfName)) {
+ final String genericVnfId = value.getVnfId();
+ LOGGER.info("Found matching vnf for name: {}, vnf-id: {}", genericVnfName, genericVnfId);
+ return Optional.of(genericVnfId);
+ }
}
}
}
}
- LOGGER.info("No match found for vnf name: {}", vnfName);
+ LOGGER.error("No match found for vnf name: {}", vnfName);
return Optional.empty();
}
@@ -164,15 +171,49 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
final Optional<GenericVnf> optional = getGenericVnf(vnfId);
if (optional.isPresent()) {
final GenericVnf cachedGenericVnf = optional.get();
- LOGGER.info("Changing OrchestrationStatus from {} to {} ", cachedGenericVnf.getOrchestrationStatus(),
- genericVnf.getOrchestrationStatus());
- cachedGenericVnf.setOrchestrationStatus(genericVnf.getOrchestrationStatus());
- return true;
+ try {
+ ShallowBeanCopy.copy(genericVnf, cachedGenericVnf);
+ return true;
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to update GenericVnf for vnfId: {}", vnfId, exception);
+ }
}
LOGGER.error("Unable to find GenericVnf ...");
return false;
}
+ @Override
+ public List<GenericVnf> getGenericVnfs(final String selflink) {
+ final Cache cache = getCache(GENERIC_VNF_CACHE.getName());
+ if (cache != null) {
+ final Object nativeCache = cache.getNativeCache();
+ if (nativeCache instanceof ConcurrentHashMap) {
+ @SuppressWarnings("unchecked")
+ final ConcurrentHashMap<Object, Object> concurrentHashMap =
+ (ConcurrentHashMap<Object, Object>) nativeCache;
+ final List<GenericVnf> result = new ArrayList<>();
+
+ concurrentHashMap.keySet().stream().forEach(key -> {
+ final Optional<GenericVnf> optional = getGenericVnf(key.toString());
+ if (optional.isPresent()) {
+ final GenericVnf genericVnf = optional.get();
+ final String genericVnfSelfLink = genericVnf.getSelflink();
+ final String genericVnfId = genericVnf.getSelflink();
+
+ if (genericVnfSelfLink != null && genericVnfSelfLink.equals(selflink)) {
+ LOGGER.info("Found matching vnf for selflink: {}, vnf-id: {}", genericVnfSelfLink,
+ genericVnfId);
+ result.add(genericVnf);
+ }
+ }
+ });
+ return result;
+ }
+ }
+ LOGGER.error("No match found for selflink: {}", selflink);
+ return Collections.emptyList();
+ }
+
private Relationship getRelationship(final String relatedLink, final GenericVnf genericVnf) {
final Relationship relationShip = new Relationship();
relationShip.setRelatedTo(GENERIC_VNF);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java
index 1874b83e..08fa750a 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java
@@ -32,7 +32,8 @@ public enum CacheName {
OWNING_ENTITY_CACHE("owning-entity-cache"),
PLATFORM_CACHE("platform-cache"),
LINES_OF_BUSINESS_CACHE("lines-of-business-cache"),
- CLOUD_REGION_CACHE("cloud-region-cache");
+ CLOUD_REGION_CACHE("cloud-region-cache"),
+ ESR_VNFM_CACHE("esr-vnfm-cache");
private String name;
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
index 97f25251..de3f9983 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
@@ -43,6 +43,8 @@ public class Constants {
public static final String PLATFORMS_URL = BUSINESS_URL + "/platforms/platform/";
+ public static final String EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL = "/external-system/esr-vnfm-list/";
+
public static final String NETWORK_URL = BASE_URL + "/network";
public static final String GENERIC_VNFS_URL = NETWORK_URL + "/generic-vnfs/";
@@ -120,6 +122,12 @@ public class Constants {
public static final String TENANT = "tenant";
+ public static final String ESR_VNFM = "esr-vnfm";
+
+ public static final String ESR_SYSTEM_INFO = "esr-system-info";
+
+ public static final String ESR_SYSTEM_INFO_LIST = "esr-system-info-list";
+
private Constants() {}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/ShallowBeanCopy.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/ShallowBeanCopy.java
new file mode 100644
index 00000000..3285e013
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/ShallowBeanCopy.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.utils;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class ShallowBeanCopy {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ShallowBeanCopy.class);
+
+ private ShallowBeanCopy() {}
+
+ public static void copy(final Object from, final Object to) throws Exception {
+ final Map<String, Method> fromMethods = getMethods(from);
+ final Map<String, Method> toMethods = getMethods(to);
+
+ for (final Entry<String, Method> entry : fromMethods.entrySet()) {
+ final String methodName = entry.getKey();
+ final Method fromMethod = entry.getValue();
+
+ final Optional<Method> optional = getSetMethod(to, fromMethod);
+ if (optional.isPresent()) {
+ final Method toGetMethod = toMethods.get(methodName);
+ final Method toMethod = optional.get();
+ final Object toValue = fromMethod.invoke(from);
+
+ final Object fromValue = toGetMethod.invoke(to);
+ if (toValue != null && !toValue.equals(fromValue)) {
+ LOGGER.info("Changing {} value from: {} to: {}", methodName, fromValue, toValue);
+ toMethod.invoke(to, toValue);
+ }
+ }
+ }
+ }
+
+
+ private static Optional<Method> getSetMethod(final Object to, final Method fromMethod) {
+ final String name = fromMethod.getName().replaceFirst("get|is", "set");
+ final Class<?> returnType = fromMethod.getReturnType();
+ try {
+ return Optional.of(to.getClass().getMethod(name, returnType));
+ } catch (final NoSuchMethodException noSuchMethodException) {
+ }
+ return Optional.empty();
+ }
+
+ private static Map<String, Method> getMethods(final Object object) {
+ final Map<String, Method> methodsFound = new HashMap<>();
+ final Method[] methods = object.getClass().getMethods();
+
+ for (final Method method : methods) {
+ if (method.getName().startsWith("get") || method.getName().startsWith("is")) {
+ final String name = method.getName().replaceFirst("get|is", "");
+
+ methodsFound.put(name, method);
+ }
+ }
+
+ return methodsFound;
+
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java
index 012c9ca6..584e28cf 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java
@@ -28,25 +28,40 @@ import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIO
import static org.onap.so.aaisimulator.utils.TestConstants.CLOUD_OWNER_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.CLOUD_REGION_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_PASSWORD;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SERVICE_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_ID;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_LIST_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SYSTEM_TYPE;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_TYEP;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_USERNAME;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VENDOR;
import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.SYSTEM_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.TENANTS_TENANT;
import static org.onap.so.aaisimulator.utils.TestConstants.TENANT_ID;
import static org.onap.so.aaisimulator.utils.TestConstants.VNF_ID;
+import static org.onap.so.aaisimulator.utils.TestConstants.VSERVER_ID;
+import static org.onap.so.aaisimulator.utils.TestConstants.VSERVER_NAME;
+import static org.onap.so.aaisimulator.utils.TestConstants.VSERVER_URL;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import org.junit.After;
import org.junit.Test;
import org.onap.aai.domain.yang.CloudRegion;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.Tenant;
+import org.onap.aai.domain.yang.Vserver;
import org.onap.so.aaisimulator.models.CloudRegionKey;
import org.onap.so.aaisimulator.service.providers.CloudRegionCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
@@ -244,6 +259,68 @@ public class CloudRegionsControllerTest extends AbstractSpringBootTest {
}
+ @Test
+ public void test_putEsrSystemInfo_successfullyAddedToCache() throws Exception {
+ final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+
+ invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
+
+ final String esrSystemInfoListUrl =
+ getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME, ESR_SYSTEM_INFO_LIST_URL);
+
+ final String esrSystemInfoUrl = esrSystemInfoListUrl + "/esr-system-info/" + ESR_SYSTEM_INFO_ID;
+ final ResponseEntity<Void> esrSystemInfoResponse =
+ testRestTemplateService.invokeHttpPut(esrSystemInfoUrl, TestUtils.getEsrSystemInfo(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, esrSystemInfoResponse.getStatusCode());
+
+ final ResponseEntity<EsrSystemInfoList> response =
+ testRestTemplateService.invokeHttpGet(esrSystemInfoListUrl, EsrSystemInfoList.class);
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+
+ assertTrue(response.hasBody());
+ final EsrSystemInfoList actualEsrSystemInfoList = response.getBody();
+
+ final List<EsrSystemInfo> esrSystemInfoList = actualEsrSystemInfoList.getEsrSystemInfo();
+ assertNotNull(esrSystemInfoList);
+ assertEquals(1, esrSystemInfoList.size());
+
+ final EsrSystemInfo esrSystemInfo = esrSystemInfoList.get(0);
+ assertEquals(ESR_SYSTEM_INFO_ID, esrSystemInfo.getEsrSystemInfoId());
+ assertEquals(SYSTEM_NAME, esrSystemInfo.getSystemName());
+ assertEquals(ESR_TYEP, esrSystemInfo.getType());
+ assertEquals(ESR_VENDOR, esrSystemInfo.getVendor());
+ assertEquals(ESR_SERVICE_URL, esrSystemInfo.getServiceUrl());
+ assertEquals(ESR_USERNAME, esrSystemInfo.getUserName());
+ assertEquals(ESR_PASSWORD, esrSystemInfo.getPassword());
+ assertEquals(ESR_SYSTEM_TYPE, esrSystemInfo.getSystemType());
+ }
+
+ @Test
+ public void test_putVServer_successfullyAddedToCache() throws Exception {
+ final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+
+ invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
+
+ final String tenantUrl = url + TENANTS_TENANT + TENANT_ID;
+ addTenantAndAssertResponse(tenantUrl);
+
+ final String vServerUrl = tenantUrl + VSERVER_URL + VSERVER_ID;
+
+ final ResponseEntity<Void> vServerResponse =
+ testRestTemplateService.invokeHttpPut(vServerUrl, TestUtils.getVserver(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, vServerResponse.getStatusCode());
+
+ final ResponseEntity<Vserver> response = testRestTemplateService.invokeHttpGet(vServerUrl, Vserver.class);
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+
+ assertTrue(response.hasBody());
+ final Vserver actualVserver = response.getBody();
+ assertEquals(VSERVER_NAME, actualVserver.getVserverName());
+ assertEquals(VSERVER_ID, actualVserver.getVserverId());
+ assertEquals("active", actualVserver.getProvStatus());
+ }
+
+
private void addTenantAndAssertResponse(final String tenantUrl) throws IOException {
final ResponseEntity<Void> responseEntity =
testRestTemplateService.invokeHttpPut(tenantUrl, TestUtils.getTenant(), Void.class);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java
new file mode 100644
index 00000000..874fab16
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.aaisimulator.utils.Constants.EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_PASSWORD;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SERVICE_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_ID;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_LIST_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SYSTEM_TYPE;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_TYEP;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_USERNAME;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VENDOR;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VIM_ID;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VNFM_ID;
+import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VNFM_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.SYSTEM_NAME;
+import java.io.IOException;
+import java.util.List;
+import org.junit.After;
+import org.junit.Test;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrVnfm;
+import org.onap.aai.domain.yang.EsrVnfmList;
+import org.onap.so.aaisimulator.service.providers.ExternalSystemCacheServiceProvider;
+import org.onap.so.aaisimulator.utils.TestUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class ExternalSystemEsrControllerTest extends AbstractSpringBootTest {
+
+ @Autowired
+ private ExternalSystemCacheServiceProvider externalSystemCacheServiceProvider;
+
+ @After
+ public void after() {
+ externalSystemCacheServiceProvider.clearAll();
+ }
+
+ @Test
+ public void test_putEsrVnfm_successfullyAddedToCache() throws Exception {
+ final String esrVnfmUrl = getUrl(ESR_VNFM_URL, ESR_VNFM_ID);
+ addEsrVnfmAndAssertResponse(esrVnfmUrl);
+
+ final ResponseEntity<EsrVnfm> response = testRestTemplateService.invokeHttpGet(esrVnfmUrl, EsrVnfm.class);
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+
+ assertTrue(response.hasBody());
+
+ final EsrVnfm actualEsrVnfm = response.getBody();
+ assertEquals(ESR_VNFM_ID, actualEsrVnfm.getVnfmId());
+ assertEquals(ESR_VIM_ID, actualEsrVnfm.getVimId());
+
+ }
+
+ @Test
+ public void test_getEsrVnfmList_getAllEsrVnfmsFromCache() throws Exception {
+ final String esrVnfmUrl = getUrl(ESR_VNFM_URL, ESR_VNFM_ID);
+ addEsrVnfmAndAssertResponse(esrVnfmUrl);
+
+ final String esrVnfmListUrl = getUrl(EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL);
+ final ResponseEntity<EsrVnfmList> response =
+ testRestTemplateService.invokeHttpGet(esrVnfmListUrl, EsrVnfmList.class);
+
+ assertTrue(response.hasBody());
+
+ final EsrVnfmList actualEsrVnfmList = response.getBody();
+
+ final List<EsrVnfm> esrVnfmList = actualEsrVnfmList.getEsrVnfm();
+ assertNotNull(esrVnfmList);
+ assertEquals(1, esrVnfmList.size());
+ final EsrVnfm actualEsrVnfm = esrVnfmList.get(0);
+ assertEquals(ESR_VNFM_ID, actualEsrVnfm.getVnfmId());
+ assertEquals(ESR_VIM_ID, actualEsrVnfm.getVimId());
+
+ }
+
+ @Test
+ public void test_putEsrSystemInfo_successfullyAddedToCache() throws Exception {
+ final String esrVnfmUrl = getUrl(ESR_VNFM_URL, ESR_VNFM_ID);
+ addEsrVnfmAndAssertResponse(esrVnfmUrl);
+ final String esrSystemInfoListUrl = getUrl(ESR_VNFM_URL, ESR_VNFM_ID, ESR_SYSTEM_INFO_LIST_URL);
+
+ final String esrSystemInfoUrl = esrSystemInfoListUrl + "/esr-system-info/" + ESR_SYSTEM_INFO_ID;
+ final ResponseEntity<Void> esrSystemInfoResponse =
+ testRestTemplateService.invokeHttpPut(esrSystemInfoUrl, TestUtils.getEsrSystemInfo(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, esrSystemInfoResponse.getStatusCode());
+
+ final ResponseEntity<EsrSystemInfoList> response =
+ testRestTemplateService.invokeHttpGet(esrSystemInfoListUrl, EsrSystemInfoList.class);
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+
+ assertTrue(response.hasBody());
+ final EsrSystemInfoList actualEsrSystemInfoList = response.getBody();
+
+ final List<EsrSystemInfo> esrSystemInfoList = actualEsrSystemInfoList.getEsrSystemInfo();
+ assertNotNull(esrSystemInfoList);
+ assertEquals(1, esrSystemInfoList.size());
+
+ final EsrSystemInfo esrSystemInfo = esrSystemInfoList.get(0);
+ assertEquals(ESR_SYSTEM_INFO_ID, esrSystemInfo.getEsrSystemInfoId());
+ assertEquals(SYSTEM_NAME, esrSystemInfo.getSystemName());
+ assertEquals(ESR_TYEP, esrSystemInfo.getType());
+ assertEquals(ESR_VENDOR, esrSystemInfo.getVendor());
+ assertEquals(ESR_SERVICE_URL, esrSystemInfo.getServiceUrl());
+ assertEquals(ESR_USERNAME, esrSystemInfo.getUserName());
+ assertEquals(ESR_PASSWORD, esrSystemInfo.getPassword());
+ assertEquals(ESR_SYSTEM_TYPE, esrSystemInfo.getSystemType());
+
+
+ }
+
+ private void addEsrVnfmAndAssertResponse(final String esrVnfmUrl) throws IOException {
+ final ResponseEntity<Void> esrVnfmResponse =
+ testRestTemplateService.invokeHttpPut(esrVnfmUrl, TestUtils.getEsrVnfm(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, esrVnfmResponse.getStatusCode());
+ }
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
index 1acd1f23..4b9cad30 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
@@ -46,6 +46,7 @@ import java.util.Optional;
import org.junit.After;
import org.junit.Test;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
@@ -364,6 +365,28 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
}
+ @Test
+ public void test_getGenericVnfs_usingSelfLink_getAllGenericVnfsInCache() throws Exception {
+
+ addCustomerServiceAndGenericVnf();
+
+ final String selfLink = "http://localhost:9921/generic-vnf/" + VNF_ID;
+ final String url = getUrl(Constants.GENERIC_VNFS_URL) + "?selflink=" + selfLink;
+ final ResponseEntity<GenericVnfs> response = testRestTemplateService.invokeHttpGet(url, GenericVnfs.class);
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+
+ assertTrue(response.hasBody());
+
+ final GenericVnfs actualGenericVnfs = response.getBody();
+ final List<GenericVnf> genericVnfList = actualGenericVnfs.getGenericVnf();
+ assertNotNull(genericVnfList);
+ assertEquals(1, genericVnfList.size());
+ final GenericVnf actualGenericVnf = genericVnfList.get(0);
+ assertEquals(selfLink, actualGenericVnf.getSelflink());
+ assertEquals(GENERIC_VNF_NAME, actualGenericVnf.getVnfName());
+ assertEquals(VNF_ID, actualGenericVnf.getVnfId());
+ }
+
private void addCustomerServiceAndGenericVnf() throws Exception, IOException {
final ResponseEntity<Void> customerResponse =
testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java
index eba2943d..d0a46811 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java
@@ -19,6 +19,7 @@
*/
package org.onap.so.aaisimulator.utils;
+import static org.onap.so.aaisimulator.utils.Constants.EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL;
import org.onap.so.aaisimulator.utils.Constants;
/**
@@ -67,6 +68,36 @@ public class TestConstants {
public static final String TENANTS_TENANT = "/tenants/tenant/";
+ public static final String ESR_VNFM_URL = EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL + "esr-vnfm/";
+
+ public static final String ESR_VNFM_ID = "c5e99cee-1996-4606-b697-838d51d4e1a3";
+
+ public static final String ESR_VIM_ID = "EtsiVimId";
+
+ public static final String ESR_SYSTEM_INFO_LIST_URL = "/esr-system-info-list";
+
+ public static final String ESR_SYSTEM_INFO_ID = "5c067098-f2e3-40f7-a7ba-155e7c61e916";
+
+ public static final String ESR_SYSTEM_TYPE = "VNFM";
+
+ public static final String ESR_PASSWORD = "123456";
+
+ public static final String ESR_USERNAME = "vnfmadapter";
+
+ public static final String ESR_SERVICE_URL = "https://so-vnfm-simulator.onap:9095/vnflcm/v1";
+
+ public static final String ESR_VENDOR = "EST";
+
+ public static final String ESR_TYEP = "simulator";
+
+ public static final String SYSTEM_NAME = "vnfmSimulator";
+
+ public static final String VSERVER_URL = "/vservers/vserver/";
+
+ public static final String VSERVER_NAME = "CsitVServer";
+
+ public static final String VSERVER_ID = "f84fdb9b-ad7c-49db-a08f-e443b4cbd033";
+
private TestConstants() {}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
index 1cdfeb91..033db17d 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
@@ -156,6 +156,19 @@ public class TestUtils {
return getJsonString("test-data/generic-vnf-orch-status-update.json");
}
+ public static String getEsrVnfm() throws IOException {
+ return getJsonString("test-data/esr-vnfm.json");
+ }
+
+ public static String getEsrSystemInfo() throws IOException {
+ return getJsonString("test-data/esr-system-info.json");
+ }
+
+ public static String getVserver() throws IOException {
+ return getJsonString("test-data/vServer.json");
+ }
+
+
public static String getUrl(final int port, final String... urls) {
final UriComponentsBuilder baseUri = UriComponentsBuilder.fromUriString("https://localhost:" + port);
for (final String url : urls) {
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/esr-system-info.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/esr-system-info.json
new file mode 100644
index 00000000..65d6095c
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/esr-system-info.json
@@ -0,0 +1,12 @@
+{
+ "esr-system-info-id": "5c067098-f2e3-40f7-a7ba-155e7c61e916",
+ "system-name": "vnfmSimulator",
+ "type": "simulator",
+ "vendor": "EST",
+ "version": "V1.0",
+ "service-url": "https://so-vnfm-simulator.onap:9095/vnflcm/v1",
+ "user-name": "vnfmadapter",
+ "password": "123456",
+ "system-type": "VNFM",
+ "resource-version": "1564774459055"
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/esr-vnfm.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/esr-vnfm.json
new file mode 100644
index 00000000..815e6ff7
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/esr-vnfm.json
@@ -0,0 +1,5 @@
+{
+ "vnfm-id": "c5e99cee-1996-4606-b697-838d51d4e1a3",
+ "vim-id": "EtsiVimId",
+ "certificate-url": ""
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf.json
index de246cd3..3740ce12 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf.json
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/generic-vnf.json
@@ -9,5 +9,6 @@
"model-version-id": "84b9649a-4eb9-4967-9abe-e8702f55518b",
"model-customization-id": "50a90cd7-a84e-4ee1-b5ba-bfa5a26f5e15",
"nf-type": "vnflcm",
- "nf-role": "vnflcm"
+ "nf-role": "vnflcm",
+ "selflink": "http://localhost:9921/generic-vnf/dfd02fb5-d7fb-4aac-b3c4-cd6b60058701"
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/vServer.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/vServer.json
new file mode 100644
index 00000000..b3cbba65
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/vServer.json
@@ -0,0 +1,5 @@
+{
+ "vserver-id": "f84fdb9b-ad7c-49db-a08f-e443b4cbd033",
+ "vserver-name": "CsitVServer",
+ "prov-status": "active"
+}