aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing
diff options
context:
space:
mode:
Diffstat (limited to 'plans/so/integration-etsi-testing')
-rw-r--r--plans/so/integration-etsi-testing/config/aai-simulator-populate-data/owning-entity.json4
-rwxr-xr-xplans/so/integration-etsi-testing/config/populate-aai-simulator.sh2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/CloudRegionsController.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java21
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java23
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CloudRegionCacheServiceProviderImpl.java17
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java6
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java16
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProvider.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java77
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProviderImpl.java5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProvider.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java83
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java4
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/HttpServiceUtils.java18
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AbstractSpringBootTest.java12
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java12
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java20
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/LinesOfBusinessControllerTest.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java75
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java78
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestConstants.java2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity-relation-ship.json2
27 files changed, 398 insertions, 105 deletions
diff --git a/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/owning-entity.json b/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/owning-entity.json
index 7248d41d..3bfd9cca 100644
--- a/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/owning-entity.json
+++ b/plans/so/integration-etsi-testing/config/aai-simulator-populate-data/owning-entity.json
@@ -1,4 +1,4 @@
{
- "owning-entity-id": "oe_1",
- "owning-entity-name": "oe_2"
+ "owning-entity-id": "f2e1071e-3d47-4a65-94d4-e473ec03326a",
+ "owning-entity-name": "OE-Demonstration"
}
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 87062ed3..3f91f0da 100755
--- a/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
+++ b/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
@@ -89,7 +89,7 @@ populate_aai_simulator()
fi
echo "$SCRIPT_NAME $(current_timestamp): Adding Owning-Entity"
- 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/owning-entities/owning-entity/oe_1 -X PUT -d @$"$OWNING_ENTITY_JSON_FILE")
+ 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/owning-entities/owning-entity/f2e1071e-3d47-4a65-94d4-e473ec03326a -X PUT -d @$"$OWNING_ENTITY_JSON_FILE")
if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put owning entity data in AAI Simulator. Status code received: $status_code"
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 2df11c1f..d7635f2b 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.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getHeaders;
import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
@@ -171,7 +172,8 @@ public class CloudRegionsController {
return getRequestErrorResponseEntity(request, CLOUD_REGION);
}
- @PutMapping(value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/relationship-list/relationship",
+ @PutMapping(
+ value = "{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}" + RELATIONSHIP_LIST_RELATIONSHIP_URL,
consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putRelationShip(@RequestBody final Relationship relationship,
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 e71cd505..216ff13a 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
@@ -22,6 +22,7 @@ package org.onap.so.aaisimulator.controller;
import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF;
import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNFS_URL;
+import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import static org.onap.so.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE;
import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getHeaders;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
@@ -108,7 +109,7 @@ public class GenericVnfsController {
}
- @PutMapping(value = "/generic-vnf/{vnf-id}/relationship-list/relationship",
+ @PutMapping(value = "/generic-vnf/{vnf-id}" + RELATIONSHIP_LIST_RELATIONSHIP_URL,
consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putGenericVnfRelationShip(@RequestBody final Relationship relationship,
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java
index 4923083d..c5ade0cb 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java
@@ -21,6 +21,7 @@ package org.onap.so.aaisimulator.controller;
import static org.onap.so.aaisimulator.utils.Constants.OWNING_ENTITY;
import static org.onap.so.aaisimulator.utils.Constants.OWNING_ENTITY_URL;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getHeaders;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
import java.util.HashMap;
@@ -33,9 +34,11 @@ import org.onap.aai.domain.yang.Relationship;
import org.onap.so.aaisimulator.models.Format;
import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.OwnEntityCacheServiceProvider;
+import org.onap.so.aaisimulator.utils.HttpServiceUtils;
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;
@@ -62,7 +65,6 @@ public class OwningEntityController {
this.cacheServiceProvider = cacheServiceProvider;
}
-
@PutMapping(value = "{owning-entity-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putOwningEntity(@RequestBody final OwningEntity owningEntity,
@@ -115,11 +117,20 @@ public class OwningEntityController {
@PathVariable("owning-entity-id") final String owningEntityId, final HttpServletRequest request) {
LOGGER.info("adding relationship for owning-entity-id: {} ...", owningEntityId);
- if (cacheServiceProvider.putOwningEntityRelationShip(owningEntityId, relationship)) {
- LOGGER.info("added OwningEntity relationship {} in cache", relationship);
- return ResponseEntity.accepted().build();
+
+ if (relationship.getRelatedLink() != null) {
+ final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
+ final HttpHeaders incomingHeader = getHeaders(request);
+
+ final boolean result = cacheServiceProvider.addRelationShip(incomingHeader, targetBaseUrl,
+ request.getRequestURI(), owningEntityId, relationship);
+ if (result) {
+ LOGGER.info("added created bi directional relationship with {}", relationship.getRelatedLink());
+ return ResponseEntity.accepted().build();
+ }
}
- LOGGER.error("Couldn't add relationship for {} in cache", owningEntityId);
+
+ LOGGER.error("Unable to add relationship for related link: {}", relationship.getRelatedLink());
return getRequestErrorResponseEntity(request);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java
index 774eef23..490982a5 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java
@@ -21,6 +21,8 @@ package org.onap.so.aaisimulator.controller;
import static org.onap.so.aaisimulator.utils.Constants.PROJECT;
import static org.onap.so.aaisimulator.utils.Constants.PROJECT_URL;
+import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getHeaders;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
import java.util.HashMap;
@@ -33,9 +35,11 @@ import org.onap.aai.domain.yang.Relationship;
import org.onap.so.aaisimulator.models.Format;
import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.ProjectCacheServiceProvider;
+import org.onap.so.aaisimulator.utils.HttpServiceUtils;
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;
@@ -106,18 +110,27 @@ public class ProjectController {
return getRequestErrorResponseEntity(request);
}
- @PutMapping(value = "/{project-name}/relationship-list/relationship",
+ @PutMapping(value = "/{project-name}" + RELATIONSHIP_LIST_RELATIONSHIP_URL,
consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putProjectRelationShip(@RequestBody final Relationship relationship,
@PathVariable("project-name") final String projectName, final HttpServletRequest request) {
LOGGER.info("adding relationship for project-name: {} ...", projectName);
- if (cacheServiceProvider.putProjectRelationShip(projectName, relationship)) {
- LOGGER.info("added project relationship {} in cache", relationship);
- return ResponseEntity.accepted().build();
+
+ if (relationship.getRelatedLink() != null) {
+ final String targetBaseUrl = HttpServiceUtils.getBaseUrl(request).toString();
+ final HttpHeaders incomingHeader = getHeaders(request);
+
+ final boolean result = cacheServiceProvider.addRelationShip(incomingHeader, targetBaseUrl,
+ request.getRequestURI(), projectName, relationship);
+ if (result) {
+ LOGGER.info("added created bi directional relationship with {}", relationship.getRelatedLink());
+ return ResponseEntity.accepted().build();
+ }
}
- LOGGER.error("Couldn't find {} in cache", projectName);
+
+ LOGGER.error("Unable to add relationship for related link: {}", relationship.getRelatedLink());
return getRequestErrorResponseEntity(request);
}
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 c18fc8f0..a7528bf3 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
@@ -21,7 +21,6 @@ package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.CLOUD_REGION_CACHE;
import static org.onap.so.aaisimulator.utils.Constants.BELONGS_TO;
-import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGION;
import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGION_CLOUD_OWNER;
import static org.onap.so.aaisimulator.utils.Constants.CLOUD_REGION_CLOUD_REGION_ID;
@@ -30,6 +29,9 @@ import static org.onap.so.aaisimulator.utils.Constants.LOCATED_IN;
import static org.onap.so.aaisimulator.utils.Constants.TENANT;
import static org.onap.so.aaisimulator.utils.Constants.TENANT_TENANT_ID;
import static org.onap.so.aaisimulator.utils.Constants.TENANT_TENANT_NAME;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBiDirectionalRelationShipListRelatedLink;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getRelationShipListRelatedLink;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl;
import java.util.List;
import java.util.Optional;
import org.onap.aai.domain.yang.CloudRegion;
@@ -48,7 +50,6 @@ 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)
@@ -108,7 +109,7 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
final Relationship resultantRelationship = new Relationship();
resultantRelationship.setRelatedTo(CLOUD_REGION);
resultantRelationship.setRelationshipLabel(LOCATED_IN);
- resultantRelationship.setRelatedLink(requestUri);
+ resultantRelationship.setRelatedLink(getBiDirectionalRelationShipListRelatedLink(requestUri));
final List<RelationshipData> relationshipDataList = resultantRelationship.getRelationshipData();
relationshipDataList.add(getRelationshipData(CLOUD_REGION_CLOUD_OWNER, cloudRegion.getCloudOwner()));
@@ -206,11 +207,12 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
return false;
}
- private Relationship getRelationship(final String relatedLink, final CloudRegionKey cloudRegionKey, final Tenant tenant) {
+ private Relationship getRelationship(final String requestUriString, final CloudRegionKey cloudRegionKey,
+ final Tenant tenant) {
final Relationship relationShip = new Relationship();
relationShip.setRelatedTo(TENANT);
relationShip.setRelationshipLabel(BELONGS_TO);
- relationShip.setRelatedLink(relatedLink);
+ relationShip.setRelatedLink(getRelationShipListRelatedLink(requestUriString));
final List<RelationshipData> relationshipDataList = relationShip.getRelationshipData();
@@ -226,11 +228,6 @@ public class CloudRegionCacheServiceProviderImpl extends AbstractCacheServicePro
return relationShip;
}
- private String getTargetUrl(final String targetBaseUrl, final String relatedLink) {
- return UriComponentsBuilder.fromUriString(targetBaseUrl).path(relatedLink)
- .path(BI_DIRECTIONAL_RELATIONSHIP_LIST_URL).toUriString();
- }
-
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/CustomerCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java
index 16b34be1..0c38e2bf 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,13 +20,13 @@
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 static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBiDirectionalRelationShipListRelatedLink;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -283,8 +283,8 @@ public class CustomerCacheServiceProviderImpl extends AbstractCacheServiceProvid
final Relationship resultantRelationship = new Relationship();
resultantRelationship.setRelatedTo(GENERIC_VNF);
- resultantRelationship.setRelationshipLabel(COMPOSED_OF);
- resultantRelationship.setRelatedLink(requestUri);
+ resultantRelationship.setRelationshipLabel(relationship.getRelationshipLabel());
+ resultantRelationship.setRelatedLink(getBiDirectionalRelationShipListRelatedLink(requestUri));
final List<RelationshipData> relationshipDataList = resultantRelationship.getRelationshipData();
relationshipDataList.add(getRelationshipData(CUSTOMER_GLOBAL_CUSTOMER_ID, globalCustomerId));
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 fed79d8e..0d97ea99 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,11 +20,13 @@
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 static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBiDirectionalRelationShipListRelatedLink;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getRelationShipListRelatedLink;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import org.onap.aai.domain.yang.GenericVnf;
@@ -40,7 +42,6 @@ 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)
@@ -112,7 +113,8 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
if (optional.isPresent()) {
final GenericVnf genericVnf = optional.get();
final String targetUrl = getTargetUrl(targetBaseUrl, relationship.getRelatedLink());
- final Relationship outGoingRelationShip = getRelationship(requestUriString, genericVnf);
+ final Relationship outGoingRelationShip =
+ getRelationship(getRelationShipListRelatedLink(requestUriString), genericVnf);
final Optional<Relationship> optionalRelationship = httpRestServiceProvider.put(incomingHeader,
outGoingRelationShip, targetUrl, Relationship.class);
if (optionalRelationship.isPresent()) {
@@ -150,7 +152,8 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
relationshipList.getRelationship().add(relationship);
LOGGER.info("Successfully added relation to GenericVnf for vnfId: {}", vnfId);
- final Relationship resultantRelationship = getRelationship(requestURI, genericVnf);
+ final String relatedLink = getBiDirectionalRelationShipListRelatedLink(requestURI);
+ final Relationship resultantRelationship = getRelationship(relatedLink, genericVnf);
return Optional.of(resultantRelationship);
}
return Optional.empty();
@@ -170,11 +173,6 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
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);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java
index 07c46472..3400afc8 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/LinesOfBusinessCacheServiceProviderImpl.java
@@ -23,6 +23,7 @@ import static org.onap.so.aaisimulator.utils.CacheName.LINES_OF_BUSINESS_CACHE;
import static org.onap.so.aaisimulator.utils.Constants.LINE_OF_BUSINESS;
import static org.onap.so.aaisimulator.utils.Constants.LINE_OF_BUSINESS_LINE_OF_BUSINESS_NAME;
import static org.onap.so.aaisimulator.utils.Constants.USES;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBiDirectionalRelationShipListRelatedLink;
import java.util.Optional;
import org.onap.aai.domain.yang.LineOfBusiness;
import org.onap.aai.domain.yang.Relationship;
@@ -88,7 +89,7 @@ public class LinesOfBusinessCacheServiceProviderImpl extends AbstractCacheServic
final Relationship resultantRelationship = new Relationship();
resultantRelationship.setRelatedTo(LINE_OF_BUSINESS);
resultantRelationship.setRelationshipLabel(USES);
- resultantRelationship.setRelatedLink(requestUri);
+ resultantRelationship.setRelatedLink(getBiDirectionalRelationShipListRelatedLink(requestUri));
final RelationshipData relationshipData = new RelationshipData();
relationshipData.setRelationshipKey(LINE_OF_BUSINESS_LINE_OF_BUSINESS_NAME);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProvider.java
index d7f3f129..394ecf17 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProvider.java
@@ -22,6 +22,7 @@ package org.onap.so.aaisimulator.service.providers;
import java.util.Optional;
import org.onap.aai.domain.yang.OwningEntity;
import org.onap.aai.domain.yang.Relationship;
+import org.springframework.http.HttpHeaders;
/**
* @author waqas.ikram@ericsson.com
@@ -33,6 +34,7 @@ public interface OwnEntityCacheServiceProvider extends Clearable {
Optional<OwningEntity> getOwningEntity(final String owningEntityId);
- boolean putOwningEntityRelationShip(String owningEntityId, Relationship relationship);
+ boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl, final String requestUriString,
+ final String owningEntityId, final Relationship relationship);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java
index 59fdfb08..b65ec3ed 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java
@@ -20,10 +20,16 @@
package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.OWNING_ENTITY_CACHE;
-import static org.onap.so.aaisimulator.utils.Constants.SERVICE_RESOURCE_TYPE;
+import static org.onap.so.aaisimulator.utils.Constants.BELONGS_TO;
+import static org.onap.so.aaisimulator.utils.Constants.OWNING_ENTITY;
+import static org.onap.so.aaisimulator.utils.Constants.OWNING_ENTITY_OWNING_ENTITY_ID;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getRelationShipListRelatedLink;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl;
+import java.util.List;
import java.util.Optional;
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.RelationshipList;
import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
@@ -31,6 +37,7 @@ 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;
/**
@@ -42,11 +49,15 @@ public class OwnEntityCacheServiceProviderImpl extends AbstractCacheServiceProvi
implements OwnEntityCacheServiceProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(OwnEntityCacheServiceProviderImpl.class);
- private static final String RELATIONSHIPS_LABEL = "org.onap.relationships.inventory.BelongsTo";
+
+ private final HttpRestServiceProvider httpRestServiceProvider;
+
@Autowired
- public OwnEntityCacheServiceProviderImpl(final CacheManager cacheManager) {
+ public OwnEntityCacheServiceProviderImpl(final CacheManager cacheManager,
+ final HttpRestServiceProvider httpRestServiceProvider) {
super(cacheManager);
+ this.httpRestServiceProvider = httpRestServiceProvider;
}
@Override
@@ -68,26 +79,37 @@ public class OwnEntityCacheServiceProviderImpl extends AbstractCacheServiceProvi
}
@Override
- public boolean putOwningEntityRelationShip(final String owningEntityId, final Relationship relationship) {
- final Cache cache = getCache(OWNING_ENTITY_CACHE.getName());
- final OwningEntity value = cache.get(owningEntityId, OwningEntity.class);
- if (value != null) {
- RelationshipList relationshipList = value.getRelationshipList();
- if (relationshipList == null) {
- relationshipList = new RelationshipList();
- value.setRelationshipList(relationshipList);
- }
+ public boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl,
+ final String requestUriString, final String owningEntityId, final Relationship relationship) {
+ try {
+ final Optional<OwningEntity> optional = getOwningEntity(owningEntityId);
+ if (optional.isPresent()) {
+ final OwningEntity owningEntity = optional.get();
+ final String targetUrl = getTargetUrl(targetBaseUrl, relationship.getRelatedLink());
+ final Relationship outGoingRelationShip = getRelationship(requestUriString, owningEntity);
- if (relationship.getRelatedTo() == null) {
- relationship.setRelatedTo(SERVICE_RESOURCE_TYPE);
- }
- if (relationship.getRelationshipLabel() == null) {
- relationship.setRelationshipLabel(RELATIONSHIPS_LABEL);
+ final Optional<Relationship> optionalRelationship = httpRestServiceProvider.put(incomingHeader,
+ outGoingRelationShip, targetUrl, Relationship.class);
+
+ if (optionalRelationship.isPresent()) {
+ final Relationship resultantRelationship = optionalRelationship.get();
+
+ RelationshipList relationshipList = owningEntity.getRelationshipList();
+ if (relationshipList == null) {
+ relationshipList = new RelationshipList();
+ owningEntity.setRelationshipList(relationshipList);
+ }
+ if (relationshipList.getRelationship().add(resultantRelationship)) {
+ LOGGER.info("added relationship {} in cache successfully", resultantRelationship);
+ return true;
+ }
+ }
}
- return relationshipList.getRelationship().add(relationship);
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to add two-way relationship for owning entity id: {}", owningEntityId, exception);
}
- LOGGER.error("OwningEntity not found in cache for {}", owningEntityId);
+ LOGGER.error("Unable to add relationship in cache for owning entity id: {}", owningEntityId);
return false;
}
@@ -96,4 +118,21 @@ public class OwnEntityCacheServiceProviderImpl extends AbstractCacheServiceProvi
clearCahce(OWNING_ENTITY_CACHE.getName());
}
+ private Relationship getRelationship(final String requestUriString, final OwningEntity owningEntity) {
+ final Relationship relationShip = new Relationship();
+ relationShip.setRelatedTo(OWNING_ENTITY);
+ relationShip.setRelationshipLabel(BELONGS_TO);
+ relationShip.setRelatedLink(getRelationShipListRelatedLink(requestUriString));
+
+ final List<RelationshipData> relationshipDataList = relationShip.getRelationshipData();
+
+ final RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey(OWNING_ENTITY_OWNING_ENTITY_ID);
+ relationshipData.setRelationshipValue(owningEntity.getOwningEntityId());
+
+ relationshipDataList.add(relationshipData);
+
+
+ return relationShip;
+ }
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProviderImpl.java
index f4c1007d..932aaa09 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProviderImpl.java
@@ -23,6 +23,7 @@ import static org.onap.so.aaisimulator.utils.CacheName.PLATFORM_CACHE;
import static org.onap.so.aaisimulator.utils.Constants.PLATFORM;
import static org.onap.so.aaisimulator.utils.Constants.PLATFORM_PLATFORM_NAME;
import static org.onap.so.aaisimulator.utils.Constants.USES;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBiDirectionalRelationShipListRelatedLink;
import java.util.Optional;
import org.onap.aai.domain.yang.Platform;
import org.onap.aai.domain.yang.Relationship;
@@ -82,13 +83,13 @@ public class PlatformCacheServiceProviderImpl extends AbstractCacheServiceProvid
platform.setRelationshipList(relationshipList);
}
relationshipList.getRelationship().add(relationship);
-
+
LOGGER.info("Successfully add relation to Platform with name: {}", platformName);
final Relationship resultantRelationship = new Relationship();
resultantRelationship.setRelatedTo(PLATFORM);
resultantRelationship.setRelationshipLabel(USES);
- resultantRelationship.setRelatedLink(requestUri);
+ resultantRelationship.setRelatedLink(getBiDirectionalRelationShipListRelatedLink(requestUri));
final RelationshipData relationshipData = new RelationshipData();
relationshipData.setRelationshipKey(PLATFORM_PLATFORM_NAME);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProvider.java
index 3e1976cd..9aad53f7 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProvider.java
@@ -22,6 +22,7 @@ package org.onap.so.aaisimulator.service.providers;
import java.util.Optional;
import org.onap.aai.domain.yang.Project;
import org.onap.aai.domain.yang.Relationship;
+import org.springframework.http.HttpHeaders;
/**
* @author waqas.ikram@ericsson.com
@@ -33,6 +34,7 @@ public interface ProjectCacheServiceProvider extends Clearable {
Optional<Project> getProject(final String projectName);
- boolean putProjectRelationShip(final String projectName, final Relationship relationship);
+ boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl, final String requestUri,
+ final String projectName, final Relationship relationship);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java
index 7f2b3bbc..0157d9e8 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java
@@ -20,10 +20,16 @@
package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.PROJECT_CACHE;
-import static org.onap.so.aaisimulator.utils.Constants.SERVICE_RESOURCE_TYPE;
+import static org.onap.so.aaisimulator.utils.Constants.PROJECT;
+import static org.onap.so.aaisimulator.utils.Constants.PROJECT_PROJECT_NAME;
+import static org.onap.so.aaisimulator.utils.Constants.USES;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getRelationShipListRelatedLink;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl;
+import java.util.List;
import java.util.Optional;
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.RelationshipList;
import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
@@ -31,6 +37,7 @@ 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;
/**
@@ -41,13 +48,15 @@ import org.springframework.stereotype.Service;
public class ProjectCacheServiceProviderImpl extends AbstractCacheServiceProvider
implements ProjectCacheServiceProvider {
- private static final String RELATIONSHIPS_LABEL = "org.onap.relationships.inventory.Uses";
-
private static final Logger LOGGER = LoggerFactory.getLogger(ProjectCacheServiceProviderImpl.class);
+ private final HttpRestServiceProvider httpRestServiceProvider;
+
@Autowired
- public ProjectCacheServiceProviderImpl(final CacheManager cacheManager) {
+ public ProjectCacheServiceProviderImpl(final CacheManager cacheManager,
+ final HttpRestServiceProvider httpRestServiceProvider) {
super(cacheManager);
+ this.httpRestServiceProvider = httpRestServiceProvider;
}
@Override
@@ -70,32 +79,62 @@ public class ProjectCacheServiceProviderImpl extends AbstractCacheServiceProvide
}
@Override
- public boolean putProjectRelationShip(final String projectName, final Relationship relationship) {
- final Cache cache = getCache(PROJECT_CACHE.getName());
- final Project value = cache.get(projectName, Project.class);
- if (value != null) {
- RelationshipList relationshipList = value.getRelationshipList();
- if (relationshipList == null) {
- relationshipList = new RelationshipList();
- value.setRelationshipList(relationshipList);
- }
+ public boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl,
+ final String requestUriString, final String projectName, final Relationship relationship) {
+ try {
+ final Optional<Project> optional = getProject(projectName);
- if (relationship.getRelatedTo() == null) {
- relationship.setRelatedTo(SERVICE_RESOURCE_TYPE);
- }
- if (relationship.getRelationshipLabel() == null) {
- relationship.setRelationshipLabel(RELATIONSHIPS_LABEL);
- }
+ if (optional.isPresent()) {
+ final Project project = optional.get();
+ final String targetUrl = getTargetUrl(targetBaseUrl, relationship.getRelatedLink());
+ final Relationship outGoingRelationShip = getRelationship(requestUriString, project);
+
+ final Optional<Relationship> optionalRelationship = httpRestServiceProvider.put(incomingHeader,
+ outGoingRelationShip, targetUrl, Relationship.class);
- return relationshipList.getRelationship().add(relationship);
+ if (optionalRelationship.isPresent()) {
+ final Relationship resultantRelationship = optionalRelationship.get();
+
+ RelationshipList relationshipList = project.getRelationshipList();
+ if (relationshipList == null) {
+ relationshipList = new RelationshipList();
+ project.setRelationshipList(relationshipList);
+ }
+ if (relationshipList.getRelationship().add(resultantRelationship)) {
+ LOGGER.info("added relationship {} in cache successfully", resultantRelationship);
+ return true;
+ }
+ }
+ }
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to add two-way relationship for project name: {}", projectName, exception);
}
- LOGGER.error("Project not found in cache for {}", projectName);
+ LOGGER.error("Unable to add relationship in cache for project name: {}", projectName);
return false;
-
}
@Override
public void clearAll() {
clearCahce(PROJECT_CACHE.getName());
}
+
+ private Relationship getRelationship(final String requestUriString, final Project project) {
+
+ final Relationship relationShip = new Relationship();
+ relationShip.setRelatedTo(PROJECT);
+ relationShip.setRelationshipLabel(USES);
+ relationShip.setRelatedLink(getRelationShipListRelatedLink(requestUriString));
+
+ final List<RelationshipData> relationshipDataList = relationShip.getRelationshipData();
+
+ final RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey(PROJECT_PROJECT_NAME);
+ relationshipData.setRelationshipValue(project.getProjectName());
+
+ relationshipDataList.add(relationshipData);
+
+
+ return relationShip;
+ }
+
}
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 83ae57a1..97f25251 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
@@ -58,8 +58,12 @@ public class Constants {
public static final String PROJECT = "project";
+ public static final String PROJECT_PROJECT_NAME = "project.project-name";
+
public static final String OWNING_ENTITY = "owning-entity";
+ public static final String OWNING_ENTITY_OWNING_ENTITY_ID = "owning-entity.owning-entity-id";
+
public static final String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override";
public static final String SERVICE_RESOURCE_TYPE = "service-instance";
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/HttpServiceUtils.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/HttpServiceUtils.java
index 339ae814..a03a2757 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/HttpServiceUtils.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/HttpServiceUtils.java
@@ -20,6 +20,8 @@
package org.onap.so.aaisimulator.utils;
import static org.onap.so.aaisimulator.utils.Constants.BASE_URL;
+import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
+import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
import static org.springframework.http.MediaType.APPLICATION_XML;
import java.net.URI;
import java.util.Arrays;
@@ -62,4 +64,20 @@ public class HttpServiceUtils {
return headers;
}
+ public static String getTargetUrl(final String targetBaseUrl, final String relatedLink) {
+ return UriComponentsBuilder.fromUriString(targetBaseUrl).path(relatedLink)
+ .path(BI_DIRECTIONAL_RELATIONSHIP_LIST_URL).toUriString();
+ }
+
+ public static String getRelationShipListRelatedLink(final String requestUriString) {
+ return requestUriString != null ? requestUriString.replaceFirst(RELATIONSHIP_LIST_RELATIONSHIP_URL, "")
+ : requestUriString;
+ }
+
+ public static String getBiDirectionalRelationShipListRelatedLink(final String requestUriString) {
+ return requestUriString != null ? requestUriString.replaceFirst(BI_DIRECTIONAL_RELATIONSHIP_LIST_URL, "")
+ : requestUriString;
+ }
+
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AbstractSpringBootTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AbstractSpringBootTest.java
index 18bd925e..84bb8cab 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AbstractSpringBootTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/AbstractSpringBootTest.java
@@ -19,7 +19,10 @@
*/
package org.onap.so.aaisimulator.controller;
+import java.util.List;
import org.junit.runner.RunWith;
+import org.onap.aai.domain.yang.RelatedToProperty;
+import org.onap.aai.domain.yang.RelationshipData;
import org.onap.so.aaisimulator.utils.TestRestTemplateService;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -50,4 +53,13 @@ public abstract class AbstractSpringBootTest {
return TestUtils.getUrl(port, urls);
}
+ public RelationshipData getRelationshipData(final List<RelationshipData> relationshipData, final String key) {
+ return relationshipData.stream().filter(data -> data.getRelationshipKey().equals(key)).findFirst().orElse(null);
+ }
+
+ public RelatedToProperty getRelatedToProperty(final List<RelatedToProperty> relatedToPropertyList,
+ final String key) {
+ return relatedToPropertyList.stream().filter(data -> data.getPropertyKey().equals(key)).findFirst()
+ .orElse(null);
+ }
}
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 a7bacb29..012c9ca6 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
@@ -145,6 +145,8 @@ public class CloudRegionsControllerTest extends AbstractSpringBootTest {
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());
@@ -265,16 +267,6 @@ public class CloudRegionsControllerTest extends AbstractSpringBootTest {
}
- private RelationshipData getRelationshipData(final List<RelationshipData> relationshipData, final String key) {
- return relationshipData.stream().filter(data -> data.getRelationshipKey().equals(key)).findFirst().orElse(null);
- }
-
- private RelatedToProperty getRelatedToProperty(final List<RelatedToProperty> relatedToPropertyList,
- final String key) {
- return relatedToPropertyList.stream().filter(data -> data.getPropertyKey().equals(key)).findFirst()
- .orElse(null);
- }
-
private void invokeCloudRegionHttpPutEndPointAndAssertResponse(final String url) throws IOException {
final ResponseEntity<Void> responseEntity =
testRestTemplateService.invokeHttpPut(url, TestUtils.getCloudRegion(), Void.class);
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 a02900cd..1acd1f23 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
@@ -133,6 +133,8 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
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());
@@ -154,6 +156,8 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
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);
@@ -206,6 +210,8 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
assertEquals(Constants.USES, relationship.getRelationshipLabel());
assertFalse(relationship.getRelationshipData().isEmpty());
assertEquals(1, relationship.getRelationshipData().size());
+ assertEquals(Constants.PLATFORMS_URL + PLATFORM_NAME, relationship.getRelatedLink());
+
final List<RelationshipData> relationshipData = relationship.getRelationshipData();
@@ -241,6 +247,8 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
final Relationship relationship = relationshipList.getRelationship().get(0);
assertEquals(Constants.USES, relationship.getRelationshipLabel());
+ assertEquals(Constants.LINES_OF_BUSINESS_URL + LINE_OF_BUSINESS_NAME, relationship.getRelatedLink());
+
assertFalse(relationship.getRelationshipData().isEmpty());
assertEquals(1, relationship.getRelationshipData().size());
@@ -279,6 +287,9 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
final Relationship relationship = relationshipList.getRelationship().get(0);
assertEquals(Constants.LOCATED_IN, relationship.getRelationshipLabel());
+ assertEquals(Constants.CLOUD_REGIONS + CLOUD_OWNER_NAME + "/" + CLOUD_REGION_NAME,
+ relationship.getRelatedLink());
+
assertFalse(relationship.getRelationshipData().isEmpty());
assertEquals(2, relationship.getRelationshipData().size());
@@ -370,14 +381,5 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
}
- private RelationshipData getRelationshipData(final List<RelationshipData> relationshipData, final String key) {
- return relationshipData.stream().filter(data -> data.getRelationshipKey().equals(key)).findFirst().orElse(null);
- }
-
- private RelatedToProperty getRelatedToProperty(final List<RelatedToProperty> relatedToPropertyList,
- final String key) {
- return relatedToPropertyList.stream().filter(data -> data.getPropertyKey().equals(key)).findFirst()
- .orElse(null);
- }
}
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 3b1b0ac3..111993ce 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
@@ -24,7 +24,9 @@ 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.GENERIC_VNF_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.LINE_OF_BUSINESS_NAME;
+import static org.onap.so.aaisimulator.utils.TestConstants.VNF_ID;
import java.util.List;
import java.util.Optional;
import org.junit.After;
@@ -124,6 +126,7 @@ public class LinesOfBusinessControllerTest extends AbstractSpringBootTest {
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());
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 34ac30ae..f4fcadeb 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
@@ -24,11 +24,24 @@ 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.CUSTOMERS_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
+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_SUBSCRIPTIONS_URL;
+import static org.onap.so.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.so.aaisimulator.models.Format;
import org.onap.so.aaisimulator.models.Results;
+import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.OwnEntityCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestUtils;
@@ -48,9 +61,13 @@ public class OwningEntityControllerTest extends AbstractSpringBootTest {
@Autowired
private OwnEntityCacheServiceProvider cacheServiceProvider;
+ @Autowired
+ private CustomerCacheServiceProvider customerCacheServiceProvider;
+
@After
public void after() {
cacheServiceProvider.clearAll();
+ customerCacheServiceProvider.clearAll();
}
@Test
@@ -94,6 +111,8 @@ public class OwningEntityControllerTest extends AbstractSpringBootTest {
@Test
public void test_putOwningEntityRelationShip_successfullyAddedToCache() throws Exception {
+ addCustomerAndServiceInstance();
+
final String url = getUrl(Constants.OWNING_ENTITY_URL, OWN_ENTITY_ID_VALUE);
final ResponseEntity<Void> actual =
testRestTemplateService.invokeHttpPut(url, TestUtils.getOwningEntity(), Void.class);
@@ -118,6 +137,62 @@ public class OwningEntityControllerTest extends AbstractSpringBootTest {
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(Constants.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/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 ea8f59b6..331d9726 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
@@ -24,7 +24,9 @@ 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.GENERIC_VNF_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.PLATFORM_NAME;
+import static org.onap.so.aaisimulator.utils.TestConstants.VNF_ID;
import java.util.List;
import java.util.Optional;
import org.junit.After;
@@ -123,6 +125,7 @@ public class PlatformControllerTest extends AbstractSpringBootTest {
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());
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 fd0c4276..ecda94e3 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
@@ -24,10 +24,23 @@ 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.CUSTOMERS_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.GLOBAL_CUSTOMER_ID;
+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_SUBSCRIPTIONS_URL;
+import static org.onap.so.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.so.aaisimulator.models.Results;
+import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.ProjectCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestRestTemplateService;
@@ -54,9 +67,13 @@ public class ProjectControllerTest extends AbstractSpringBootTest {
@Autowired
private ProjectCacheServiceProvider cacheServiceProvider;
+ @Autowired
+ private CustomerCacheServiceProvider customerCacheServiceProvider;
+
@After
public void after() {
cacheServiceProvider.clearAll();
+ customerCacheServiceProvider.clearAll();
}
@Test
@@ -79,6 +96,8 @@ public class ProjectControllerTest extends AbstractSpringBootTest {
@Test
public void test_putProjectRelationShip_successfullyAddedToCache() throws Exception {
+ addCustomerAndServiceInstance();
+
final String url = getUrl(Constants.PROJECT_URL, PROJECT_NAME_VALUE);
final ResponseEntity<Void> actual =
testRestTemplateService.invokeHttpPut(url, TestUtils.getBusinessProject(), Void.class);
@@ -102,6 +121,52 @@ public class ProjectControllerTest extends AbstractSpringBootTest {
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(Constants.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
@@ -123,4 +188,17 @@ public class ProjectControllerTest extends AbstractSpringBootTest {
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/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 415622c9..eba2943d 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
@@ -49,7 +49,7 @@ public class TestConstants {
public static final String GENERIC_VNF_NAME = "EsyVnfInstantiationTest2";
- public static final String GENERIC_VNF_URL = Constants.GENERIC_VNFS_URL + "/generic-vnf/";
+ public static final String GENERIC_VNF_URL = Constants.GENERIC_VNFS_URL + "generic-vnf/";
public static final String GENERIC_VNFS_URL = "/generic-vnfs";
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json
index 9f6e5f35..c2662266 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/business-project-relation-ship.json
@@ -1,3 +1,3 @@
{
- "related-link": "/aai/v15/business/customers/customer/NordixDemoCustomer/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/ae93f2d8-7d06-4eeb-8712-93a2bdb776f6"
+ "related-link": "/business/customers/customer/DemoCustomer/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/ccece8fe-13da-456a-baf6-41b3a4a2bc2b"
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity-relation-ship.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity-relation-ship.json
index 1c419476..c2662266 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity-relation-ship.json
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/owning-entity-relation-ship.json
@@ -1,3 +1,3 @@
{
- "related-link": "/business/customers/customer/NordixDemoCustomer/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/ccece8fe-13da-456a-baf6-41b3a4a2bc2b"
+ "related-link": "/business/customers/customer/DemoCustomer/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/ccece8fe-13da-456a-baf6-41b3a4a2bc2b"
}