aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plans/so/integration-etsi-testing/config/aai-simulator-populate-data/tenant.json4
-rwxr-xr-xplans/so/integration-etsi-testing/config/populate-aai-simulator.sh9
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/BusinessController.java52
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java45
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java86
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java42
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProvider.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java48
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java64
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProvider.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProviderImpl.java7
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java34
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java10
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java6
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/tenant.json4
26 files changed, 319 insertions, 144 deletions
diff --git a/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/tenant.json b/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/tenant.json
new file mode 100644
index 00000000..746131a6
--- /dev/null
+++ b/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/tenant.json
@@ -0,0 +1,4 @@
+{
+ "tenant-id": "693c7729b2364a26a3ca602e6f66187d",
+ "tenant-name": "admin"
+}
diff --git a/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh b/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
index d96301cf..87062ed3 100755
--- a/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
+++ b/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
@@ -57,6 +57,7 @@ populate_aai_simulator()
LINE_OF_BUSINESS_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/line-of-business.json
PLATFORM_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/platform.json
CLOUD_REGION_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/cloud-region.json
+ TENANT_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/tenant.json
STATUS_CODE_ACCEPTED="202"
echo "$SCRIPT_NAME $(current_timestamp): checking health of AAI Simulator"
@@ -119,6 +120,14 @@ populate_aai_simulator()
exit 1
fi
+ echo "$SCRIPT_NAME $(current_timestamp): Adding Tenant"
+ 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/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/EtsiCloudRegion/tenants/tenant/693c7729b2364a26a3ca602e6f66187d -X PUT -d @$"$TENANT_JSON_FILE")
+
+ if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
+ echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put Tenant 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/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/BusinessController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/BusinessController.java
index 22767b29..347743bd 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/BusinessController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/BusinessController.java
@@ -19,28 +19,22 @@
*/
package org.onap.so.aaisimulator.controller;
-import static org.onap.so.aaisimulator.utils.Constants.COMPOSED_OF;
-import static org.onap.so.aaisimulator.utils.Constants.CUSTOMER_GLOBAL_CUSTOMER_ID;
+import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.Constants.CUSTOMER_TYPE;
import static org.onap.so.aaisimulator.utils.Constants.CUSTOMER_URL;
import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF;
import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_ID;
-import static org.onap.so.aaisimulator.utils.Constants.SERVICE_INSTANCE_SERVICE_INSTANCE_ID;
-import static org.onap.so.aaisimulator.utils.Constants.SERVICE_INSTANCE_SERVICE_INSTANCE_NAME;
import static org.onap.so.aaisimulator.utils.Constants.SERVICE_RESOURCE_TYPE;
import static org.onap.so.aaisimulator.utils.Constants.SERVICE_SUBSCRIPTION;
-import static org.onap.so.aaisimulator.utils.Constants.SERVICE_SUBSCRIPTION_SERVICE_TYPE;
import static org.onap.so.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
-import java.util.List;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.Customer;
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.ServiceInstance;
@@ -50,7 +44,6 @@ import org.onap.so.aaisimulator.models.NodeServiceInstance;
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.NodesCacheServiceProvider;
-import org.onap.so.aaisimulator.utils.RequestErrorResponseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -302,9 +295,9 @@ public class BusinessController {
return getRequestErrorResponseEntity(request, GENERIC_VNF);
}
-
@PutMapping(
- value = "/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}/relationship-list/relationship",
+ 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(
@@ -316,25 +309,12 @@ public class BusinessController {
LOGGER.info(
"Will add {} relationship for 'global customer id': {}, 'service type': {} and 'service instance id: '{} ...",
relationship.getRelatedTo(), globalCustomerId, serviceType, serviceInstanceId);
- final Optional<ServiceInstance> optional =
- cacheServiceProvider.addRelationShip(globalCustomerId, serviceType, serviceInstanceId, relationship);
+ final Optional<Relationship> optional = cacheServiceProvider.addRelationShip(globalCustomerId, serviceType,
+ serviceInstanceId, relationship, request.getRequestURI());
if (optional.isPresent()) {
- final ServiceInstance serviceInstance = optional.get();
- final Relationship resultantRelationship = new Relationship();
- resultantRelationship.setRelatedTo(GENERIC_VNF);
- resultantRelationship.setRelationshipLabel(COMPOSED_OF);
- resultantRelationship.setRelatedLink(request.getRequestURI());
-
- final List<RelationshipData> relationshipDataList = resultantRelationship.getRelationshipData();
- relationshipDataList.add(getRelationshipData(CUSTOMER_GLOBAL_CUSTOMER_ID, globalCustomerId));
- relationshipDataList.add(getRelationshipData(SERVICE_SUBSCRIPTION_SERVICE_TYPE, serviceType));
- relationshipDataList.add(getRelationshipData(SERVICE_INSTANCE_SERVICE_INSTANCE_ID, serviceInstanceId));
-
- final List<RelatedToProperty> relatedToProperty = resultantRelationship.getRelatedToProperty();
- relatedToProperty.add(getRelatedToProperty(SERVICE_INSTANCE_SERVICE_INSTANCE_NAME,
- serviceInstance.getServiceInstanceName()));
-
+ final Relationship resultantRelationship = optional.get();
+ LOGGER.info("Relationship add, sending resultant relationship: {} in response ...", resultantRelationship);
return ResponseEntity.accepted().body(resultantRelationship);
}
@@ -342,22 +322,6 @@ public class BusinessController {
"Couldn't add {} relationship for 'global customer id': {}, 'service type': {} and 'service instance id: '{} ...",
relationship.getRelatedTo(), globalCustomerId, serviceType, serviceInstanceId);
- return RequestErrorResponseUtils.getRequestErrorResponseEntity(request);
- }
-
- private RelatedToProperty getRelatedToProperty(final String key, final String value) {
- final RelatedToProperty relatedToProperty = new RelatedToProperty();
- relatedToProperty.setPropertyKey(key);
- relatedToProperty.setPropertyValue(value);
- return relatedToProperty;
- }
-
- private RelationshipData getRelationshipData(final String key, final String value) {
- final RelationshipData relationshipData = new RelationshipData();
- relationshipData.setRelationshipKey(key);
- relationshipData.setRelationshipValue(value);
- return relationshipData;
+ return getRequestErrorResponseEntity(request);
}
-
-
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java
index 2b45499a..23633158 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java
@@ -21,6 +21,7 @@ package org.onap.so.aaisimulator.controller;
import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGION;
import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGIONS;
+import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
import java.util.Optional;
@@ -28,6 +29,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.Tenant;
import org.onap.so.aaisimulator.models.CloudRegionKey;
import org.onap.so.aaisimulator.service.providers.CloudRegionCacheServiceProvider;
import org.slf4j.Logger;
@@ -99,7 +101,7 @@ public class CloudRegionsController {
return getRequestErrorResponseEntity(request, CLOUD_REGION);
}
- @PutMapping(value = "{cloud-owner}/{cloud-region-id}/relationship-list/relationship",
+ @PutMapping(value = "{cloud-owner}/{cloud-region-id}" + BI_DIRECTIONAL_RELATIONSHIP_LIST_URL,
consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putRelationShip(@PathVariable("cloud-owner") final String cloudOwner,
@@ -124,5 +126,46 @@ public class CloudRegionsController {
}
+ @PutMapping(value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putTenant(@RequestBody final Tenant tenant,
+ @PathVariable("cloud-owner") final String cloudOwner,
+ @PathVariable("cloud-region-id") final String cloudRegionId,
+ @PathVariable("tenant-id") final String tenantId, final HttpServletRequest request) {
+
+ final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+ if (key.isValid()) {
+ LOGGER.info("Will add Tenant to cache with key 'key': {} ....", key);
+ if (tenant.getResourceVersion() == null || tenant.getResourceVersion().isEmpty()) {
+ tenant.setResourceVersion(getResourceVersion());
+ }
+ if (cacheServiceProvider.putTenant(key, tenant)) {
+ return ResponseEntity.accepted().build();
+ }
+ }
+
+ LOGGER.error("Unable to add Tenant in cache using key {}", key);
+ return getRequestErrorResponseEntity(request, CLOUD_REGION);
+ }
+
+ @GetMapping(value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getTenant(@PathVariable("cloud-owner") final String cloudOwner,
+ @PathVariable("cloud-region-id") final String cloudRegionId,
+ @PathVariable("tenant-id") final String tenantId, final HttpServletRequest request) {
+ final CloudRegionKey key = new CloudRegionKey(cloudOwner, cloudRegionId);
+ LOGGER.info("Retrieving Tenant using key : {} and tenant-id:{} ...", key, tenantId);
+ if (key.isValid()) {
+ final Optional<Tenant> optional = cacheServiceProvider.getTenant(key, tenantId);
+ if (optional.isPresent()) {
+ final Tenant tenant = optional.get();
+ LOGGER.info("found Tenant {} in cache", tenant);
+ return ResponseEntity.ok(tenant);
+ }
+ }
+ LOGGER.error("Unable to find Tenant in cache key : {} and tenant-id:{} ...", key, tenantId);
+ return getRequestErrorResponseEntity(request, CLOUD_REGION);
+ }
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java
index 2eb84f05..1e8c0cc0 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java
@@ -19,13 +19,8 @@
*/
package org.onap.so.aaisimulator.controller;
-import static org.onap.so.aaisimulator.utils.Constants.COMPOSED_OF;
import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF;
import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNFS_URL;
-import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_ID;
-import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_NAME;
-import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
-import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBaseUrl;
import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getHeaders;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
@@ -33,15 +28,14 @@ import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
-import org.onap.aai.domain.yang.RelationshipData;
import org.onap.so.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
-import org.onap.so.aaisimulator.service.providers.HttpRestServiceProvider;
+import org.onap.so.aaisimulator.utils.HttpServiceUtils;
import org.onap.so.aaisimulator.utils.RequestErrorResponseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@@ -50,7 +44,6 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.util.UriComponentsBuilder;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -64,13 +57,10 @@ public class GenericVnfsController {
private final GenericVnfCacheServiceProvider cacheServiceProvider;
- private final HttpRestServiceProvider httpRestServiceProvider;
@Autowired
- public GenericVnfsController(final GenericVnfCacheServiceProvider cacheServiceProvider,
- final HttpRestServiceProvider httpRestServiceProvider) {
+ public GenericVnfsController(final GenericVnfCacheServiceProvider cacheServiceProvider) {
this.cacheServiceProvider = cacheServiceProvider;
- this.httpRestServiceProvider = httpRestServiceProvider;
}
@PutMapping(value = "/generic-vnf/{vnf-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
@@ -90,8 +80,13 @@ public class GenericVnfsController {
@GetMapping(value = "/generic-vnf/{vnf-id}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getGenericVnf(@PathVariable("vnf-id") final String vnfId,
- @RequestParam(name = "depth", required = false) final Integer depth, final HttpServletRequest request) {
- LOGGER.info("Will get GenericVnf for 'vnf-id': {} with depth: {}...", vnfId, depth);
+ @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 get GenericVnf for 'vnf-id': {} with depth: {}, resultIndex: {}, resultSize:{}, format:{} ...",
+ vnfId, depth, resultIndex, resultSize, format);
final Optional<GenericVnf> optional = cacheServiceProvider.getGenericVnf(vnfId);
@@ -101,7 +96,9 @@ public class GenericVnfsController {
return ResponseEntity.ok(genericVnf);
}
- LOGGER.error("Unable to find GenericVnf in cache for 'vnf-id': {} with depth: {} ...", vnfId, depth);
+ LOGGER.error(
+ "Unable to find GenericVnf in cache for 'vnf-id': {} with depth: {}, resultIndex: {}, resultSize:{}, format:{} ...",
+ vnfId, depth, resultIndex, resultSize, format);
return getRequestErrorResponseEntity(request, GENERIC_VNF);
}
@@ -113,59 +110,18 @@ public class GenericVnfsController {
@PathVariable("vnf-id") final String vnfId, final HttpServletRequest request) {
LOGGER.info("Will put RelationShip for 'vnf-id': {} ...", vnfId);
- try {
- if (relationship.getRelatedLink() != null) {
- final Optional<GenericVnf> optional = cacheServiceProvider.getGenericVnf(vnfId);
-
- if (optional.isPresent()) {
- final GenericVnf genericVnf = optional.get();
- final String url = getRelationShipUrl(request, relationship.getRelatedLink());
-
- final Relationship serviceRelationship = getRelationship(request.getRequestURI(), genericVnf);
- final Optional<Relationship> optionalRelationship = httpRestServiceProvider.put(getHeaders(request),
- serviceRelationship, url, Relationship.class);
-
- if (optionalRelationship.isPresent()) {
- final Relationship resultantRelationship = optionalRelationship.get();
- final boolean result = cacheServiceProvider.addRelationShip(vnfId, resultantRelationship);
- if (result) {
- LOGGER.info("added relationship {} in cache successfully", relationship);
- return ResponseEntity.accepted().build();
- }
- LOGGER.error("Unable to add relationship {} in cache", relationship);
- }
- }
+ if (relationship.getRelatedLink() != null) {
+ final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
+ final HttpHeaders incomingHeader = getHeaders(request);
+ boolean result = cacheServiceProvider.addRelationShip(incomingHeader, targetBaseUrl,
+ request.getRequestURI(), vnfId, relationship);
+ if (result) {
+ LOGGER.info("added created bi directional relationship with {}", relationship.getRelatedLink());
+ return ResponseEntity.accepted().build();
}
- } catch (final Exception exception) {
- LOGGER.error("Unable to add two-way relationship ", exception);
}
-
LOGGER.error("Unable to add relationship for related link: {}", relationship.getRelatedLink());
return RequestErrorResponseUtils.getRequestErrorResponseEntity(request, GENERIC_VNF);
-
- }
-
- private Relationship getRelationship(final String relatedLink, final GenericVnf genericVnf) {
- final Relationship relationShip = new Relationship();
- relationShip.setRelatedTo(GENERIC_VNF);
- relationShip.setRelationshipLabel(COMPOSED_OF);
- relationShip.setRelatedLink(relatedLink);
-
- final RelationshipData relationshipData = new RelationshipData();
- relationshipData.setRelationshipKey(GENERIC_VNF_VNF_ID);
- relationshipData.setRelationshipValue(genericVnf.getVnfId());
- relationShip.getRelationshipData().add(relationshipData);
-
- final RelatedToProperty relatedToProperty = new RelatedToProperty();
- relatedToProperty.setPropertyKey(GENERIC_VNF_VNF_NAME);
- relatedToProperty.setPropertyValue(genericVnf.getVnfName());
- relationShip.getRelatedToProperty().add(relatedToProperty);
- return relationShip;
- }
-
- private String getRelationShipUrl(final HttpServletRequest request, final String relatedLink) {
- return UriComponentsBuilder.fromUri(getBaseUrl(request)).path(relatedLink)
- .path(RELATIONSHIP_LIST_RELATIONSHIP_URL).toUriString();
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java
index ac1ad8c5..c6fc6c7b 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/LinesOfBusinessController.java
@@ -21,6 +21,7 @@ package org.onap.so.aaisimulator.controller;
import static org.onap.so.aaisimulator.utils.Constants.LINES_OF_BUSINESS_URL;
import static org.onap.so.aaisimulator.utils.Constants.LINE_OF_BUSINESS;
+import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
import java.util.Optional;
@@ -87,7 +88,7 @@ public class LinesOfBusinessController {
return getRequestErrorResponseEntity(request, LINE_OF_BUSINESS);
}
- @PutMapping(value = "/{line-of-business-name}/relationship-list/relationship",
+ @PutMapping(value = "/{line-of-business-name}" + BI_DIRECTIONAL_RELATIONSHIP_LIST_URL,
consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putRelationShip(@PathVariable("line-of-business-name") final String lineOfBusinessName,
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
index d0019727..8d68469d 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
@@ -21,6 +21,7 @@ package org.onap.so.aaisimulator.controller;
import static org.onap.so.aaisimulator.utils.Constants.PLATFORM;
import static org.onap.so.aaisimulator.utils.Constants.PLATFORMS_URL;
+import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
import java.util.Optional;
@@ -84,7 +85,7 @@ public class PlatformController {
return getRequestErrorResponseEntity(request, PLATFORM);
}
- @PutMapping(value = "/{platform-name}/relationship-list/relationship",
+ @PutMapping(value = "/{platform-name}" + BI_DIRECTIONAL_RELATIONSHIP_LIST_URL,
consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putRelationShip(@PathVariable("platform-name") final String platformName,
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java
index a10a8ac4..ebaf7ce3 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProvider.java
@@ -22,6 +22,7 @@ package org.onap.so.aaisimulator.service.providers;
import java.util.Optional;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.Tenant;
import org.onap.so.aaisimulator.models.CloudRegionKey;
/**
@@ -36,4 +37,8 @@ public interface CloudRegionCacheServiceProvider extends Clearable {
Optional<Relationship> addRelationShip(final CloudRegionKey key, final Relationship relationship,
final String requestUri);
+
+ boolean putTenant(final CloudRegionKey key, Tenant tenant);
+
+ Optional<Tenant> getTenant(final CloudRegionKey key, final String tenantId);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java
index 41422c40..ebefd056 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java
@@ -32,6 +32,8 @@ import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
+import org.onap.aai.domain.yang.Tenant;
+import org.onap.aai.domain.yang.Tenants;
import org.onap.so.aaisimulator.models.CloudRegionKey;
import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
@@ -116,6 +118,46 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
return Optional.empty();
}
+ @Override
+ public boolean putTenant(final CloudRegionKey key, final Tenant tenant) {
+ final Optional<CloudRegion> optional = getCloudRegion(key);
+ if (optional.isPresent()) {
+ final CloudRegion cloudRegion = optional.get();
+ Tenants tenants = cloudRegion.getTenants();
+ if (tenants == null) {
+ tenants = new Tenants();
+ cloudRegion.setTenants(tenants);
+ }
+
+ final Optional<Tenant> existingTenantOptional = tenants.getTenant().stream()
+ .filter(existing -> existing.getTenantId().equals(tenant.getTenantId())).findFirst();
+
+ if (!existingTenantOptional.isPresent()) {
+ return tenants.getTenant().add(tenant);
+ }
+ LOGGER.warn("Tenant already exists ...");
+ return false;
+ }
+ LOGGER.error("Unable to add Tenant using key: {} ...", key);
+ return false;
+ }
+
+ @Override
+ public Optional<Tenant> getTenant(final CloudRegionKey key, final String tenantId) {
+ final Optional<CloudRegion> optional = getCloudRegion(key);
+ if (optional.isPresent()) {
+ final CloudRegion cloudRegion = optional.get();
+ final Tenants tenants = cloudRegion.getTenants();
+ if (tenants != null) {
+ return tenants.getTenant().stream().filter(existing -> existing.getTenantId().equals(tenantId))
+ .findFirst();
+ }
+ }
+
+ LOGGER.error("Unable to find Tenant using key: {} and tenantId: {} ...", key, tenantId);
+ return Optional.empty();
+ }
+
private RelationshipData getRelationshipData(final String key, final String value) {
final RelationshipData relationshipData = new RelationshipData();
relationshipData.setRelationshipKey(key);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProvider.java
index bf30013a..268a6bc3 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProvider.java
@@ -56,7 +56,7 @@ public interface CustomerCacheServiceProvider extends Clearable {
Optional<Relationship> getRelationship(final String globalCustomerId, final String serviceType,
final String serviceInstanceId, final String vnfName);
- Optional<ServiceInstance> addRelationShip(final String globalCustomerId, final String serviceType,
- final String serviceInstanceId, final Relationship relationship);
+ Optional<Relationship> addRelationShip(final String globalCustomerId, final String serviceType,
+ final String serviceInstanceId, final Relationship relationship, final String requestUri);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java
index 695bfc0f..16b34be1 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java
@@ -20,12 +20,20 @@
package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.CUSTOMER_CACHE;
+import static org.onap.so.aaisimulator.utils.Constants.COMPOSED_OF;
+import static org.onap.so.aaisimulator.utils.Constants.CUSTOMER_GLOBAL_CUSTOMER_ID;
+import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF;
import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_NAME;
+import static org.onap.so.aaisimulator.utils.Constants.SERVICE_INSTANCE_SERVICE_INSTANCE_ID;
+import static org.onap.so.aaisimulator.utils.Constants.SERVICE_INSTANCE_SERVICE_INSTANCE_NAME;
+import static org.onap.so.aaisimulator.utils.Constants.SERVICE_SUBSCRIPTION_SERVICE_TYPE;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.onap.aai.domain.yang.Customer;
+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.aai.domain.yang.ServiceInstances;
@@ -259,8 +267,8 @@ public class CustomerCacheServiceProviderImpl extends AbstractCacheServiceProvid
}
@Override
- public Optional<ServiceInstance> addRelationShip(final String globalCustomerId, final String serviceType,
- final String serviceInstanceId, final Relationship relationship) {
+ public Optional<Relationship> addRelationShip(final String globalCustomerId, final String serviceType,
+ final String serviceInstanceId, final Relationship relationship, final String requestUri) {
final Optional<ServiceInstance> optional = getServiceInstance(globalCustomerId, serviceType, serviceInstanceId);
if (optional.isPresent()) {
final ServiceInstance serviceInstance = optional.get();
@@ -270,12 +278,28 @@ public class CustomerCacheServiceProviderImpl extends AbstractCacheServiceProvid
serviceInstance.setRelationshipList(relationshipList);
}
relationshipList.getRelationship().add(relationship);
- return Optional.of(serviceInstance);
+
+ LOGGER.info("Successfully added relation to ServiceInstance");
+
+ final Relationship resultantRelationship = new Relationship();
+ resultantRelationship.setRelatedTo(GENERIC_VNF);
+ resultantRelationship.setRelationshipLabel(COMPOSED_OF);
+ resultantRelationship.setRelatedLink(requestUri);
+
+ final List<RelationshipData> relationshipDataList = resultantRelationship.getRelationshipData();
+ relationshipDataList.add(getRelationshipData(CUSTOMER_GLOBAL_CUSTOMER_ID, globalCustomerId));
+ relationshipDataList.add(getRelationshipData(SERVICE_SUBSCRIPTION_SERVICE_TYPE, serviceType));
+ relationshipDataList.add(getRelationshipData(SERVICE_INSTANCE_SERVICE_INSTANCE_ID, serviceInstanceId));
+
+ final List<RelatedToProperty> relatedToProperty = resultantRelationship.getRelatedToProperty();
+ relatedToProperty.add(getRelatedToProperty(SERVICE_INSTANCE_SERVICE_INSTANCE_NAME,
+ serviceInstance.getServiceInstanceName()));
+
+ return Optional.of(resultantRelationship);
}
LOGGER.error("Unable to find ServiceInstance ...");
return Optional.empty();
-
}
@Override
@@ -283,4 +307,20 @@ public class CustomerCacheServiceProviderImpl extends AbstractCacheServiceProvid
clearCahce(CUSTOMER_CACHE.getName());
}
+ private RelatedToProperty getRelatedToProperty(final String key, final String value) {
+ final RelatedToProperty relatedToProperty = new RelatedToProperty();
+ relatedToProperty.setPropertyKey(key);
+ relatedToProperty.setPropertyValue(value);
+ return relatedToProperty;
+ }
+
+ private RelationshipData getRelationshipData(final String key, final String value) {
+ final RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey(key);
+ relationshipData.setRelationshipValue(value);
+ return relationshipData;
+ }
+
+
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java
index 213ecf69..093cfa12 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java
@@ -22,6 +22,7 @@ package org.onap.so.aaisimulator.service.providers;
import java.util.Optional;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Relationship;
+import org.springframework.http.HttpHeaders;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -35,6 +36,9 @@ public interface GenericVnfCacheServiceProvider extends Clearable {
boolean addRelationShip(final String vnfId, final Relationship relationship);
+ boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl, final String requestUriString,
+ final String vnfId, final Relationship relationship);
+
Optional<String> getGenericVnfId(final String vnfName);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java
index 7ff012f6..472ca172 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java
@@ -20,10 +20,17 @@
package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.GENERIC_VNF_CACHE;
+import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
+import static org.onap.so.aaisimulator.utils.Constants.COMPOSED_OF;
+import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF;
+import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_ID;
+import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_NAME;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
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.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
@@ -31,7 +38,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
+import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
+import org.springframework.web.util.UriComponentsBuilder;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -43,9 +52,13 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
private static final Logger LOGGER = LoggerFactory.getLogger(GenericVnfCacheServiceProviderImpl.class);
+ private final HttpRestServiceProvider httpRestServiceProvider;
+
@Autowired
- public GenericVnfCacheServiceProviderImpl(final CacheManager cacheManager) {
+ public GenericVnfCacheServiceProviderImpl(final CacheManager cacheManager,
+ final HttpRestServiceProvider httpRestServiceProvider) {
super(cacheManager);
+ this.httpRestServiceProvider = httpRestServiceProvider;
}
@Override
@@ -108,6 +121,55 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
}
@Override
+ public boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl,
+ final String requestUriString, final String vnfId, final Relationship relationship) {
+ try {
+ final Optional<GenericVnf> optional = getGenericVnf(vnfId);
+ if (optional.isPresent()) {
+ final GenericVnf genericVnf = optional.get();
+ final String targetUrl = getTargetUrl(targetBaseUrl, relationship.getRelatedLink());
+ final Relationship outGoingRelationShip = getRelationship(requestUriString, genericVnf);
+ final Optional<Relationship> optionalRelationship = httpRestServiceProvider.put(incomingHeader,
+ outGoingRelationShip, targetUrl, Relationship.class);
+ if (optionalRelationship.isPresent()) {
+ final Relationship resultantRelationship = optionalRelationship.get();
+ if (addRelationShip(vnfId, resultantRelationship)) {
+ LOGGER.info("added relationship {} in cache successfully", resultantRelationship);
+ return true;
+ }
+ }
+ }
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to add two-way relationship for vnfId: {}", vnfId, exception);
+ }
+ LOGGER.error("Unable to add relationship in cache for vnfId: {}", vnfId);
+ return false;
+ }
+
+ private String getTargetUrl(final String targetBaseUrl, final String relatedLink) {
+ return UriComponentsBuilder.fromUriString(targetBaseUrl).path(relatedLink)
+ .path(BI_DIRECTIONAL_RELATIONSHIP_LIST_URL).toUriString();
+ }
+
+ private Relationship getRelationship(final String relatedLink, final GenericVnf genericVnf) {
+ final Relationship relationShip = new Relationship();
+ relationShip.setRelatedTo(GENERIC_VNF);
+ relationShip.setRelationshipLabel(COMPOSED_OF);
+ relationShip.setRelatedLink(relatedLink);
+
+ final RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey(GENERIC_VNF_VNF_ID);
+ relationshipData.setRelationshipValue(genericVnf.getVnfId());
+ relationShip.getRelationshipData().add(relationshipData);
+
+ final RelatedToProperty relatedToProperty = new RelatedToProperty();
+ relatedToProperty.setPropertyKey(GENERIC_VNF_VNF_NAME);
+ relatedToProperty.setPropertyValue(genericVnf.getVnfName());
+ relationShip.getRelatedToProperty().add(relatedToProperty);
+ return relationShip;
+ }
+
+ @Override
public void clearAll() {
clearCahce(GENERIC_VNF_CACHE.getName());
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProvider.java
index 38d23d78..bbcc435b 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProvider.java
@@ -20,6 +20,7 @@
package org.onap.so.aaisimulator.service.providers;
import java.util.Optional;
+import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
@@ -29,8 +30,7 @@ import org.springframework.http.ResponseEntity;
*/
public interface HttpRestServiceProvider {
- <T> ResponseEntity<T> invokeHttpPut(final HttpHeaders headers, final Object object, final String url,
- final Class<T> clazz);
+ <T> ResponseEntity<T> invokeHttpPut(final HttpEntity<Object> httpEntity, final String url, final Class<T> clazz);
<T> Optional<T> put(final HttpHeaders headers, final Object object, final String url, final Class<T> clazz);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProviderImpl.java
index b9f92c87..b96920f0 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/HttpRestServiceProviderImpl.java
@@ -51,13 +51,13 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider {
}
@Override
- public <T> ResponseEntity<T> invokeHttpPut(final HttpHeaders headers, final Object object, final String url,
+ public <T> ResponseEntity<T> invokeHttpPut(final HttpEntity<Object> httpEntity, final String url,
final Class<T> clazz) {
final HttpMethod httpMethod = HttpMethod.PUT;
LOGGER.trace("Will invoke HTTP {} using URL: {}", httpMethod, url);
try {
- return restTemplate.exchange(url, httpMethod, new HttpEntity<>(object, headers), clazz);
+ return restTemplate.exchange(url, httpMethod, httpEntity, clazz);
} catch (final HttpClientErrorException httpClientErrorException) {
final String message = "Unable to invoke HTTP " + httpMethod + " using url: " + url + ", Response: "
@@ -78,7 +78,8 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider {
@Override
public <T> Optional<T> put(final HttpHeaders headers, final Object object, final String url, final Class<T> clazz) {
- final ResponseEntity<T> response = invokeHttpPut(headers, object, url, clazz);
+ final HttpEntity<Object> httpEntity = new HttpEntity<Object>(object, headers);
+ final ResponseEntity<T> response = invokeHttpPut(httpEntity, url, clazz);
if (!response.getStatusCode().equals(HttpStatus.OK) && !response.getStatusCode().equals(HttpStatus.CREATED)
&& !response.getStatusCode().equals(HttpStatus.ACCEPTED)) {
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
index 979da6b9..231b0c61 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
@@ -49,6 +49,9 @@ public class Constants {
public static final String RELATIONSHIP_LIST_RELATIONSHIP_URL = "/relationship-list/relationship";
+ public static final String BI_DIRECTIONAL_RELATIONSHIP_LIST_URL =
+ RELATIONSHIP_LIST_RELATIONSHIP_URL + "/bi-directional";
+
public static final String LINES_OF_BUSINESS_URL = BUSINESS_URL + "/lines-of-business/line-of-business/";
public static final String HEALTHY = "healthy";
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
index fd3191d6..8c57db58 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
@@ -23,13 +23,13 @@ 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.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
import static org.onap.so.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
import static org.onap.so.aaisimulator.utils.TestConstants.RELATED_TO_URL;
-import static org.onap.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCES_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_ID;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
@@ -336,7 +336,7 @@ public class BusinessControllerTest extends AbstractSpringBootTest {
invokeServiceInstanceEndPointAndAssertResponse();
final String relationShipUrl =
- getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL, RELATIONSHIP_URL);
+ 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);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java
index 2118b6d8..980c7582 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java
@@ -23,9 +23,11 @@ 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.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.CLOUD_OWNER_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.CLOUD_REGION_NAME;
-import static org.onap.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.TENANTS_TENANT;
+import static org.onap.so.aaisimulator.utils.TestConstants.TENANT_ID;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
@@ -35,6 +37,7 @@ import org.onap.aai.domain.yang.CloudRegion;
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.Tenant;
import org.onap.so.aaisimulator.models.CloudRegionKey;
import org.onap.so.aaisimulator.service.providers.CloudRegionCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
@@ -106,8 +109,8 @@ public class CloudRegionsControllerTest extends AbstractSpringBootTest {
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
- final String relationShipUrl =
- getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME, RELATIONSHIP_URL);
+ final String relationShipUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
+ BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
final ResponseEntity<Relationship> responseEntity = testRestTemplateService.invokeHttpPut(relationShipUrl,
TestUtils.getGenericVnfRelationShip(), Relationship.class);
@@ -136,6 +139,31 @@ public class CloudRegionsControllerTest extends AbstractSpringBootTest {
}
+ @Test
+ public void test_putTenant_successfullyAddedToCache() throws Exception {
+ final String cloudRegionUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+
+ invokeCloudRegionHttpPutEndPointAndAssertResponse(cloudRegionUrl);
+
+ final String tenantUrl =
+ getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME + TENANTS_TENANT + TENANT_ID);
+ final ResponseEntity<Void> responseEntity =
+ testRestTemplateService.invokeHttpPut(tenantUrl, TestUtils.getTenant(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
+
+ 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());
+
+ }
+
private void invokeCloudRegionHttpPutEndPointAndAssertResponse(final String url) throws IOException {
final ResponseEntity<Void> responseEntity =
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
index ba5c85e7..4411e3e8 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java
@@ -23,6 +23,7 @@ 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.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.CLOUD_OWNER_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.CLOUD_REGION_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
@@ -31,7 +32,6 @@ import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
import static org.onap.so.aaisimulator.utils.TestConstants.LINE_OF_BUSINESS_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.PLATFORM_NAME;
-import static org.onap.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_ID;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_NAME;
@@ -110,7 +110,7 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
addCustomerServiceAndGenericVnf();
- final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_URL);
+ final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
.invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getRelationShip(), Void.class);
@@ -184,7 +184,7 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
testRestTemplateService.invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
- final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_URL);
+ final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
.invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getPlatformRelatedLink(), Void.class);
@@ -221,7 +221,7 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
- final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_URL);
+ final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
.invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getLineOfBusinessRelatedLink(), Void.class);
@@ -259,7 +259,7 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
testRestTemplateService.invokeHttpPut(url, TestUtils.getCloudRegion(), Void.class);
assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
- final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_URL);
+ final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
final ResponseEntity<Void> genericVnfRelationShipResponse = testRestTemplateService
.invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getCloudRegionRelatedLink(), Void.class);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java
index d0234f6f..daa5138e 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java
@@ -23,8 +23,8 @@ 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.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.LINE_OF_BUSINESS_NAME;
-import static org.onap.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
import java.util.List;
import java.util.Optional;
import org.junit.After;
@@ -83,7 +83,7 @@ public class LinesOfBusinessControllerTest extends AbstractSpringBootTest {
testRestTemplateService.invokeHttpPut(url, TestUtils.getLineOfBusiness(), Void.class);
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
- final String relationShipUrl = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME, RELATIONSHIP_URL);
+ final String relationShipUrl = getUrl(Constants.LINES_OF_BUSINESS_URL, LINE_OF_BUSINESS_NAME, BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
final ResponseEntity<Relationship> responseEntity = testRestTemplateService.invokeHttpPut(relationShipUrl,
TestUtils.getGenericVnfRelationShip(), Relationship.class);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
index f2f43fb0..34ac30ae 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
@@ -23,7 +23,7 @@ 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.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
+import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import org.junit.After;
import org.junit.Test;
import org.onap.aai.domain.yang.OwningEntity;
@@ -99,7 +99,7 @@ public class OwningEntityControllerTest extends AbstractSpringBootTest {
testRestTemplateService.invokeHttpPut(url, TestUtils.getOwningEntity(), Void.class);
assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
- final String owningEntityRelationshipUrl = url + RELATIONSHIP_URL;
+ final String owningEntityRelationshipUrl = url + RELATIONSHIP_LIST_RELATIONSHIP_URL;
final ResponseEntity<Void> putResponse = testRestTemplateService.invokeHttpPut(owningEntityRelationshipUrl,
TestUtils.getOwningEntityRelationship(), Void.class);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
index 2769b6a0..754c7ebe 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
@@ -23,8 +23,8 @@ 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.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.PLATFORM_NAME;
-import static org.onap.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
import java.util.List;
import java.util.Optional;
import org.junit.After;
@@ -82,7 +82,8 @@ public class PlatformControllerTest extends AbstractSpringBootTest {
testRestTemplateService.invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
- final String platformRelationShipUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME, RELATIONSHIP_URL);
+ final String platformRelationShipUrl =
+ getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME, BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
final ResponseEntity<Relationship> responseEntity = testRestTemplateService
.invokeHttpPut(platformRelationShipUrl, TestUtils.getGenericVnfRelationShip(), Relationship.class);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
index 9e477fa4..fd0c4276 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
@@ -23,7 +23,7 @@ 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.so.aaisimulator.utils.TestConstants.RELATIONSHIP_URL;
+import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import org.junit.After;
import org.junit.Test;
import org.onap.aai.domain.yang.Project;
@@ -84,7 +84,8 @@ public class ProjectControllerTest extends AbstractSpringBootTest {
testRestTemplateService.invokeHttpPut(url, TestUtils.getBusinessProject(), Void.class);
assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
- final String projectRelationshipUrl = getUrl(Constants.PROJECT_URL, PROJECT_NAME_VALUE, RELATIONSHIP_URL);
+ final String projectRelationshipUrl =
+ getUrl(Constants.PROJECT_URL, PROJECT_NAME_VALUE, RELATIONSHIP_LIST_RELATIONSHIP_URL);
final ResponseEntity<Void> putResponse = testRestTemplateService.invokeHttpPut(projectRelationshipUrl,
TestUtils.getBusinessProjectRelationship(), Void.class);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java
index 52973a58..415622c9 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java
@@ -45,8 +45,6 @@ public class TestConstants {
public static final String CUSTOMERS_URL = Constants.CUSTOMER_URL + GLOBAL_CUSTOMER_ID;
- public static final String RELATIONSHIP_URL = "/relationship-list/relationship";
-
public static final String VNF_ID = "dfd02fb5-d7fb-4aac-b3c4-cd6b60058701";
public static final String GENERIC_VNF_NAME = "EsyVnfInstantiationTest2";
@@ -65,6 +63,10 @@ public class TestConstants {
public static final String CLOUD_REGION_NAME = "EtsiCloudRegion";
+ public static final String TENANT_ID = "693c7729b2364a26a3ca602e6f66187d";
+
+ public static final String TENANTS_TENANT = "/tenants/tenant/";
+
private TestConstants() {}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
index 7e378662..d851b70e 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
@@ -136,6 +136,10 @@ public class TestUtils {
return getJsonString("test-data/cloud-region.json");
}
+ public static String getTenant() throws IOException {
+ return getJsonString("test-data/tenant.json");
+ }
+
public static Object getCloudRegionRelatedLink() throws IOException {
return getJsonString("test-data/cloud-region-related-link.json");
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/tenant.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/tenant.json
new file mode 100644
index 00000000..746131a6
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/tenant.json
@@ -0,0 +1,4 @@
+{
+ "tenant-id": "693c7729b2364a26a3ca602e6f66187d",
+ "tenant-name": "admin"
+}