aboutsummaryrefslogtreecommitdiffstats
path: root/plans
diff options
context:
space:
mode:
Diffstat (limited to 'plans')
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/setup.sh6
-rw-r--r--plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/aai-simulator-populate-data/service-instance-aai.json45
-rw-r--r--plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/env2
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/populate-aai-simulator.sh17
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/controller/BusinessController.java328
-rw-r--r--plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/service/providers/ServiceInstanceCacheProvider.java32
-rw-r--r--plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/service/providers/ServiceInstanceCacheProviderImpl.java78
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/utils/CacheName.java1
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/AaiSimulatorControllerTest.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AaiSimulatorControllerTest.java)0
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/AbstractSpringBootTest.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AbstractSpringBootTest.java)0
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/BusinessControllerTest.java109
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/LinesOfBusinessControllerTest.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java)0
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/PlatformControllerTest.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java)0
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/PnfsControllerTest.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PnfsControllerTest.java)0
-rw-r--r--plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/ServiceDesignAndCreationControllerTest.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ServiceDesignAndCreationControllerTest.java)0
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/configuration/TestRestTemplateConfigration.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/configuration/TestRestTemplateConfigration.java)0
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestConstants.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java)14
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestRestTemplateService.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java)0
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestUtils.java (renamed from plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java)4
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java397
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java420
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java233
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java430
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java156
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java199
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java205
-rw-r--r--plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/resources/test-data/service-instance-aai.json45
-rwxr-xr-xplans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/teardown.sh12
28 files changed, 401 insertions, 2332 deletions
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/setup.sh b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/setup.sh
index b7d7e648..65cd576f 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/setup.sh
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/setup.sh
@@ -34,6 +34,12 @@ if [ "$MTU" == "" ]; then
fi
unset http_proxy https_proxy
+# Prepare Environment
+echo "Uninstall docker-py and reinstall docker."
+pip uninstall -y docker-py
+pip uninstall -y docker
+pip install -U docker==2.7.0
+
HOST_IP_ADDR=localhost
###################### setup so ##############################
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/aai-simulator-populate-data/service-instance-aai.json b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/aai-simulator-populate-data/service-instance-aai.json
new file mode 100644
index 00000000..8ea4263b
--- /dev/null
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/aai-simulator-populate-data/service-instance-aai.json
@@ -0,0 +1,45 @@
+{
+ "service-instance-id": "5df8b6de-2083-11e7-93ae-92361f002676",
+ "service-instance-name": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-version-id": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "resource-version": "1595258335377",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/5df8b6de-2083-11e7-93ae-92361f002676/service-data/service-topology/",
+ "orchestration-status": "Assigned",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "67f2e84c-734d-4e90-a1e4-d2ffa2e75849"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "PNFDemo"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo1",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "PNFDemo1"
+ }
+ ]
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/env b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/env
index 95469f90..ab4e3df4 100644
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/env
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/env
@@ -1,6 +1,6 @@
NEXUS_DOCKER_REPO_MSO=nexus3.onap.org:10001
DOCKER_ENVIRONMENT=remote
-TAG=1.7.5
+TAG=1.7.7-STAGING-latest
TIME_OUT_DEFAULT_VALUE_SEC=1200
PROJECT_NAME=pnfSwU
DEFAULT_NETWORK_NAME=pnfswu_default
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/populate-aai-simulator.sh b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/populate-aai-simulator.sh
index 6852e3f9..26673fcf 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/populate-aai-simulator.sh
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/config/populate-aai-simulator.sh
@@ -62,6 +62,7 @@ populate_aai_simulator()
ESR_SYSTEM_INFO_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/esr-system-info.json
CLOUD_ESR_SYSTEM_INFO_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/cloud-esr-system-info.json
PNF_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/pnf.json
+ SERVICE_INSTANCE_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/service-instance-aai.json
STATUS_CODE_ACCEPTED="202"
echo "$SCRIPT_NAME $(current_timestamp): checking health of AAI Simulator"
@@ -76,14 +77,6 @@ populate_aai_simulator()
echo "$SCRIPT_NAME $(current_timestamp): Populating AAI Simulator"
- echo "$SCRIPT_NAME $(current_timestamp): Adding Cloud-Customer Data"
- status_code=$(curl -k --write-out %{http_code} --silent --output /dev/null -H "$BASIC_AUTHORIZATION_HEADER" -H "$ACCEPT_HEADER" -H "$CONTENT_TYPE_HEADER" $BASE_URL/business/customers/customer/DemoCustomer -X PUT -d @"$CUSTOMER_JSON_FILE")
-
- if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
- echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put customer data in AAI Simulator. Status code received: $status_code"
- exit 1
- fi
-
echo "$SCRIPT_NAME $(current_timestamp): Adding Project"
status_code=$(curl -k --write-out %{http_code} --silent --output /dev/null -H "$BASIC_AUTHORIZATION_HEADER" -H "$ACCEPT_HEADER" -H "$CONTENT_TYPE_HEADER" $BASE_URL/business/projects/project/PnfSwUCsitProject -X PUT -d @"$PROJECT_JSON_FILE")
@@ -164,6 +157,14 @@ populate_aai_simulator()
exit 1
fi
+ echo "$SCRIPT_NAME $(current_timestamp): Adding ServiceInstance"
+ status_code=$(curl -k --write-out %{http_code} --silent --output /dev/null -H "$BASIC_AUTHORIZATION_HEADER" -H "$ACCEPT_HEADER" -H "$CONTENT_TYPE_HEADER" $BASE_URL/business/customers/customer/5df8b6de-2083-11e7-93ae-92361f002676/service-subscriptions/service-subscription/pNF/service-instances/service-instance/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce -X PUT -d @$"$SERVICE_INSTANCE_JSON_FILE")
+
+ if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
+ echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put ServiceInstance data in AAI Simulator. Status code received: $status_code"
+ exit 1
+ fi
+
echo "$SCRIPT_NAME $(current_timestamp): AAI Simulator Populated Successfully"
}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/controller/BusinessController.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/controller/BusinessController.java
index 8559e8aa..f6ee7e64 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/controller/BusinessController.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/controller/BusinessController.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,38 +19,22 @@
*/
package org.onap.aaisimulator.controller;
-import static org.onap.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
-import static org.onap.aaisimulator.utils.Constants.CUSTOMER_TYPE;
import static org.onap.aaisimulator.utils.Constants.CUSTOMER_URL;
-import static org.onap.aaisimulator.utils.Constants.GENERIC_VNF;
-import static org.onap.aaisimulator.utils.Constants.GENERIC_VNF_VNF_ID;
import static org.onap.aaisimulator.utils.Constants.SERVICE_RESOURCE_TYPE;
-import static org.onap.aaisimulator.utils.Constants.SERVICE_SUBSCRIPTION;
import static org.onap.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
import static org.onap.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
-import static org.onap.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.Customer;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.GenericVnfs;
-import org.onap.aai.domain.yang.Relationship;
-import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.ServiceInstances;
-import org.onap.aai.domain.yang.ServiceSubscription;
-import org.onap.aaisimulator.models.NodeServiceInstance;
-import org.onap.aaisimulator.service.providers.CustomerCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.NodesCacheServiceProvider;
+import org.onap.aaisimulator.service.providers.ServiceInstanceCacheProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -60,297 +44,87 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
-/**
- * @author waqas.ikram@ericsson.com
- *
- */
@Controller
@RequestMapping(path = CUSTOMER_URL)
public class BusinessController {
private static final Logger LOGGER = LoggerFactory.getLogger(BusinessController.class);
- private final CustomerCacheServiceProvider cacheServiceProvider;
- private final NodesCacheServiceProvider nodesCacheServiceProvider;
- private final GenericVnfCacheServiceProvider genericVnfCacheServiceProvider;
-
- @Autowired
- public BusinessController(final CustomerCacheServiceProvider cacheServiceProvider,
- final NodesCacheServiceProvider nodesCacheServiceProvider,
- final GenericVnfCacheServiceProvider genericVnfCacheServiceProvider) {
- this.cacheServiceProvider = cacheServiceProvider;
- this.nodesCacheServiceProvider = nodesCacheServiceProvider;
- this.genericVnfCacheServiceProvider = genericVnfCacheServiceProvider;
- }
-
- @GetMapping(value = "{global-customer-id}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> getCustomer(@PathVariable("global-customer-id") final String globalCustomerId,
- final HttpServletRequest request) {
- LOGGER.info("Will retrieve customer for 'global customer id': {} ...", globalCustomerId);
-
- final Optional<Customer> optional = cacheServiceProvider.getCustomer(globalCustomerId);
- if (optional.isPresent()) {
- final Customer customer = optional.get();
- LOGGER.info("found customer {} in cache", customer);
- return ResponseEntity.ok(customer);
- }
- LOGGER.error("Couldn't find {} in cache", globalCustomerId);
- return getRequestErrorResponseEntity(request, CUSTOMER_TYPE);
- }
-
- @PutMapping(value = "/{global-customer-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> putCustomer(@RequestBody final Customer customer,
- @PathVariable("global-customer-id") final String globalCustomerId, final HttpServletRequest request) {
- LOGGER.info("Will put customer for 'global customer id': {} ...", globalCustomerId);
-
- if (customer.getResourceVersion() == null || customer.getResourceVersion().isEmpty()) {
- customer.setResourceVersion(getResourceVersion());
-
- }
- cacheServiceProvider.putCustomer(globalCustomerId, customer);
- return ResponseEntity.accepted().build();
+ private final ServiceInstanceCacheProvider svcInstanceCacheSvcProvider;
+ @Autowired
+ public BusinessController(final ServiceInstanceCacheProvider serviceInstanceCacheProvider) {
+ this.svcInstanceCacheSvcProvider = serviceInstanceCacheProvider;
}
- @GetMapping(value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> getCustomer(@PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType, final HttpServletRequest request) {
- LOGGER.info("Will retrieve service subscription for 'global customer id': {} and 'service type': {} ...",
- globalCustomerId, serviceType);
-
- final Optional<ServiceSubscription> optional =
- cacheServiceProvider.getServiceSubscription(globalCustomerId, serviceType);
- if (optional.isPresent()) {
- final ServiceSubscription serviceSubscription = optional.get();
- LOGGER.info("found service subscription {} in cache", serviceSubscription);
- return ResponseEntity.ok(serviceSubscription);
- }
-
- LOGGER.error("Couldn't find 'global customer id': {} and 'service type': {} in cache", globalCustomerId,
- serviceType);
- return getRequestErrorResponseEntity(request, SERVICE_SUBSCRIPTION);
- }
+ @PutMapping(value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putServiceInstance(@PathVariable("global-customer-id") final String globalCustomerId,
+ @PathVariable("service-type") final String serviceType,
+ @PathVariable(name = "service-instance-id") final String serviceInstanceId,
+ @RequestBody final ServiceInstance serviceInstance, final HttpServletRequest request) {
- @PutMapping(value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> putServiceSubscription(@PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType,
- @RequestBody final ServiceSubscription serviceSubscription, final HttpServletRequest request) {
- LOGGER.info("Will add service subscription for 'global customer id': {} and 'service type': {} ...",
- globalCustomerId, serviceType);
+ LOGGER.info("Add service instance to cache for 'global customer id': {}, 'service type': {} and "
+ + "'service instance id: '{}..", globalCustomerId, serviceType, serviceInstanceId);
- if (cacheServiceProvider.putServiceSubscription(globalCustomerId, serviceType, serviceSubscription)) {
- LOGGER.info("Successfully add service subscription in cache ...");
+ if (svcInstanceCacheSvcProvider.putServiceInstance(globalCustomerId, serviceInstance)) {
+ LOGGER.info("Successfully added service instance to cache ...");
return ResponseEntity.accepted().build();
}
- LOGGER.error("Couldn't add service subscription using 'global customer id': {} and 'service type': {}",
- globalCustomerId, serviceType);
- return getRequestErrorResponseEntity(request, SERVICE_SUBSCRIPTION);
- }
-
- @GetMapping(
- value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> getSericeInstances(@PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType,
- @RequestParam(name = "service-instance-name") final String serviceInstanceName,
- @RequestParam(name = "depth", required = false) final Integer depth, final HttpServletRequest request) {
-
- LOGGER.info(
- "Will retrieve service instances for 'global customer id': {}, 'service type': {} and 'service instance name: '{} with depth: {}...",
- globalCustomerId, serviceType, serviceInstanceName, depth);
-
- final Optional<ServiceInstances> optional =
- cacheServiceProvider.getServiceInstances(globalCustomerId, serviceType, serviceInstanceName);
- if (optional.isPresent()) {
- final ServiceInstances serviceInstances = optional.get();
- LOGGER.info("found service instance {} in cache", serviceInstances);
- return ResponseEntity.ok(serviceInstances);
- }
- LOGGER.error(
- "Couldn't find 'global customer id': {}, 'service type': {} and 'service instance name': {} with depth: {} in cache",
- globalCustomerId, serviceType, serviceInstanceName, depth);
- return getRequestErrorResponseEntity(request);
- }
-
- @GetMapping(
- value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> getSericeInstance(@PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType,
- @PathVariable(name = "service-instance-id") final String serviceInstanceId,
- @RequestParam(name = "depth", required = false) final Integer depth,
- @RequestParam(name = "resultIndex", required = false) final Integer resultIndex,
- @RequestParam(name = "resultSize", required = false) final Integer resultSize,
- @RequestParam(name = "format", required = false) final String format, final HttpServletRequest request) {
-
- LOGGER.info(
- "Will retrieve service instances for 'global customer id': {}, 'service type': {} and 'service instance id: '{} with depth: {}, resultIndex:{}, resultSize: {} and format: {}...",
- globalCustomerId, serviceType, serviceInstanceId, depth, resultIndex, resultSize, format);
-
- final Optional<ServiceInstance> optional =
- cacheServiceProvider.getServiceInstance(globalCustomerId, serviceType, serviceInstanceId);
- if (optional.isPresent()) {
- final ServiceInstance serviceInstance = optional.get();
- LOGGER.info("found service instance {} in cache", serviceInstance);
- return ResponseEntity.ok(serviceInstance);
- }
LOGGER.error(
- "Couldn't find 'global customer id': {}, 'service type': {} and 'service instance id': {} with depth: {}, resultIndex:{}, resultSize: {} and format: {} in cache",
- globalCustomerId, serviceType, serviceInstanceId, depth, resultIndex, resultSize, format);
- return getRequestErrorResponseEntity(request);
+ "Couldn't add service instance for 'global customer id': {},'service type': {} and 'service instance id: '{} ...",
+ globalCustomerId, serviceType, serviceInstanceId);
+ return getRequestErrorResponseEntity(request, SERVICE_RESOURCE_TYPE);
}
- @PutMapping(
- value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> putSericeInstance(@PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType,
- @PathVariable(name = "service-instance-id") final String serviceInstanceId,
- @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String invocationId,
- @RequestBody final ServiceInstance serviceInstance, final HttpServletRequest request) {
+ @GetMapping(value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getServiceInstance(@PathVariable("global-customer-id") final String globalCustomerId,
+ @PathVariable("service-type") final String serviceType,
+ @PathVariable(name = "service-instance-id") final String serviceInstanceId,
+ @RequestParam(name = "depth", required = false) final Integer depth,
+ @RequestParam(name = "resultIndex", required = false) final Integer resultIndex,
+ @RequestParam(name = "resultSize", required = false) final Integer resultSize,
+ @RequestParam(name = "format", required = false) final String format, final HttpServletRequest request) {
LOGGER.info(
- "Will add service instance for 'global customer id': {}, 'service type': {} and 'service instance id: '{} ...",
- globalCustomerId, serviceType, serviceInstanceId);
+ "Retrieve service instances for 'global customer id': {}, 'service type': {} and 'service instance id: '{} with depth: {}, resultIndex:{}, resultSize: {} and format: {}...",
+ globalCustomerId, serviceType, serviceInstanceId, depth, resultIndex, resultSize, format);
- if (serviceInstance.getResourceVersion() == null || serviceInstance.getResourceVersion().isEmpty()) {
- serviceInstance.setResourceVersion(getResourceVersion());
- }
+ final Optional<ServiceInstance> svcInstance =
+ svcInstanceCacheSvcProvider.getServiceInstance(globalCustomerId);
- if (cacheServiceProvider.putServiceInstance(globalCustomerId, serviceType, serviceInstanceId,
- serviceInstance)) {
- nodesCacheServiceProvider.putNodeServiceInstance(serviceInstanceId, new NodeServiceInstance(
- globalCustomerId, serviceType, serviceInstanceId, SERVICE_RESOURCE_TYPE, request.getRequestURI()));
- return ResponseEntity.accepted().build();
+ if (svcInstance.isPresent()) {
+ final ServiceInstance serviceInstance = svcInstance.get();
+ LOGGER.info("Found service instance {} in cache", serviceInstance);
+ return ResponseEntity.ok(serviceInstance);
}
- LOGGER.error("Couldn't add 'global customer id': {}, 'service type': {} and 'service instance id': {} to cache",
- globalCustomerId, serviceType, serviceInstanceId);
+ LOGGER.error(
+ "Couldn't find 'global customer id': {}, 'service type': {} and 'service instance id': {} with depth: {}, resultIndex:{}, resultSize: {} and format: {} in cache",
+ globalCustomerId, serviceType, serviceInstanceId, depth, resultIndex, resultSize, format);
return getRequestErrorResponseEntity(request);
}
- @PostMapping(
- value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> patchSericeInstance(@PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType,
- @PathVariable(name = "service-instance-id") final String serviceInstanceId,
- @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String xHttpHeaderOverride,
- @RequestBody final ServiceInstance serviceInstance, final HttpServletRequest request) {
+ @PostMapping(value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> patchServiceInstance(@PathVariable("global-customer-id") final String globalCustomerId,
+ @PathVariable("service-type") final String serviceType,
+ @PathVariable(name = "service-instance-id") final String serviceInstanceId,
+ @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String xHttpHeaderOverride,
+ @RequestBody final ServiceInstance serviceInstance, final HttpServletRequest request) {
LOGGER.info(
- "Will post service instance for 'global customer id': {}, 'service type': {}, 'service instance id: '{} and '{}': {}...",
- globalCustomerId, serviceType, serviceInstanceId, X_HTTP_METHOD_OVERRIDE, xHttpHeaderOverride);
+ "Post service instance for 'global customer id': {}, 'service type': {}, 'service instance id: '{} and '{}': {}...",
+ globalCustomerId, serviceType, serviceInstanceId, X_HTTP_METHOD_OVERRIDE, xHttpHeaderOverride);
if (HttpMethod.PATCH.toString().equalsIgnoreCase(xHttpHeaderOverride)) {
- cacheServiceProvider.patchServiceInstance(globalCustomerId, serviceType, serviceInstanceId,
- serviceInstance);
+ svcInstanceCacheSvcProvider.patchServiceInstance(globalCustomerId, serviceInstance);
return ResponseEntity.accepted().build();
}
LOGGER.error("{} not supported ... ", xHttpHeaderOverride);
return getRequestErrorResponseEntity(request);
}
-
-
- @GetMapping(
- value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}/related-to/generic-vnfs",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> getRelatedToGenericVnf(@PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType,
- @PathVariable(name = "service-instance-id") final String serviceInstanceId,
- @RequestParam(name = "vnf-name", required = true) final String vnfName, final HttpServletRequest request) {
-
- LOGGER.info(
- "Will retrieve generic vnf related to information for 'global customer id': {}, 'service type': {} and 'service instance id: '{} with vnfname: {}...",
- globalCustomerId, serviceType, serviceInstanceId, vnfName);
-
- final Optional<Relationship> optional =
- cacheServiceProvider.getRelationship(globalCustomerId, serviceType, serviceInstanceId, vnfName);
-
- if (optional.isPresent()) {
-
- final Relationship relationship = optional.get();
- final Optional<RelationshipData> relationshipDataOptional = relationship.getRelationshipData().stream()
- .filter(existing -> GENERIC_VNF_VNF_ID.equals(existing.getRelationshipKey())).findFirst();
-
- if (relationshipDataOptional.isPresent()) {
- final RelationshipData relationshipData = relationshipDataOptional.get();
- final String vnfId = relationshipData.getRelationshipValue();
- final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(vnfId);
- if (genericVnfOptional.isPresent()) {
- final GenericVnfs genericVnfs = new GenericVnfs();
- genericVnfs.getGenericVnf().add(genericVnfOptional.get());
- LOGGER.info("found service instance {} in cache", relationship);
- return ResponseEntity.ok(genericVnfs);
- }
- }
- }
- LOGGER.error(
- "Couldn't find generic vnf related to information for 'global customer id': {}, 'service type': {} and 'service instance id: '{} with vnfname: {}...",
- globalCustomerId, serviceType, serviceInstanceId, vnfName);
- return getRequestErrorResponseEntity(request, GENERIC_VNF);
- }
-
- @PutMapping(
- value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}"
- + BI_DIRECTIONAL_RELATIONSHIP_LIST_URL,
- consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> putSericeInstanceRelationShip(
- @PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType,
- @PathVariable(name = "service-instance-id") final String serviceInstanceId,
- @RequestBody final Relationship relationship, final HttpServletRequest request) {
-
- LOGGER.info(
- "Will add {} relationship for 'global customer id': {}, 'service type': {} and 'service instance id: '{} ...",
- relationship.getRelatedTo(), globalCustomerId, serviceType, serviceInstanceId);
- final Optional<Relationship> optional = cacheServiceProvider.addRelationShip(globalCustomerId, serviceType,
- serviceInstanceId, relationship, request.getRequestURI());
-
- if (optional.isPresent()) {
- final Relationship resultantRelationship = optional.get();
- LOGGER.info("Relationship add, sending resultant relationship: {} in response ...", resultantRelationship);
- return ResponseEntity.accepted().body(resultantRelationship);
- }
-
- LOGGER.error(
- "Couldn't add {} relationship for 'global customer id': {}, 'service type': {} and 'service instance id: '{} ...",
- relationship.getRelatedTo(), globalCustomerId, serviceType, serviceInstanceId);
-
- return getRequestErrorResponseEntity(request);
- }
-
- @DeleteMapping(
- value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}",
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity<?> deleteSericeInstance(@PathVariable("global-customer-id") final String globalCustomerId,
- @PathVariable("service-type") final String serviceType,
- @PathVariable(name = "service-instance-id") final String serviceInstanceId,
- @RequestParam(name = "resource-version") final String resourceVersion, final HttpServletRequest request) {
-
- LOGGER.info(
- "Will delete SericeInstance for 'global-customer-id': {}, 'service-type': {}, 'service-instance-id': {} and 'resource-version': {}",
- globalCustomerId, serviceType, serviceInstanceId, resourceVersion);
-
- if (cacheServiceProvider.deleteSericeInstance(globalCustomerId, serviceType, serviceInstanceId,
- resourceVersion)) {
- LOGGER.info(
- "Successfully deleted SericeInstance from cache for 'global-customer-id': {}, 'service-type': {}, 'service-instance-id': {} and 'resource-version': {}",
- globalCustomerId, serviceType, serviceInstanceId, resourceVersion);
- return ResponseEntity.noContent().build();
- }
-
- LOGGER.error(
- "Unable to delete SericeInstance from cache for 'global-customer-id': {}, 'service-type': {}, 'service-instance-id': {} and 'resource-version': {}",
- globalCustomerId, serviceType, serviceInstanceId, resourceVersion);
-
- return getRequestErrorResponseEntity(request);
-
- }
-}
+} \ No newline at end of file
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/service/providers/ServiceInstanceCacheProvider.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/service/providers/ServiceInstanceCacheProvider.java
new file mode 100644
index 00000000..fc21eb69
--- /dev/null
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/service/providers/ServiceInstanceCacheProvider.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.aaisimulator.service.providers;
+
+import java.util.Optional;
+import org.onap.aai.domain.yang.ServiceInstance;
+
+public interface ServiceInstanceCacheProvider {
+
+ boolean patchServiceInstance(final String globalCustomerId, final ServiceInstance serviceInstance);
+
+ Optional<ServiceInstance> getServiceInstance(final String globalCustomerId);
+
+ boolean putServiceInstance(final String serviceInstanceId, final ServiceInstance serviceInstance);
+} \ No newline at end of file
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/service/providers/ServiceInstanceCacheProviderImpl.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/service/providers/ServiceInstanceCacheProviderImpl.java
new file mode 100644
index 00000000..57450ed6
--- /dev/null
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/service/providers/ServiceInstanceCacheProviderImpl.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.aaisimulator.service.providers;
+
+import static org.onap.aaisimulator.utils.CacheName.SERVICE_INSTANCE_CACHE;
+
+import java.util.Optional;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaisimulator.cache.provider.AbstractCacheServiceProvider;
+import org.onap.aaisimulator.utils.ShallowBeanCopy;
+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;
+
+@Service
+public class ServiceInstanceCacheProviderImpl extends AbstractCacheServiceProvider implements
+ ServiceInstanceCacheProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ServiceInstanceCacheProviderImpl.class);
+
+ private final Cache cache;
+
+ @Autowired
+ public ServiceInstanceCacheProviderImpl(final CacheManager cacheManager) {
+ super(cacheManager);
+ cache = getCache(SERVICE_INSTANCE_CACHE.getName());
+ }
+
+ @Override
+ public boolean patchServiceInstance(String globalCustomerId, ServiceInstance serviceInstance) {
+ final Optional<ServiceInstance> svcInstance = getServiceInstance(globalCustomerId);
+ if (svcInstance.isPresent()) {
+ final ServiceInstance cachedSvcInstance = svcInstance.get();
+ try {
+ ShallowBeanCopy.copy(serviceInstance, cachedSvcInstance);
+ return true;
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to update ServiceInstance for globalCustomerId: {}", globalCustomerId, exception);
+ }
+ }
+ LOGGER.error("Unable to find ServiceInstance for globalCustomerId : {}", globalCustomerId);
+ return false;
+ }
+
+ @Override
+ public Optional<ServiceInstance> getServiceInstance(final String globalCustomerId) {
+ LOGGER.info("Getting Service Instance with key: {} in cache ...", globalCustomerId);
+ final ServiceInstance svcInstance = cache.get(globalCustomerId, ServiceInstance.class);
+ return Optional.ofNullable(svcInstance);
+ }
+
+ @Override
+ public boolean putServiceInstance(String globalCustomerId, ServiceInstance serviceInstance) {
+ LOGGER.info("Adding ServiceInstance: {} with key: {} in cache ...", serviceInstance, globalCustomerId);
+ cache.put(globalCustomerId, serviceInstance);
+ return true;
+ }
+} \ No newline at end of file
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/utils/CacheName.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/utils/CacheName.java
index 63e7e261..53d2dff2 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/utils/CacheName.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/main/java/org/onap/aaisimulator/utils/CacheName.java
@@ -26,6 +26,7 @@ package org.onap.aaisimulator.utils;
public enum CacheName {
CUSTOMER_CACHE("customer-cache"),
+ SERVICE_INSTANCE_CACHE("service-instance-cache"),
PROJECT_CACHE("project-cache"),
NODES_CACHE("nodes-cache"),
GENERIC_VNF_CACHE("generic-vnf-cache"),
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AaiSimulatorControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/AaiSimulatorControllerTest.java
index af9b2367..af9b2367 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AaiSimulatorControllerTest.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/AaiSimulatorControllerTest.java
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AbstractSpringBootTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/AbstractSpringBootTest.java
index 4f2eab27..4f2eab27 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AbstractSpringBootTest.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/AbstractSpringBootTest.java
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/BusinessControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/BusinessControllerTest.java
new file mode 100755
index 00000000..9bab789d
--- /dev/null
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/BusinessControllerTest.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.aaisimulator.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.onap.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
+import static org.onap.aaisimulator.utils.TestConstants.CUSTOMER_BASE_URL;
+import static org.onap.aaisimulator.utils.TestConstants.SVC_INSTANCE_CUSTOMER_ID;
+import static org.onap.aaisimulator.utils.TestConstants.SVC_INSTANCE_CUSTOMER_NAME;
+import static org.onap.aaisimulator.utils.TestConstants.SVC_INSTANCE_URL;
+import static org.onap.aaisimulator.utils.TestConstants.SVC_SUBSCRIPTIONS_URL;
+import static org.onap.aaisimulator.utils.TestUtils.getSvcInstance;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Test;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaisimulator.service.providers.CustomerCacheServiceProvider;
+import org.onap.aaisimulator.utils.Constants;
+import org.onap.aaisimulator.utils.TestUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+public class BusinessControllerTest extends AbstractSpringBootTest {
+
+ @Autowired
+ private CustomerCacheServiceProvider cacheServiceProvider;
+
+ @After
+ public void after() {
+ cacheServiceProvider.clearAll();
+ }
+
+ @Test
+ public void test_getSvcInstance_usingServiceInstanceId_fromCache() throws Exception {
+ final String url = getUrl(CUSTOMER_BASE_URL, SVC_SUBSCRIPTIONS_URL, SVC_INSTANCE_URL);
+
+ final ResponseEntity<Void> responseEntity = testRestTemplateService
+ .invokeHttpPut(url, getSvcInstance(), Void.class);
+
+ assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
+
+ final ResponseEntity<ServiceInstance> actual = testRestTemplateService
+ .invokeHttpGet(url, ServiceInstance.class);
+
+ assertEquals(HttpStatus.OK, actual.getStatusCode());
+ assertTrue(actual.hasBody());
+
+ final ServiceInstance actualServiceInstance = actual.getBody();
+
+ assertEquals(SVC_INSTANCE_CUSTOMER_NAME, actualServiceInstance.getServiceInstanceName());
+ assertEquals(SVC_INSTANCE_CUSTOMER_ID, actualServiceInstance.getServiceInstanceId());
+ }
+
+ @Test
+ public void test_postForServiceInstanceId_fromCache() throws Exception {
+ addServiceInstnceToCache();
+ final HttpHeaders httpHeaders = testRestTemplateService.getHttpHeaders();
+ httpHeaders.add(X_HTTP_METHOD_OVERRIDE, HttpMethod.PATCH.toString());
+ httpHeaders.remove(HttpHeaders.CONTENT_TYPE);
+ httpHeaders.add(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_MERGE_PATCH_JSON);
+
+ final String svcInstanceUrl = getUrl(CUSTOMER_BASE_URL, SVC_SUBSCRIPTIONS_URL, SVC_INSTANCE_URL);
+ final ResponseEntity<Void> postServiceInstanceResponse = testRestTemplateService
+ .invokeHttpPost(httpHeaders, svcInstanceUrl, TestUtils.getSvcInstance(), Void.class);
+
+ assertEquals(HttpStatus.ACCEPTED, postServiceInstanceResponse.getStatusCode());
+
+ final ResponseEntity<ServiceInstance> response =
+ testRestTemplateService.invokeHttpGet(svcInstanceUrl, ServiceInstance.class);
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+
+ assertTrue(response.hasBody());
+
+ final ServiceInstance actualServiceInstance = response.getBody();
+
+ assertEquals(SVC_INSTANCE_CUSTOMER_NAME, actualServiceInstance.getServiceInstanceName());
+ assertEquals(SVC_INSTANCE_CUSTOMER_ID, actualServiceInstance.getServiceInstanceId());
+
+ }
+
+ private void addServiceInstnceToCache() throws Exception, IOException {
+ final ResponseEntity<Void> serviceInstanceResponse =
+ testRestTemplateService.invokeHttpPut(getUrl(CUSTOMER_BASE_URL, SVC_SUBSCRIPTIONS_URL, SVC_INSTANCE_URL),
+ TestUtils.getSvcInstance(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
+ }
+} \ No newline at end of file
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/LinesOfBusinessControllerTest.java
index 0b6cfb50..0b6cfb50 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/LinesOfBusinessControllerTest.java
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/PlatformControllerTest.java
index 00c66388..00c66388 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/PlatformControllerTest.java
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PnfsControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/PnfsControllerTest.java
index 440c66d6..440c66d6 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PnfsControllerTest.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/PnfsControllerTest.java
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ServiceDesignAndCreationControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/ServiceDesignAndCreationControllerTest.java
index d0e652bd..d0e652bd 100644
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ServiceDesignAndCreationControllerTest.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/ServiceDesignAndCreationControllerTest.java
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/configuration/TestRestTemplateConfigration.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/configuration/TestRestTemplateConfigration.java
index 2e50d3d7..2e50d3d7 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/configuration/TestRestTemplateConfigration.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/controller/configuration/TestRestTemplateConfigration.java
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestConstants.java
index 942e8701..bccb2f02 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestConstants.java
@@ -33,18 +33,32 @@ public class TestConstants {
public static final String SERVICE_INSTANCE_ID = "ccece8fe-13da-456a-baf6-41b3a4a2bc2b";
+ public static final String SVC_INSTANCE_NAME = "ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce";
+
public static final String SERVICE_INSTANCE_URL =
SERVICE_INSTANCES_URL + "/service-instance/" + SERVICE_INSTANCE_ID;
+ public static final String SVC_INSTANCE_URL = SERVICE_INSTANCES_URL + "/service-instance/" + SVC_INSTANCE_NAME;
+
public static final String SERVICE_TYPE = "vCPE";
+ public static final String SVC_TYPE = "pNF";
+
public static final String SERVICE_SUBSCRIPTIONS_URL =
"/service-subscriptions/service-subscription/" + SERVICE_TYPE;
+ public static final String SVC_SUBSCRIPTIONS_URL = "/service-subscriptions/service-subscription/"+ SVC_TYPE;
+
public static final String GLOBAL_CUSTOMER_ID = "DemoCustomer";
+ public static final String SVC_INSTANCE_CUSTOMER_ID = "5df8b6de-2083-11e7-93ae-92361f002676";
+
+ public static final String SVC_INSTANCE_CUSTOMER_NAME = "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269";
+
public static final String CUSTOMERS_URL = BASE_URL_V17 + "/business/customers/customer/" + GLOBAL_CUSTOMER_ID;
+ public static final String CUSTOMER_BASE_URL = BASE_URL_V17 + "/business/customers/customer/" + SVC_INSTANCE_CUSTOMER_ID;
+
public static final String VNF_ID = "dfd02fb5-d7fb-4aac-b3c4-cd6b60058701";
public static final String GENERIC_VNF_NAME = "EsyVnfInstantiationTest2";
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestRestTemplateService.java
index 2e068bce..2e068bce 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestRestTemplateService.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestRestTemplateService.java
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestUtils.java
index e8dc9df2..77675745 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/aaisimulator/utils/TestUtils.java
@@ -80,6 +80,10 @@ public class TestUtils {
return getJsonString("test-data/service-instance.json");
}
+ public static String getSvcInstance() throws IOException {
+ return getJsonString("test-data/service-instance-aai.json");
+ }
+
public static String getGenericVnf() throws IOException {
return getJsonString("test-data/generic-vnf.json");
}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
deleted file mode 100755
index 70f5d21b..00000000
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*-
- * ============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.aaisimulator.controller;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
-import static org.onap.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
-import static org.onap.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
-import static org.onap.aaisimulator.utils.TestConstants.RELATED_TO_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCES_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_ID;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_TYPE;
-import static org.onap.aaisimulator.utils.TestConstants.VNF_ID;
-import static org.onap.aaisimulator.utils.TestUtils.getCustomer;
-import static org.onap.aaisimulator.utils.TestUtils.getServiceInstance;
-import java.io.IOException;
-import java.util.Optional;
-import java.util.UUID;
-import org.junit.After;
-import org.junit.Test;
-import org.onap.aai.domain.yang.Customer;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.GenericVnfs;
-import org.onap.aai.domain.yang.Relationship;
-import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.ServiceInstances;
-import org.onap.aai.domain.yang.ServiceSubscription;
-import org.onap.aaisimulator.service.providers.CustomerCacheServiceProvider;
-import org.onap.aaisimulator.utils.RequestError;
-import org.onap.aaisimulator.utils.RequestErrorResponseUtils;
-import org.onap.aaisimulator.utils.ServiceException;
-import org.onap.aaisimulator.utils.TestUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-/**
- * @author waqas.ikram@ericsson.com
- *
- */
-public class BusinessControllerTest extends AbstractSpringBootTest {
-
- private static final String FIREWALL_SERVICE_TYPE = "Firewall";
-
- private static final String ORCHESTRATION_STATUS = "Active";
-
- @Autowired
- private CustomerCacheServiceProvider cacheServiceProvider;
-
- @After
- public void after() {
- cacheServiceProvider.clearAll();
- }
-
- @Test
- public void test_putCustomer_successfullyAddedToCache() throws Exception {
- invokeCustomerEndPointAndAssertResponse();
- assertTrue(cacheServiceProvider.getCustomer(GLOBAL_CUSTOMER_ID).isPresent());
- }
-
- @Test
- public void test_getCustomer_ableToRetrieveCustomer() throws Exception {
- final String url = getUrl(CUSTOMERS_URL);
-
- final ResponseEntity<Void> response = testRestTemplateService.invokeHttpPut(url, getCustomer(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- final ResponseEntity<Customer> actual = testRestTemplateService.invokeHttpGet(url, Customer.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final Customer actualCustomer = actual.getBody();
- assertEquals(GLOBAL_CUSTOMER_ID, actualCustomer.getGlobalCustomerId());
- assertNotNull(actualCustomer.getResourceVersion());
- assertFalse(actualCustomer.getResourceVersion().isEmpty());
- }
-
- @Test
- public void test_getCustomer_returnRequestError_ifCustomerNotInCache() throws Exception {
- final String url = getUrl(CUSTOMERS_URL);
-
- final ResponseEntity<RequestError> actual = testRestTemplateService.invokeHttpGet(url, RequestError.class);
-
- assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
-
- final RequestError actualError = actual.getBody();
- final ServiceException serviceException = actualError.getServiceException();
-
- assertNotNull(serviceException);
- assertEquals(RequestErrorResponseUtils.ERROR_MESSAGE_ID, serviceException.getMessageId());
- assertEquals(RequestErrorResponseUtils.ERROR_MESSAGE, serviceException.getText());
- assertTrue(serviceException.getVariables().contains(HttpMethod.GET.toString()));
-
- }
-
- @Test
- public void test_getServiceSubscription_ableToRetrieveServiceSubscriptionFromCache() throws Exception {
- final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL);
-
- invokeCustomerEndPointAndAssertResponse();
-
- final ResponseEntity<ServiceSubscription> actual =
- testRestTemplateService.invokeHttpGet(url, ServiceSubscription.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final ServiceSubscription actualServiceSubscription = actual.getBody();
- assertEquals(SERVICE_TYPE, actualServiceSubscription.getServiceType());
- assertNotNull(actualServiceSubscription.getRelationshipList());
- assertFalse(actualServiceSubscription.getRelationshipList().getRelationship().isEmpty());
- }
-
- @Test
- public void test_putSericeInstance_ableToRetrieveServiceInstanceFromCache() throws Exception {
-
- invokeCustomerEndPointAndAssertResponse();
- invokeServiceInstanceEndPointAndAssertResponse();
-
-
- final Optional<ServiceInstance> actual =
- cacheServiceProvider.getServiceInstance(GLOBAL_CUSTOMER_ID, SERVICE_TYPE, SERVICE_INSTANCE_ID);
-
- assertTrue(actual.isPresent());
- final ServiceInstance actualServiceInstance = actual.get();
-
- assertEquals(SERVICE_INSTANCE_ID, actualServiceInstance.getServiceInstanceId());
- assertEquals(SERVICE_NAME, actualServiceInstance.getServiceInstanceName());
-
- }
-
- @Test
- public void test_getSericeInstance_usingServiceInstanceName_ableToRetrieveServiceInstanceFromCache()
- throws Exception {
-
- invokeCustomerEndPointAndAssertResponse();
- invokeServiceInstanceEndPointAndAssertResponse();
-
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCES_URL)
- + "?depth=2&service-instance-name=" + SERVICE_NAME;
-
- final ResponseEntity<ServiceInstances> actual =
- testRestTemplateService.invokeHttpGet(serviceInstanceUrl, ServiceInstances.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final ServiceInstances actualServiceInstances = actual.getBody();
- assertFalse(actualServiceInstances.getServiceInstance().isEmpty());
-
- assertEquals(SERVICE_NAME, actualServiceInstances.getServiceInstance().get(0).getServiceInstanceName());
-
- }
-
- @Test
- public void test_getSericeInstance_usingServiceInstanceName_returnRequestErrorIfnoServiceInstanceFound()
- throws Exception {
-
- invokeCustomerEndPointAndAssertResponse();
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCES_URL)
- + "?depth=2&service-instance-name=" + SERVICE_NAME;
-
- final ResponseEntity<RequestError> actual =
- testRestTemplateService.invokeHttpGet(serviceInstanceUrl, RequestError.class);
-
- assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- assertNotNull(actual.getBody().getServiceException());
-
- }
-
- @Test
- public void test_getSericeInstance_usingServiceInstanceId_ableToRetrieveServiceInstanceFromCache()
- throws Exception {
-
- final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
-
- invokeCustomerEndPointAndAssertResponse();
- invokeServiceInstanceEndPointAndAssertResponse();
-
- final ResponseEntity<ServiceInstance> actual =
- testRestTemplateService.invokeHttpGet(url, ServiceInstance.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final ServiceInstance actualServiceInstance = actual.getBody();
-
- assertEquals(SERVICE_NAME, actualServiceInstance.getServiceInstanceName());
- assertEquals(SERVICE_INSTANCE_ID, actualServiceInstance.getServiceInstanceId());
-
- }
-
- @Test
- public void test_getSericeInstance_usinginvalidServiceInstanceId_shouldReturnError() throws Exception {
-
- invokeCustomerEndPointAndAssertResponse();
-
- invokeServiceInstanceEndPointAndAssertResponse();
-
-
- final String invalidServiceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL,
- SERVICE_INSTANCES_URL + "/service-instance/" + UUID.randomUUID());
-
- final ResponseEntity<RequestError> actual =
- testRestTemplateService.invokeHttpGet(invalidServiceInstanceUrl, RequestError.class);
-
- assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
-
- final RequestError actualError = actual.getBody();
- final ServiceException serviceException = actualError.getServiceException();
-
- assertNotNull(serviceException);
- assertEquals(RequestErrorResponseUtils.ERROR_MESSAGE_ID, serviceException.getMessageId());
- assertEquals(RequestErrorResponseUtils.ERROR_MESSAGE, serviceException.getText());
- assertTrue(serviceException.getVariables().contains(HttpMethod.GET.toString()));
-
- }
-
- @Test
- public void test_getSericeInstance_usingInvalidServiceInstanceName_shouldReturnError() throws Exception {
-
- invokeCustomerEndPointAndAssertResponse();
- invokeServiceInstanceEndPointAndAssertResponse();
-
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCES_URL)
- + "?service-instance-name=Dummy&depth=2";
-
- final ResponseEntity<RequestError> actual =
- testRestTemplateService.invokeHttpGet(serviceInstanceUrl, RequestError.class);
-
- assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
-
- final RequestError actualError = actual.getBody();
- final ServiceException serviceException = actualError.getServiceException();
-
- assertNotNull(serviceException);
- assertEquals(RequestErrorResponseUtils.ERROR_MESSAGE_ID, serviceException.getMessageId());
- assertEquals(RequestErrorResponseUtils.ERROR_MESSAGE, serviceException.getText());
- assertTrue(serviceException.getVariables().contains(HttpMethod.GET.toString()));
-
- }
-
- @Test
- public void test_PathSericeInstance_usingServiceInstanceId_OrchStatusChangedInCache() throws Exception {
-
- final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
-
- invokeCustomerEndPointAndAssertResponse();
- invokeServiceInstanceEndPointAndAssertResponse();
-
- final HttpHeaders httpHeaders = testRestTemplateService.getHttpHeaders();
- httpHeaders.add(X_HTTP_METHOD_OVERRIDE, HttpMethod.PATCH.toString());
-
- final ResponseEntity<Void> orchStatuUpdateServiceInstanceResponse = testRestTemplateService
- .invokeHttpPost(httpHeaders, url, TestUtils.getOrchStatuUpdateServiceInstance(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, orchStatuUpdateServiceInstanceResponse.getStatusCode());
-
- final ResponseEntity<ServiceInstance> actual =
- testRestTemplateService.invokeHttpGet(url, ServiceInstance.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final ServiceInstance actualServiceInstance = actual.getBody();
-
- assertEquals(SERVICE_NAME, actualServiceInstance.getServiceInstanceName());
- assertEquals(SERVICE_INSTANCE_ID, actualServiceInstance.getServiceInstanceId());
- assertEquals(ORCHESTRATION_STATUS, actualServiceInstance.getOrchestrationStatus());
-
- }
-
- @Test
- public void test_putServiceSubscription_successfullyAddedToCache() throws Exception {
- final String serviceSubscriptionurl =
- getUrl(CUSTOMERS_URL, "/service-subscriptions/service-subscription/", FIREWALL_SERVICE_TYPE);
-
- invokeCustomerEndPointAndAssertResponse();
-
- final ResponseEntity<Void> responseEntity = testRestTemplateService.invokeHttpPut(serviceSubscriptionurl,
- TestUtils.getServiceSubscription(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
-
- final ResponseEntity<ServiceSubscription> actual =
- testRestTemplateService.invokeHttpGet(serviceSubscriptionurl, ServiceSubscription.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final ServiceSubscription actualServiceSubscription = actual.getBody();
- assertEquals(FIREWALL_SERVICE_TYPE, actualServiceSubscription.getServiceType());
-
- }
-
- @Test
- public void test_putSericeInstanceRelatedTo_ableToRetrieveServiceInstanceFromCache() throws Exception {
-
- final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
-
- invokeCustomerEndPointAndAssertResponse();
-
- invokeServiceInstanceEndPointAndAssertResponse();
-
- final String relationShipUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL,
- BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
-
- final ResponseEntity<Relationship> responseEntity2 = testRestTemplateService.invokeHttpPut(relationShipUrl,
- TestUtils.getRelationShipJsonObject(), Relationship.class);
-
- assertEquals(HttpStatus.ACCEPTED, responseEntity2.getStatusCode());
-
- final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> genericVnfResponse =
- testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
-
- final ResponseEntity<GenericVnfs> actual = testRestTemplateService
- .invokeHttpGet(url + RELATED_TO_URL + "?vnf-name=" + GENERIC_VNF_NAME, GenericVnfs.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
-
- assertTrue(actual.hasBody());
- final GenericVnfs genericVnfs = actual.getBody();
- assertFalse(genericVnfs.getGenericVnf().isEmpty());
- final GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0);
- assertEquals(GENERIC_VNF_NAME, genericVnf.getVnfName());
- }
-
- @Test
- public void test_DeleteSericeInstance_ServiceInstanceRemovedFromCache() throws Exception {
- final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
-
- invokeCustomerEndPointAndAssertResponse();
-
- invokeServiceInstanceEndPointAndAssertResponse();
-
- final Optional<ServiceInstance> optional =
- cacheServiceProvider.getServiceInstance(GLOBAL_CUSTOMER_ID, SERVICE_TYPE, SERVICE_INSTANCE_ID);
- assertTrue(optional.isPresent());
- final ServiceInstance serviceInstance = optional.get();
-
- final ResponseEntity<Void> responseEntity = testRestTemplateService
- .invokeHttpDelete(url + "?resource-version=" + serviceInstance.getResourceVersion(), Void.class);
- assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode());
- assertFalse(cacheServiceProvider.getServiceInstance(GLOBAL_CUSTOMER_ID, SERVICE_TYPE, SERVICE_INSTANCE_ID)
- .isPresent());
- }
-
- private void invokeServiceInstanceEndPointAndAssertResponse() throws IOException {
- final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> responseEntity =
- testRestTemplateService.invokeHttpPut(url, getServiceInstance(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
- }
-
- private void invokeCustomerEndPointAndAssertResponse() throws Exception, IOException {
- final ResponseEntity<Void> response =
- testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), getCustomer(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- }
-
-}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java
deleted file mode 100755
index 29d03ce0..00000000
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*-
- * ============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.aaisimulator.controller;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
-import static org.onap.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
-import static org.onap.aaisimulator.utils.Constants.VSERVER;
-import static org.onap.aaisimulator.utils.TestConstants.CLOUD_OWNER_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.CLOUD_REGION_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_PASSWORD;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_SERVICE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_ID;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_LIST_URL;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_SYSTEM_TYPE;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_TYEP;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_USERNAME;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_VENDOR;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SYSTEM_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.TENANTS_TENANT;
-import static org.onap.aaisimulator.utils.TestConstants.TENANT_ID;
-import static org.onap.aaisimulator.utils.TestConstants.VNF_ID;
-import static org.onap.aaisimulator.utils.TestConstants.VSERVER_ID;
-import static org.onap.aaisimulator.utils.TestConstants.VSERVER_NAME;
-import static org.onap.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.aaisimulator.models.CloudRegionKey;
-import org.onap.aaisimulator.service.providers.CloudRegionCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.CustomerCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
-import org.onap.aaisimulator.utils.Constants;
-import org.onap.aaisimulator.utils.TestConstants;
-import org.onap.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 CloudRegionsControllerTest extends AbstractSpringBootTest {
-
- private static final CloudRegionKey CLOUD_REGION_KEY = new CloudRegionKey(CLOUD_OWNER_NAME, CLOUD_REGION_NAME);
-
- @Autowired
- private CloudRegionCacheServiceProvider cloudRegionCacheServiceProvider;
-
- @Autowired
- private CustomerCacheServiceProvider customerCacheServiceProvider;
-
- @Autowired
- private GenericVnfCacheServiceProvider genericVnfCacheServiceProvider;
-
- @After
- public void after() {
- cloudRegionCacheServiceProvider.clearAll();
- customerCacheServiceProvider.clearAll();
- genericVnfCacheServiceProvider.clearAll();
- }
-
- @Test
- public void test_putCloudRegion_successfullyAddedToCache() throws Exception {
- final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
-
- invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
-
- final ResponseEntity<CloudRegion> response = testRestTemplateService.invokeHttpGet(url, CloudRegion.class);
- assertEquals(HttpStatus.OK, response.getStatusCode());
-
- assertTrue(response.hasBody());
-
- final CloudRegion cloudRegion = response.getBody();
- assertEquals(CLOUD_OWNER_NAME, cloudRegion.getCloudOwner());
- assertEquals(CLOUD_REGION_NAME, cloudRegion.getCloudRegionId());
-
- assertNotNull("ResourceVersion should not be null", cloudRegion.getResourceVersion());
-
- }
-
- @Test
- public void test_getCloudRegionWithDepthValue_shouldReturnMatchedCloudRegion() throws Exception {
- final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
-
- invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
-
- final ResponseEntity<CloudRegion> response =
- testRestTemplateService.invokeHttpGet(url + "?depth=2", CloudRegion.class);
- assertEquals(HttpStatus.OK, response.getStatusCode());
-
- assertTrue(response.hasBody());
-
- final CloudRegion cloudRegion = response.getBody();
- assertEquals(CLOUD_OWNER_NAME, cloudRegion.getCloudOwner());
- assertEquals(CLOUD_REGION_NAME, cloudRegion.getCloudRegionId());
-
- assertNotNull("ResourceVersion should not be null", cloudRegion.getResourceVersion());
-
- }
-
- @Test
- public void test_putGenericVnfRelationShipToPlatform_successfullyAddedToCache() throws Exception {
-
- final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
-
- invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
-
- final String relationShipUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
- BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
-
- final ResponseEntity<Relationship> responseEntity = testRestTemplateService.invokeHttpPut(relationShipUrl,
- TestUtils.getGenericVnfRelationShip(), Relationship.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
-
- final Optional<CloudRegion> optional = cloudRegionCacheServiceProvider.getCloudRegion(CLOUD_REGION_KEY);
- assertTrue(optional.isPresent());
-
- final CloudRegion actual = optional.get();
-
- assertNotNull(actual.getRelationshipList());
- final List<Relationship> relationshipList = actual.getRelationshipList().getRelationship();
- assertFalse("Relationship list should not be empty", relationshipList.isEmpty());
- final Relationship relationship = relationshipList.get(0);
-
- assertEquals(GENERIC_VNF_URL + VNF_ID, relationship.getRelatedLink());
-
- assertFalse("RelationshipData list should not be empty", relationship.getRelationshipData().isEmpty());
- assertFalse("RelatedToProperty list should not be empty", relationship.getRelatedToProperty().isEmpty());
-
- final RelationshipData relationshipData = relationship.getRelationshipData().get(0);
- assertEquals(Constants.GENERIC_VNF_VNF_ID, relationshipData.getRelationshipKey());
- assertEquals(TestConstants.VNF_ID, relationshipData.getRelationshipValue());
-
- final RelatedToProperty relatedToProperty = relationship.getRelatedToProperty().get(0);
- assertEquals(Constants.GENERIC_VNF_VNF_NAME, relatedToProperty.getPropertyKey());
- assertEquals(TestConstants.GENERIC_VNF_NAME, relatedToProperty.getPropertyValue());
-
- }
-
- @Test
- public void test_putTenant_successfullyAddedToCache() throws Exception {
- final String cloudRegionUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
-
- invokeCloudRegionHttpPutEndPointAndAssertResponse(cloudRegionUrl);
-
- final String tenantUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME,
- "/" + CLOUD_REGION_NAME + TENANTS_TENANT + TENANT_ID);
- addTenantAndAssertResponse(tenantUrl);
-
- final ResponseEntity<Tenant> response = testRestTemplateService.invokeHttpGet(tenantUrl, Tenant.class);
- assertEquals(HttpStatus.OK, response.getStatusCode());
-
- assertTrue(response.hasBody());
-
- final Tenant tenant = response.getBody();
- assertEquals(TENANT_ID, tenant.getTenantId());
- assertEquals("admin", tenant.getTenantName());
-
- assertNotNull("ResourceVersion should not be null", tenant.getResourceVersion());
-
- }
-
- @Test
- public void test_putTenantRelationToGenericVnf_successfullyAddedToCache() throws Exception {
-
- addCustomerServiceAndGenericVnf();
-
- final String cloudRegionUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
- invokeCloudRegionHttpPutEndPointAndAssertResponse(cloudRegionUrl);
-
- final String tenantUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
- TENANTS_TENANT + TENANT_ID);
- addTenantAndAssertResponse(tenantUrl);
-
- final String tenantRelationShipUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME,
- "/" + CLOUD_REGION_NAME, TENANTS_TENANT + TENANT_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
-
- final ResponseEntity<Void> tenantRelationShipResponse = testRestTemplateService
- .invokeHttpPut(tenantRelationShipUrl, TestUtils.getGenericVnfRelatedLink(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, tenantRelationShipResponse.getStatusCode());
-
- final Optional<Tenant> optional = cloudRegionCacheServiceProvider.getTenant(CLOUD_REGION_KEY, TENANT_ID);
-
- assertTrue(optional.isPresent());
- final Tenant actualTenant = optional.get();
- final RelationshipList relationshipList = actualTenant.getRelationshipList();
- assertNotNull(relationshipList);
- assertFalse(relationshipList.getRelationship().isEmpty());
-
- final Relationship relationship = relationshipList.getRelationship().get(0);
-
- assertEquals(Constants.BELONGS_TO, relationship.getRelationshipLabel());
- assertFalse(relationship.getRelationshipData().isEmpty());
- assertEquals(1, relationship.getRelationshipData().size());
-
- final List<RelationshipData> relationshipDataList = relationship.getRelationshipData();
-
- final RelationshipData relationshipData =
- getRelationshipData(relationshipDataList, Constants.GENERIC_VNF_VNF_ID);
- assertNotNull(relationshipData);
- assertEquals(VNF_ID, relationshipData.getRelationshipValue());
-
- final List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty();
-
- final RelatedToProperty property = getRelatedToProperty(relatedToPropertyList, Constants.GENERIC_VNF_VNF_NAME);
- assertNotNull(property);
- assertEquals(GENERIC_VNF_NAME, property.getPropertyValue());
-
- final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(genericVnfOptional.isPresent());
- final GenericVnf actualGenericVnf = genericVnfOptional.get();
- final RelationshipList relationshipListGenericVnf = actualGenericVnf.getRelationshipList();
- assertNotNull(relationshipListGenericVnf);
- assertFalse(relationshipListGenericVnf.getRelationship().isEmpty());
-
- final Relationship relationshipGenericVnf = relationshipListGenericVnf.getRelationship().get(0);
-
- assertEquals(Constants.BELONGS_TO, relationshipGenericVnf.getRelationshipLabel());
- assertFalse(relationshipGenericVnf.getRelationshipData().isEmpty());
- assertEquals(3, relationshipGenericVnf.getRelationshipData().size());
-
- }
-
- @Test
- public void test_putEsrSystemInfo_successfullyAddedToCache() throws Exception {
- final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
-
- invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
-
- final String esrSystemInfoListUrl = getUrl(TestConstants.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(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
-
- invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
- addCustomerServiceAndGenericVnf();
-
- 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());
- assertNotNull(actualVserver.getRelationshipList());
- assertFalse(actualVserver.getRelationshipList().getRelationship().isEmpty());
-
- final Optional<GenericVnf> optional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(optional.isPresent());
- final GenericVnf genericVnf = optional.get();
- assertNotNull(genericVnf.getRelationshipList());
- assertFalse(genericVnf.getRelationshipList().getRelationship().isEmpty());
-
- final Relationship expectedRelationShip = genericVnf.getRelationshipList().getRelationship().get(0);
- assertEquals(VSERVER, expectedRelationShip.getRelatedTo());
- assertNotNull(expectedRelationShip.getRelationshipData());
- assertEquals(4, expectedRelationShip.getRelationshipData().size());
-
- final List<RelationshipData> relationshipDataList = expectedRelationShip.getRelationshipData();
- final RelationshipData vServerrelationshipData =
- getRelationshipData(relationshipDataList, Constants.VSERVER_VSERVER_ID);
- assertNotNull(vServerrelationshipData);
- assertEquals(VSERVER_ID, vServerrelationshipData.getRelationshipValue());
-
- final RelationshipData cloudOwnerRelationshipData =
- getRelationshipData(relationshipDataList, Constants.CLOUD_REGION_CLOUD_OWNER);
- assertNotNull(cloudOwnerRelationshipData);
- assertEquals(CLOUD_OWNER_NAME, cloudOwnerRelationshipData.getRelationshipValue());
-
- final RelationshipData cloudRegionIdRelationshipData =
- getRelationshipData(relationshipDataList, Constants.CLOUD_REGION_CLOUD_REGION_ID);
- assertNotNull(cloudRegionIdRelationshipData);
- assertEquals(CLOUD_REGION_NAME, cloudRegionIdRelationshipData.getRelationshipValue());
-
- final RelationshipData tenantRelationshipData =
- getRelationshipData(relationshipDataList, Constants.TENANT_TENANT_ID);
- assertNotNull(tenantRelationshipData);
- assertEquals(TENANT_ID, tenantRelationshipData.getRelationshipValue());
-
- }
-
- @Test
- public void test_deleteVServer_successfullyRemoveFromCache() throws Exception {
- final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
-
- invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
- addCustomerServiceAndGenericVnf();
-
- final String tenantUrl = url + TENANTS_TENANT + TENANT_ID;
- addTenantAndAssertResponse(tenantUrl);
-
- final String vServerAddUrl = tenantUrl + VSERVER_URL + VSERVER_ID;
-
- final ResponseEntity<Void> vServerAddResponse =
- testRestTemplateService.invokeHttpPut(vServerAddUrl, TestUtils.getVserver(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, vServerAddResponse.getStatusCode());
-
- final Optional<Vserver> optional =
- cloudRegionCacheServiceProvider.getVserver(CLOUD_REGION_KEY, TENANT_ID, VSERVER_ID);
- assertTrue(optional.isPresent());
- final Vserver vserver = optional.get();
-
- final String vServerRemoveUrl = vServerAddUrl + "?resource-version=" + vserver.getResourceVersion();
-
- final ResponseEntity<Void> responseEntity =
- testRestTemplateService.invokeHttpDelete(vServerRemoveUrl, Void.class);
- assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode());
- assertFalse(cloudRegionCacheServiceProvider.getVserver(CLOUD_REGION_KEY, TENANT_ID, VSERVER_ID).isPresent());
-
-
- }
-
- private void addTenantAndAssertResponse(final String tenantUrl) throws IOException {
- final ResponseEntity<Void> responseEntity =
- testRestTemplateService.invokeHttpPut(tenantUrl, TestUtils.getTenant(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
- }
-
- private void addCustomerServiceAndGenericVnf() throws Exception, IOException {
- final ResponseEntity<Void> customerResponse =
- testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, customerResponse.getStatusCode());
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> serviceInstanceResponse =
- testRestTemplateService.invokeHttpPut(serviceInstanceUrl, TestUtils.getServiceInstance(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
-
- final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> genericVnfResponse =
- testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
-
- }
-
- private void invokeCloudRegionHttpPutEndPointAndAssertResponse(final String url) throws IOException {
- final ResponseEntity<Void> responseEntity =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getCloudRegion(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
- }
-
-}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java
deleted file mode 100755
index fb406ab4..00000000
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*-
- * ============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.aaisimulator.controller;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
-import static org.onap.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_PASSWORD;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_SERVICE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_ID;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_LIST_URL;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_SYSTEM_TYPE;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_TYEP;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_USERNAME;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_VENDOR;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_VIM_ID;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_VNFM_ID;
-import static org.onap.aaisimulator.utils.TestConstants.ESR_VNFM_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SYSTEM_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.VNF_ID;
-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.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.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.Relationship;
-import org.onap.aai.domain.yang.RelationshipData;
-import org.onap.aai.domain.yang.RelationshipList;
-import org.onap.aaisimulator.service.providers.ExternalSystemCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
-import org.onap.aaisimulator.utils.Constants;
-import org.onap.aaisimulator.utils.TestConstants;
-import org.onap.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;
-
-
- @Autowired
- private GenericVnfCacheServiceProvider genericVnfCacheServiceProvider;
-
- @After
- public void after() {
- externalSystemCacheServiceProvider.clearAll();
- genericVnfCacheServiceProvider.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(TestConstants.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());
-
-
- }
-
- @Test
- public void test_putEsrRelationToGenericVnfm_successfullyAddedToCache() throws Exception {
- final String esrVnfmUrl = getUrl(ESR_VNFM_URL, ESR_VNFM_ID);
-
- addEsrVnfmAndAssertResponse(esrVnfmUrl);
- addCustomerServiceAndGenericVnf();
-
- final String relationShipUrl = esrVnfmUrl + RELATIONSHIP_LIST_RELATIONSHIP_URL;
-
- final ResponseEntity<Void> response = testRestTemplateService.invokeHttpPut(relationShipUrl,
- TestUtils.getGenericVnfRelatedLink(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- final Optional<EsrVnfm> optional = externalSystemCacheServiceProvider.getEsrVnfm(ESR_VNFM_ID);
- assertTrue(optional.isPresent());
-
- final EsrVnfm actualEsrVnfm = optional.get();
- final RelationshipList relationshipList = actualEsrVnfm.getRelationshipList();
- assertNotNull(relationshipList);
- assertFalse(relationshipList.getRelationship().isEmpty());
-
- final Relationship relationship = relationshipList.getRelationship().get(0);
-
- assertEquals(Constants.DEPENDS_ON, relationship.getRelationshipLabel());
- assertFalse(relationship.getRelationshipData().isEmpty());
- assertEquals(1, relationship.getRelationshipData().size());
-
- final RelationshipData relationshipData =
- getRelationshipData(relationship.getRelationshipData(), Constants.GENERIC_VNF_VNF_ID);
- assertNotNull(relationshipData);
- assertEquals(VNF_ID, relationshipData.getRelationshipValue());
-
- final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(genericVnfOptional.isPresent());
- final GenericVnf actualGenericVnf = genericVnfOptional.get();
- final RelationshipList relationshipListGenericVnf = actualGenericVnf.getRelationshipList();
- assertNotNull(relationshipListGenericVnf);
- assertFalse(relationshipListGenericVnf.getRelationship().isEmpty());
-
- final Relationship relationshipGenericVnf = relationshipListGenericVnf.getRelationship().get(0);
-
- assertEquals(Constants.DEPENDS_ON, relationshipGenericVnf.getRelationshipLabel());
- assertFalse(relationshipGenericVnf.getRelationshipData().isEmpty());
- assertEquals(1, relationshipGenericVnf.getRelationshipData().size());
-
- final RelationshipData esrRelationshipData =
- getRelationshipData(relationshipGenericVnf.getRelationshipData(), Constants.ESR_VNFM_VNFM_ID);
- assertNotNull(esrRelationshipData);
- assertEquals(ESR_VNFM_ID, esrRelationshipData.getRelationshipValue());
-
-
- }
-
- private void addEsrVnfmAndAssertResponse(final String esrVnfmUrl) throws IOException {
- final ResponseEntity<Void> esrVnfmResponse =
- testRestTemplateService.invokeHttpPut(esrVnfmUrl, TestUtils.getEsrVnfm(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, esrVnfmResponse.getStatusCode());
- }
-
- private void addCustomerServiceAndGenericVnf() throws Exception, IOException {
- final ResponseEntity<Void> customerResponse =
- testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, customerResponse.getStatusCode());
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> serviceInstanceResponse =
- testRestTemplateService.invokeHttpPut(serviceInstanceUrl, TestUtils.getServiceInstance(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
-
- final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> genericVnfResponse =
- testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
-
- }
-}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
deleted file mode 100755
index 8ec26065..00000000
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*-
- * ============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.aaisimulator.controller;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
-import static org.onap.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
-import static org.onap.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
-import static org.onap.aaisimulator.utils.TestConstants.CLOUD_OWNER_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.CLOUD_REGION_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
-import static org.onap.aaisimulator.utils.TestConstants.LINE_OF_BUSINESS_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.PLATFORM_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_ID;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_TYPE;
-import static org.onap.aaisimulator.utils.TestConstants.VNF_ID;
-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.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;
-import org.onap.aai.domain.yang.RelationshipList;
-import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aaisimulator.service.providers.CustomerCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.LinesOfBusinessCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.PlatformCacheServiceProvider;
-import org.onap.aaisimulator.utils.Constants;
-import org.onap.aaisimulator.utils.TestConstants;
-import org.onap.aaisimulator.utils.TestUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-/**
- * @author Waqas Ikram (waqas.ikram@est.tech)
- *
- */
-public class GenericVnfsControllerTest extends AbstractSpringBootTest {
-
- @Autowired
- private CustomerCacheServiceProvider customerCacheServiceProvider;
-
- @Autowired
- private GenericVnfCacheServiceProvider genericVnfCacheServiceProvider;
-
- @Autowired
- private LinesOfBusinessCacheServiceProvider linesOfBusinessCacheServiceProvider;
-
- @Autowired
- private PlatformCacheServiceProvider platformVnfCacheServiceProvider;
-
- @After
- public void after() {
- customerCacheServiceProvider.clearAll();
- genericVnfCacheServiceProvider.clearAll();
- platformVnfCacheServiceProvider.clearAll();
- linesOfBusinessCacheServiceProvider.clearAll();
- }
-
- @Test
- public void test_putGenericVnf_successfullyAddedToCache() throws Exception {
-
- final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> genericVnfResponse =
- testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
-
- final ResponseEntity<GenericVnf> response =
- testRestTemplateService.invokeHttpGet(genericVnfUrl, GenericVnf.class);
- assertEquals(HttpStatus.OK, response.getStatusCode());
-
- assertTrue(response.hasBody());
-
- final GenericVnf actualGenericVnf = response.getBody();
- assertEquals(GENERIC_VNF_NAME, actualGenericVnf.getVnfName());
- assertEquals(VNF_ID, actualGenericVnf.getVnfId());
-
- }
-
- @Test
- public void test_putGenericVnfRelation_successfullyAddedToCache() throws Exception {
-
- addCustomerServiceAndGenericVnf();
-
- final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
- final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
- .invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getRelationShip(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, genericVnfRelationShipResponse.getStatusCode());
-
-
- final Optional<ServiceInstance> optional =
- customerCacheServiceProvider.getServiceInstance(GLOBAL_CUSTOMER_ID, SERVICE_TYPE, SERVICE_INSTANCE_ID);
-
- assertTrue(optional.isPresent());
-
- final ServiceInstance actualServiceInstance = optional.get();
- final RelationshipList actualRelationshipList = actualServiceInstance.getRelationshipList();
- assertNotNull(actualRelationshipList);
- assertFalse(actualRelationshipList.getRelationship().isEmpty());
- final Relationship actualRelationShip = actualRelationshipList.getRelationship().get(0);
-
- assertEquals(Constants.COMPOSED_OF, actualRelationShip.getRelationshipLabel());
- assertEquals(GENERIC_VNF_URL + VNF_ID, actualRelationShip.getRelatedLink());
-
-
- assertFalse(actualRelationShip.getRelatedToProperty().isEmpty());
- assertFalse(actualRelationShip.getRelationshipData().isEmpty());
- final RelatedToProperty actualRelatedToProperty = actualRelationShip.getRelatedToProperty().get(0);
- final RelationshipData actualRelationshipData = actualRelationShip.getRelationshipData().get(0);
-
- assertEquals(Constants.GENERIC_VNF_VNF_NAME, actualRelatedToProperty.getPropertyKey());
- assertEquals(GENERIC_VNF_NAME, actualRelatedToProperty.getPropertyValue());
- assertEquals(Constants.GENERIC_VNF_VNF_ID, actualRelationshipData.getRelationshipKey());
- assertEquals(VNF_ID, actualRelationshipData.getRelationshipValue());
-
- final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(genericVnfOptional.isPresent());
- final GenericVnf actualGenericVnf = genericVnfOptional.get();
- final RelationshipList relationshipList = actualGenericVnf.getRelationshipList();
- assertNotNull(relationshipList);
- assertFalse(relationshipList.getRelationship().isEmpty());
-
- final Relationship relationship = relationshipList.getRelationship().get(0);
- assertFalse(relationship.getRelatedToProperty().isEmpty());
- assertEquals(3, relationship.getRelationshipData().size());
- assertEquals(CUSTOMERS_URL + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL, relationship.getRelatedLink());
-
-
- final List<RelatedToProperty> relatedToProperty = relationship.getRelatedToProperty();
- final RelatedToProperty firstRelatedToProperty = relatedToProperty.get(0);
- assertEquals(Constants.SERVICE_INSTANCE_SERVICE_INSTANCE_NAME, firstRelatedToProperty.getPropertyKey());
- assertEquals(SERVICE_NAME, firstRelatedToProperty.getPropertyValue());
-
- final List<RelationshipData> relationshipData = relationship.getRelationshipData();
-
- final RelationshipData globalRelationshipData =
- getRelationshipData(relationshipData, Constants.CUSTOMER_GLOBAL_CUSTOMER_ID);
- assertNotNull(globalRelationshipData);
- assertEquals(GLOBAL_CUSTOMER_ID, globalRelationshipData.getRelationshipValue());
-
- final RelationshipData serviceSubscriptionRelationshipData =
- getRelationshipData(relationshipData, Constants.SERVICE_SUBSCRIPTION_SERVICE_TYPE);
- assertNotNull(serviceSubscriptionRelationshipData);
- assertEquals(SERVICE_TYPE, serviceSubscriptionRelationshipData.getRelationshipValue());
-
- final RelationshipData serviceInstanceRelationshipData =
- getRelationshipData(relationshipData, Constants.SERVICE_INSTANCE_SERVICE_INSTANCE_ID);
- assertNotNull(serviceInstanceRelationshipData);
- assertEquals(SERVICE_INSTANCE_ID, serviceInstanceRelationshipData.getRelationshipValue());
-
- }
-
- @Test
- public void test_putGenericVnfRelationToPlatform_successfullyAddedToCache() throws Exception {
- addCustomerServiceAndGenericVnf();
-
- final String platformUrl = getUrl(TestConstants.PLATFORMS_URL, PLATFORM_NAME);
- final ResponseEntity<Void> platformResponse =
- testRestTemplateService.invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
-
- final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
- final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
- .invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getPlatformRelatedLink(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, genericVnfRelationShipResponse.getStatusCode());
-
- final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(genericVnfOptional.isPresent());
- final GenericVnf actualGenericVnf = genericVnfOptional.get();
- final RelationshipList relationshipList = actualGenericVnf.getRelationshipList();
- assertNotNull(relationshipList);
- assertFalse(relationshipList.getRelationship().isEmpty());
-
- final Relationship relationship = relationshipList.getRelationship().get(0);
-
- assertEquals(Constants.USES, relationship.getRelationshipLabel());
- assertFalse(relationship.getRelationshipData().isEmpty());
- assertEquals(1, relationship.getRelationshipData().size());
- assertEquals(TestConstants.PLATFORMS_URL + PLATFORM_NAME, relationship.getRelatedLink());
-
-
- final List<RelationshipData> relationshipData = relationship.getRelationshipData();
-
- final RelationshipData platformRelationshipData =
- getRelationshipData(relationshipData, Constants.PLATFORM_PLATFORM_NAME);
- assertNotNull(platformRelationshipData);
- assertEquals(PLATFORM_NAME, platformRelationshipData.getRelationshipValue());
-
- }
-
- @Test
- public void test_putGenericVnfRelationToLineOfBusiness_successfullyAddedToCache() throws Exception {
- addCustomerServiceAndGenericVnf();
-
- final String url = getUrl(TestConstants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME);
- final ResponseEntity<Void> responseEntity =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
-
- final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
- final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
- .invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getLineOfBusinessRelatedLink(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, genericVnfRelationShipResponse.getStatusCode());
-
- final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(genericVnfOptional.isPresent());
- final GenericVnf actualGenericVnf = genericVnfOptional.get();
- final RelationshipList relationshipList = actualGenericVnf.getRelationshipList();
- assertNotNull(relationshipList);
- assertFalse(relationshipList.getRelationship().isEmpty());
-
- final Relationship relationship = relationshipList.getRelationship().get(0);
-
- assertEquals(Constants.USES, relationship.getRelationshipLabel());
- assertEquals(TestConstants.LINES_OF_BUSINESS_URL + LINE_OF_BUSINESS_NAME, relationship.getRelatedLink());
-
- assertFalse(relationship.getRelationshipData().isEmpty());
- assertEquals(1, relationship.getRelationshipData().size());
-
- final List<RelationshipData> relationshipData = relationship.getRelationshipData();
-
- final RelationshipData lineOfBusinessRelationshipData =
- getRelationshipData(relationshipData, Constants.LINE_OF_BUSINESS_LINE_OF_BUSINESS_NAME);
- assertNotNull(lineOfBusinessRelationshipData);
- assertEquals(LINE_OF_BUSINESS_NAME, lineOfBusinessRelationshipData.getRelationshipValue());
-
- }
-
- @Test
- public void test_putGenericVnfRelationToCloudRegion_successfullyAddedToCache() throws Exception {
- addCustomerServiceAndGenericVnf();
-
- final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
-
- final ResponseEntity<Void> responseEntity =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getCloudRegion(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
-
- final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
- final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
- .invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getCloudRegionRelatedLink(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, genericVnfRelationShipResponse.getStatusCode());
-
- final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(genericVnfOptional.isPresent());
- final GenericVnf actualGenericVnf = genericVnfOptional.get();
- final RelationshipList relationshipList = actualGenericVnf.getRelationshipList();
- assertNotNull(relationshipList);
- assertFalse(relationshipList.getRelationship().isEmpty());
-
- final Relationship relationship = relationshipList.getRelationship().get(0);
-
- assertEquals(Constants.LOCATED_IN, relationship.getRelationshipLabel());
- assertEquals(TestConstants.CLOUD_REGIONS + CLOUD_OWNER_NAME + "/" + CLOUD_REGION_NAME,
- relationship.getRelatedLink());
-
- assertFalse(relationship.getRelationshipData().isEmpty());
- assertEquals(2, relationship.getRelationshipData().size());
-
- final List<RelationshipData> relationshipDataList = relationship.getRelationshipData();
-
- final RelationshipData cloudOwnerRelationshipData =
- getRelationshipData(relationshipDataList, Constants.CLOUD_REGION_CLOUD_OWNER);
- assertNotNull(cloudOwnerRelationshipData);
- assertEquals(CLOUD_OWNER_NAME, cloudOwnerRelationshipData.getRelationshipValue());
-
- final RelationshipData cloudRegionIdRelationshipData =
- getRelationshipData(relationshipDataList, Constants.CLOUD_REGION_CLOUD_REGION_ID);
- assertNotNull(cloudRegionIdRelationshipData);
- assertEquals(CLOUD_REGION_NAME, cloudRegionIdRelationshipData.getRelationshipValue());
-
- final List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty();
-
- final RelatedToProperty cloudRegionOwnerDefinedTypeProperty =
- getRelatedToProperty(relatedToPropertyList, Constants.CLOUD_REGION_OWNER_DEFINED_TYPE);
- assertNotNull(cloudRegionOwnerDefinedTypeProperty);
- assertEquals("OwnerType", cloudRegionOwnerDefinedTypeProperty.getPropertyValue());
-
- }
-
- @Test
- public void test_putBiDirectionalRelationShip_successfullyAddedToCache() throws Exception {
- addCustomerServiceAndGenericVnf();
-
- final String relationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
-
- final ResponseEntity<Relationship> responseEntity = testRestTemplateService.invokeHttpPut(relationShipUrl,
- TestUtils.getTenantRelationShip(), Relationship.class);
- assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
-
- final Optional<GenericVnf> optional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(optional.isPresent());
-
- final GenericVnf actual = optional.get();
-
- assertNotNull(actual.getRelationshipList());
- final List<Relationship> relationshipList = actual.getRelationshipList().getRelationship();
- assertFalse("Relationship list should not be empty", relationshipList.isEmpty());
- final Relationship relationship = relationshipList.get(0);
-
- assertFalse("RelationshipData list should not be empty", relationship.getRelationshipData().isEmpty());
- assertFalse("RelatedToProperty list should not be empty", relationship.getRelatedToProperty().isEmpty());
- }
-
- @Test
- public void test_patchGenericVnf_usingVnfId_OrchStatusChangedInCache() throws Exception {
- addCustomerServiceAndGenericVnf();
-
- final HttpHeaders httpHeaders = testRestTemplateService.getHttpHeaders();
- httpHeaders.add(X_HTTP_METHOD_OVERRIDE, HttpMethod.PATCH.toString());
- httpHeaders.remove(HttpHeaders.CONTENT_TYPE);
- httpHeaders.add(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_MERGE_PATCH_JSON);
-
- final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> orchStatuUpdateServiceInstanceResponse = testRestTemplateService
- .invokeHttpPost(httpHeaders, genericVnfUrl, TestUtils.getGenericVnfOrchStatuUpdate(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, orchStatuUpdateServiceInstanceResponse.getStatusCode());
-
- final ResponseEntity<GenericVnf> response =
- testRestTemplateService.invokeHttpGet(genericVnfUrl, GenericVnf.class);
- assertEquals(HttpStatus.OK, response.getStatusCode());
-
- assertTrue(response.hasBody());
-
- final GenericVnf actualGenericVnf = response.getBody();
- assertEquals(GENERIC_VNF_NAME, actualGenericVnf.getVnfName());
- assertEquals(VNF_ID, actualGenericVnf.getVnfId());
- assertEquals("Assigned", actualGenericVnf.getOrchestrationStatus());
-
- }
-
- @Test
- public void test_getGenericVnfs_usingSelfLink_getAllGenericVnfsInCache() throws Exception {
-
- addCustomerServiceAndGenericVnf();
-
- final String selfLink = "http://localhost:9921/generic-vnf/" + VNF_ID;
- final String url = getUrl(TestConstants.GENERIC_VNFS_URL_1) + "?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());
- }
-
- @Test
- public void test_deleteGenericVnf_usingVnfIdAndResourceVersion_removedFromCache() throws Exception {
-
- addCustomerServiceAndGenericVnf();
-
- final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
- assertTrue(genericVnfOptional.isPresent());
- final GenericVnf genericVnf = genericVnfOptional.get();
-
- final String genericVnfDeleteUrl =
- getUrl(GENERIC_VNF_URL, genericVnf.getVnfId()) + "?resource-version=" + genericVnf.getResourceVersion();
-
- final ResponseEntity<Void> responseEntity =
- testRestTemplateService.invokeHttpDelete(genericVnfDeleteUrl, Void.class);
- assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode());
- assertFalse(genericVnfCacheServiceProvider.getGenericVnf(VNF_ID).isPresent());
-
- }
-
- private void addCustomerServiceAndGenericVnf() throws Exception, IOException {
- final ResponseEntity<Void> customerResponse =
- testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, customerResponse.getStatusCode());
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> serviceInstanceResponse =
- testRestTemplateService.invokeHttpPut(serviceInstanceUrl, TestUtils.getServiceInstance(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
-
- final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> genericVnfResponse =
- testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
-
- }
-
-
-}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
deleted file mode 100755
index 12412872..00000000
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*-
- * ============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.aaisimulator.controller;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.aaisimulator.utils.Constants.RESOURCE_LINK;
-import static org.onap.aaisimulator.utils.Constants.RESOURCE_TYPE;
-import static org.onap.aaisimulator.utils.Constants.SERVICE_RESOURCE_TYPE;
-import static org.onap.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNFS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_ID;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_NAME;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.VNF_ID;
-import java.io.IOException;
-import java.util.Map;
-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.ServiceInstance;
-import org.onap.aaisimulator.models.Format;
-import org.onap.aaisimulator.models.Results;
-import org.onap.aaisimulator.service.providers.CustomerCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.NodesCacheServiceProvider;
-import org.onap.aaisimulator.utils.TestConstants;
-import org.onap.aaisimulator.utils.TestUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-/**
- * @author waqas.ikram@ericsson.com
- *
- */
-public class NodesControllerTest extends AbstractSpringBootTest {
-
- @Autowired
- private NodesCacheServiceProvider nodesCacheServiceProvider;
-
- @Autowired
- private CustomerCacheServiceProvider customerCacheServiceProvider;
-
- @After
- public void after() {
- nodesCacheServiceProvider.clearAll();
- customerCacheServiceProvider.clearAll();
- }
-
- @Test
- public void test_getNodesSericeInstance_usingServiceInstanceId_ableToRetrieveServiceInstanceFromCache()
- throws Exception {
-
- invokeCustomerandServiceInstanceUrls();
-
- final ResponseEntity<ServiceInstance> actual = testRestTemplateService
- .invokeHttpGet(getUrl(TestConstants.NODES_URL, SERVICE_INSTANCE_URL), ServiceInstance.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final ServiceInstance actualServiceInstance = actual.getBody();
-
- assertEquals(SERVICE_NAME, actualServiceInstance.getServiceInstanceName());
- assertEquals(SERVICE_INSTANCE_ID, actualServiceInstance.getServiceInstanceId());
-
- }
-
- @Test
- public void test_getNodesSericeInstance_usingServiceInstanceIdAndFormatPathed_ableToRetrieveServiceInstanceFromCache()
- throws Exception {
-
- invokeCustomerandServiceInstanceUrls();
-
- final ResponseEntity<Results> actual = testRestTemplateService.invokeHttpGet(
- getUrl(TestConstants.NODES_URL, SERVICE_INSTANCE_URL) + "?format=" + Format.PATHED.getValue(),
- Results.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final Results result = actual.getBody();
-
- assertNotNull(result.getValues());
- assertFalse(result.getValues().isEmpty());
- final Map<String, Object> actualMap = result.getValues().get(0);
-
- assertEquals(CUSTOMERS_URL + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL, actualMap.get(RESOURCE_LINK));
- assertEquals(SERVICE_RESOURCE_TYPE, actualMap.get(RESOURCE_TYPE));
-
- }
-
- @Test
- public void test_getNodesGenericVnfs_usingVnfName_ableToRetrieveItFromCache() throws Exception {
- invokeCustomerandServiceInstanceUrls();
-
- final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> genericVnfResponse =
- testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
-
- final String nodeGenericVnfsUrl =
- getUrl(TestConstants.NODES_URL, GENERIC_VNFS_URL) + "?vnf-name=" + GENERIC_VNF_NAME;
-
- final ResponseEntity<GenericVnfs> actual =
- testRestTemplateService.invokeHttpGet(nodeGenericVnfsUrl, GenericVnfs.class);
-
- assertEquals(HttpStatus.OK, actual.getStatusCode());
- assertTrue(actual.hasBody());
-
- final GenericVnfs genericVnfs = actual.getBody();
- assertEquals(1, genericVnfs.getGenericVnf().size());
-
- final GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0);
- assertEquals(GENERIC_VNF_NAME, genericVnf.getVnfName());
- assertEquals(VNF_ID, genericVnf.getVnfId());
-
- }
-
- private void invokeCustomerandServiceInstanceUrls() throws Exception, IOException {
- final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
-
- final ResponseEntity<Void> response =
- testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- final ResponseEntity<Void> response2 =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getServiceInstance(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, response2.getStatusCode());
- }
-
-}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
deleted file mode 100755
index c5baad47..00000000
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*-
- * ============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.aaisimulator.controller;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
-import static org.onap.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_ID;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_TYPE;
-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.OwningEntity;
-import org.onap.aai.domain.yang.Relationship;
-import org.onap.aai.domain.yang.RelationshipData;
-import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aaisimulator.models.Format;
-import org.onap.aaisimulator.models.Results;
-import org.onap.aaisimulator.service.providers.CustomerCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.OwnEntityCacheServiceProvider;
-import org.onap.aaisimulator.utils.Constants;
-import org.onap.aaisimulator.utils.TestConstants;
-import org.onap.aaisimulator.utils.TestUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-/**
- * @author waqas.ikram@ericsson.com
- *
- */
-public class OwningEntityControllerTest extends AbstractSpringBootTest {
-
- private static final String OWN_ENTITY_ID_VALUE = "oe_1";
- private static final String OWN_ENTITY_NAME_VALUE = "oe_2";
-
- @Autowired
- private OwnEntityCacheServiceProvider cacheServiceProvider;
-
- @Autowired
- private CustomerCacheServiceProvider customerCacheServiceProvider;
-
- @After
- public void after() {
- cacheServiceProvider.clearAll();
- customerCacheServiceProvider.clearAll();
- }
-
- @Test
- public void test_putOwningEntity_successfullyAddedToCache() throws Exception {
- final String url = getUrl(TestConstants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
- final ResponseEntity<Void> actual =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getOwningEntity(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
-
- final ResponseEntity<OwningEntity> actualResponse =
- testRestTemplateService.invokeHttpGet(url, OwningEntity.class);
-
- assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
- assertTrue(actualResponse.hasBody());
- final OwningEntity actualOwningEntity = actualResponse.getBody();
- assertEquals(OWN_ENTITY_ID_VALUE, actualOwningEntity.getOwningEntityId());
- assertEquals(OWN_ENTITY_NAME_VALUE, actualOwningEntity.getOwningEntityName());
- assertNotNull(actualOwningEntity.getResourceVersion());
-
- }
-
- @Test
- public void test_getOwningEntityCount_correctResult() throws Exception {
- final String url = getUrl(TestConstants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
- final ResponseEntity<Void> actual =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getOwningEntity(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
-
- final ResponseEntity<Results> actualResponse = testRestTemplateService
- .invokeHttpGet(url + "?resultIndex=0&resultSize=1&format=" + Format.COUNT.getValue(), Results.class);
-
- assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
- assertTrue(actualResponse.hasBody());
- final Results result = actualResponse.getBody();
- assertNotNull(result.getValues());
- assertFalse(result.getValues().isEmpty());
- assertEquals(1, result.getValues().get(0).get(Constants.OWNING_ENTITY));
- }
-
- @Test
- public void test_putOwningEntityRelationShip_successfullyAddedToCache() throws Exception {
- addCustomerAndServiceInstance();
-
- final String url = getUrl(TestConstants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
- final ResponseEntity<Void> actual =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getOwningEntity(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
-
- final String owningEntityRelationshipUrl = url + RELATIONSHIP_LIST_RELATIONSHIP_URL;
-
- final ResponseEntity<Void> putResponse = testRestTemplateService.invokeHttpPut(owningEntityRelationshipUrl,
- TestUtils.getOwningEntityRelationship(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, putResponse.getStatusCode());
-
- final ResponseEntity<OwningEntity> actualResponse =
- testRestTemplateService.invokeHttpGet(url, OwningEntity.class);
-
- assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
- assertTrue(actualResponse.hasBody());
- final OwningEntity actualOwningEntity = actualResponse.getBody();
- assertEquals(OWN_ENTITY_ID_VALUE, actualOwningEntity.getOwningEntityId());
- assertEquals(OWN_ENTITY_NAME_VALUE, actualOwningEntity.getOwningEntityName());
- assertNotNull(actualOwningEntity.getRelationshipList());
- assertFalse(actualOwningEntity.getRelationshipList().getRelationship().isEmpty());
- assertNotNull(actualOwningEntity.getRelationshipList().getRelationship().get(0));
-
- final Relationship actualRelationship = actualOwningEntity.getRelationshipList().getRelationship().get(0);
- final List<RelationshipData> relationshipDataList = actualRelationship.getRelationshipData();
- assertEquals(Constants.BELONGS_TO, actualRelationship.getRelationshipLabel());
- assertFalse(relationshipDataList.isEmpty());
- assertEquals(3, relationshipDataList.size());
-
- final RelationshipData globalRelationshipData =
- getRelationshipData(relationshipDataList, Constants.CUSTOMER_GLOBAL_CUSTOMER_ID);
- assertNotNull(globalRelationshipData);
- assertEquals(GLOBAL_CUSTOMER_ID, globalRelationshipData.getRelationshipValue());
-
- final RelationshipData serviceSubscriptionRelationshipData =
- getRelationshipData(relationshipDataList, Constants.SERVICE_SUBSCRIPTION_SERVICE_TYPE);
- assertNotNull(serviceSubscriptionRelationshipData);
- assertEquals(SERVICE_TYPE, serviceSubscriptionRelationshipData.getRelationshipValue());
-
- final RelationshipData serviceInstanceRelationshipData =
- getRelationshipData(relationshipDataList, Constants.SERVICE_INSTANCE_SERVICE_INSTANCE_ID);
- assertNotNull(serviceInstanceRelationshipData);
- assertEquals(SERVICE_INSTANCE_ID, serviceInstanceRelationshipData.getRelationshipValue());
-
- final Optional<ServiceInstance> optional =
- customerCacheServiceProvider.getServiceInstance(GLOBAL_CUSTOMER_ID, SERVICE_TYPE, SERVICE_INSTANCE_ID);
- assertTrue(optional.isPresent());
-
- final ServiceInstance serviceInstance = optional.get();
-
- assertNotNull(serviceInstance.getRelationshipList());
- final List<Relationship> serviceRelationshipList = serviceInstance.getRelationshipList().getRelationship();
- assertFalse(serviceRelationshipList.isEmpty());
- assertEquals(1, serviceRelationshipList.size());
- final Relationship relationship = serviceRelationshipList.get(0);
- assertEquals(Constants.BELONGS_TO, relationship.getRelationshipLabel());
- assertEquals(TestConstants.OWNING_ENTITY_URL + OWN_ENTITY_ID_VALUE, relationship.getRelatedLink());
-
- final List<RelationshipData> serviceRelationshipDataList = serviceRelationshipList.get(0).getRelationshipData();
- assertFalse(serviceRelationshipDataList.isEmpty());
- assertEquals(1, serviceRelationshipDataList.size());
-
- final RelationshipData owningEntityRelationshipData =
- getRelationshipData(serviceRelationshipDataList, Constants.OWNING_ENTITY_OWNING_ENTITY_ID);
- assertNotNull(owningEntityRelationshipData);
- assertEquals(OWN_ENTITY_ID_VALUE, owningEntityRelationshipData.getRelationshipValue());
-
- }
-
- private void addCustomerAndServiceInstance() throws Exception, IOException {
- final ResponseEntity<Void> customerResponse =
- testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, customerResponse.getStatusCode());
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> serviceInstanceResponse =
- testRestTemplateService.invokeHttpPut(serviceInstanceUrl, TestUtils.getServiceInstance(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
-
- }
-
-}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
deleted file mode 100755
index 5478ef7c..00000000
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*-
- * ============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.aaisimulator.controller;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onap.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
-import static org.onap.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_ID;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
-import static org.onap.aaisimulator.utils.TestConstants.SERVICE_TYPE;
-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.Project;
-import org.onap.aai.domain.yang.Relationship;
-import org.onap.aai.domain.yang.RelationshipData;
-import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aaisimulator.models.Results;
-import org.onap.aaisimulator.service.providers.CustomerCacheServiceProvider;
-import org.onap.aaisimulator.service.providers.ProjectCacheServiceProvider;
-import org.onap.aaisimulator.utils.Constants;
-import org.onap.aaisimulator.utils.TestConstants;
-import org.onap.aaisimulator.utils.TestRestTemplateService;
-import org.onap.aaisimulator.utils.TestUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-/**
- * @author waqas.ikram@ericsson.com
- *
- */
-public class ProjectControllerTest extends AbstractSpringBootTest {
-
- private static final String PROJECT_NAME_VALUE = "PROJECT_NAME_VALUE";
-
- @LocalServerPort
- private int port;
-
- @Autowired
- private TestRestTemplateService testRestTemplateService;
-
- @Autowired
- private ProjectCacheServiceProvider cacheServiceProvider;
-
- @Autowired
- private CustomerCacheServiceProvider customerCacheServiceProvider;
-
- @After
- public void after() {
- cacheServiceProvider.clearAll();
- customerCacheServiceProvider.clearAll();
- }
-
- @Test
- public void test_putProject_successfullyAddedToCache() throws Exception {
- final String url = getUrl(TestConstants.PROJECT_URL, PROJECT_NAME_VALUE);
- final ResponseEntity<Void> actual =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getBusinessProject(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
-
- final ResponseEntity<Project> actualResponse = testRestTemplateService.invokeHttpGet(url, Project.class);
-
- assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
- assertTrue(actualResponse.hasBody());
- final Project actualProject = actualResponse.getBody();
- assertEquals(PROJECT_NAME_VALUE, actualProject.getProjectName());
- assertNotNull(actualProject.getResourceVersion());
-
- }
-
- @Test
- public void test_putProjectRelationShip_successfullyAddedToCache() throws Exception {
- addCustomerAndServiceInstance();
-
- final String url = getUrl(TestConstants.PROJECT_URL, PROJECT_NAME_VALUE);
- final ResponseEntity<Void> actual =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getBusinessProject(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
-
- final String projectRelationshipUrl =
- getUrl(TestConstants.PROJECT_URL, PROJECT_NAME_VALUE, RELATIONSHIP_LIST_RELATIONSHIP_URL);
-
- final ResponseEntity<Void> putResponse = testRestTemplateService.invokeHttpPut(projectRelationshipUrl,
- TestUtils.getBusinessProjectRelationship(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, putResponse.getStatusCode());
-
- final ResponseEntity<Project> actualResponse = testRestTemplateService.invokeHttpGet(url, Project.class);
-
- assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
- assertTrue(actualResponse.hasBody());
- final Project actualProject = actualResponse.getBody();
- assertEquals(PROJECT_NAME_VALUE, actualProject.getProjectName());
- assertNotNull(actualProject.getRelationshipList());
- assertFalse(actualProject.getRelationshipList().getRelationship().isEmpty());
- assertNotNull(actualProject.getRelationshipList().getRelationship().get(0));
-
- final Relationship actualRelationship = actualProject.getRelationshipList().getRelationship().get(0);
- final List<RelationshipData> relationshipDataList = actualRelationship.getRelationshipData();
- assertEquals(Constants.USES, actualRelationship.getRelationshipLabel());
-
- assertFalse(relationshipDataList.isEmpty());
- assertEquals(3, relationshipDataList.size());
-
- final RelationshipData globalRelationshipData =
- getRelationshipData(relationshipDataList, Constants.CUSTOMER_GLOBAL_CUSTOMER_ID);
- assertNotNull(globalRelationshipData);
- assertEquals(GLOBAL_CUSTOMER_ID, globalRelationshipData.getRelationshipValue());
-
- final RelationshipData serviceSubscriptionRelationshipData =
- getRelationshipData(relationshipDataList, Constants.SERVICE_SUBSCRIPTION_SERVICE_TYPE);
- assertNotNull(serviceSubscriptionRelationshipData);
- assertEquals(SERVICE_TYPE, serviceSubscriptionRelationshipData.getRelationshipValue());
-
- final RelationshipData serviceInstanceRelationshipData =
- getRelationshipData(relationshipDataList, Constants.SERVICE_INSTANCE_SERVICE_INSTANCE_ID);
- assertNotNull(serviceInstanceRelationshipData);
- assertEquals(SERVICE_INSTANCE_ID, serviceInstanceRelationshipData.getRelationshipValue());
-
- final Optional<ServiceInstance> optional =
- customerCacheServiceProvider.getServiceInstance(GLOBAL_CUSTOMER_ID, SERVICE_TYPE, SERVICE_INSTANCE_ID);
- assertTrue(optional.isPresent());
-
- final ServiceInstance serviceInstance = optional.get();
-
- assertNotNull(serviceInstance.getRelationshipList());
- final List<Relationship> serviceRelationshipList = serviceInstance.getRelationshipList().getRelationship();
- assertFalse(serviceRelationshipList.isEmpty());
- assertEquals(1, serviceRelationshipList.size());
- final Relationship relationship = serviceRelationshipList.get(0);
- assertEquals(Constants.USES, relationship.getRelationshipLabel());
- assertEquals(TestConstants.PROJECT_URL + PROJECT_NAME_VALUE, relationship.getRelatedLink());
-
-
- final List<RelationshipData> serviceRelationshipDataList = serviceRelationshipList.get(0).getRelationshipData();
- assertFalse(serviceRelationshipDataList.isEmpty());
- assertEquals(1, serviceRelationshipDataList.size());
-
- final RelationshipData projectRelationshipData =
- getRelationshipData(serviceRelationshipDataList, Constants.PROJECT_PROJECT_NAME);
- assertNotNull(projectRelationshipData);
- assertEquals(PROJECT_NAME_VALUE, projectRelationshipData.getRelationshipValue());
-
- }
-
- @Test
- public void test_getProjectCount_correctResult() throws Exception {
- final String url = getUrl(TestConstants.PROJECT_URL, PROJECT_NAME_VALUE);
- final ResponseEntity<Void> actual =
- testRestTemplateService.invokeHttpPut(url, TestUtils.getBusinessProject(), Void.class);
-
- assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
-
- final ResponseEntity<Results> actualResponse =
- testRestTemplateService.invokeHttpGet(url + "?resultIndex=0&resultSize=1&format=count", Results.class);
-
- assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
- assertTrue(actualResponse.hasBody());
- final Results result = actualResponse.getBody();
- assertNotNull(result.getValues());
- assertFalse(result.getValues().isEmpty());
- assertEquals(1, result.getValues().get(0).get(Constants.PROJECT));
- }
-
-
- private void addCustomerAndServiceInstance() throws Exception, IOException {
- final ResponseEntity<Void> customerResponse =
- testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, customerResponse.getStatusCode());
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> serviceInstanceResponse =
- testRestTemplateService.invokeHttpPut(serviceInstanceUrl, TestUtils.getServiceInstance(), Void.class);
- assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
-
- }
-
-}
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/resources/test-data/service-instance-aai.json b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/resources/test-data/service-instance-aai.json
new file mode 100644
index 00000000..8ea4263b
--- /dev/null
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/sorch/simulator/aai-simulator/src/test/resources/test-data/service-instance-aai.json
@@ -0,0 +1,45 @@
+{
+ "service-instance-id": "5df8b6de-2083-11e7-93ae-92361f002676",
+ "service-instance-name": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-version-id": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "resource-version": "1595258335377",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/5df8b6de-2083-11e7-93ae-92361f002676/service-data/service-topology/",
+ "orchestration-status": "Assigned",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "67f2e84c-734d-4e90-a1e4-d2ffa2e75849"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "PNFDemo"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo1",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "PNFDemo1"
+ }
+ ]
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/teardown.sh b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/teardown.sh
index a9d9bdd5..7257b366 100755
--- a/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/teardown.sh
+++ b/plans/usecases-pnf-sw-upgrade/pnf-sw-upgrade/teardown.sh
@@ -1,10 +1,10 @@
#!/bin/bash
-source $SO_DOCKER_PATH/so_teardown.sh
+echo 'Stop, Removing all running containers...'
+docker stop $(docker ps -aq) && docker rm $(docker ps -aq)
-source $SDNC_DOCKER_PATH/sdn_teardown.sh
+echo 'Removing Volumes...'
+echo y | docker volume prune
-source $CDS_DOCKER_PATH/cds_teardown.sh
-
-PNFSIM_DOCKER_COMPOSE_PATH=$PNF_SIM_DOCKER_PATH/docker-compose.yml
-docker-compose -f $PNFSIM_DOCKER_COMPOSE_PATH -p $PROJECT_NAME down
+echo 'Removing Networks...'
+echo y | docker network prune \ No newline at end of file