aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-08-19 13:44:42 +0000
committerWaqas Ikram <waqas.ikram@est.tech>2019-08-19 13:45:21 +0000
commitff79c8b3e49b954d0987657c97053521a9d0f808 (patch)
tree85d3b71c55108dc44da496441b07f413cd30904f /plans/so/integration-etsi-testing
parent450b162a79a1b98b223ffe96ae386779483ac7e4 (diff)
Adding aai platform endpoints
Change-Id: Ibe08bf0a6f7e65632a1ebc7a539272f55a049eaf Issue-ID: SO-2219 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'plans/so/integration-etsi-testing')
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/BusinessController.java2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java9
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java27
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java109
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/Clearable.java28
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProvider.java6
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java6
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java28
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProvider.java8
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java32
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProvider.java5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProvider.java39
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProviderImpl.java109
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProvider.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java1
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java8
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/GenericVnfsControllerTest.java99
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java72
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java159
-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.java38
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-related-link.json3
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-relationship.json13
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform.json3
25 files changed, 717 insertions, 99 deletions
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 c88dac46..22767b29 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
@@ -323,7 +323,7 @@ public class BusinessController {
final ServiceInstance serviceInstance = optional.get();
final Relationship resultantRelationship = new Relationship();
resultantRelationship.setRelatedTo(GENERIC_VNF);
- resultantRelationship.setRelatedLink(COMPOSED_OF);
+ resultantRelationship.setRelationshipLabel(COMPOSED_OF);
resultantRelationship.setRelatedLink(request.getRequestURI());
final List<RelationshipData> relationshipDataList = resultantRelationship.getRelationshipData();
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 c6ec3a5e..2eb84f05 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
@@ -49,6 +49,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.util.UriComponentsBuilder;
/**
@@ -89,8 +90,8 @@ 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,
- final HttpServletRequest request) {
- LOGGER.info("Will get GenericVnf for 'vnf-id': {} ...", vnfId);
+ @RequestParam(name = "depth", required = false) final Integer depth, final HttpServletRequest request) {
+ LOGGER.info("Will get GenericVnf for 'vnf-id': {} with depth: {}...", vnfId, depth);
final Optional<GenericVnf> optional = cacheServiceProvider.getGenericVnf(vnfId);
@@ -100,7 +101,7 @@ public class GenericVnfsController {
return ResponseEntity.ok(genericVnf);
}
- LOGGER.error("Unable to find GenericVnf in cache for 'vnf-id': {} ...", vnfId);
+ LOGGER.error("Unable to find GenericVnf in cache for 'vnf-id': {} with depth: {} ...", vnfId, depth);
return getRequestErrorResponseEntity(request, GENERIC_VNF);
}
@@ -110,7 +111,7 @@ public class GenericVnfsController {
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> putGenericVnfRelationShip(@RequestBody final Relationship relationship,
@PathVariable("vnf-id") final String vnfId, final HttpServletRequest request) {
- LOGGER.info("Will put customer for 'global customer id': {} ...", vnfId);
+ LOGGER.info("Will put RelationShip for 'vnf-id': {} ...", vnfId);
try {
if (relationship.getRelatedLink() != null) {
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java
index 17de3748..21bcae93 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java
@@ -19,6 +19,7 @@
*/
package org.onap.so.aaisimulator.controller;
+import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF;
import static org.onap.so.aaisimulator.utils.Constants.NODES_URL;
import static org.onap.so.aaisimulator.utils.Constants.RESOURCE_LINK;
import static org.onap.so.aaisimulator.utils.Constants.RESOURCE_TYPE;
@@ -28,11 +29,11 @@ import java.util.Map;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.aaisimulator.models.Format;
import org.onap.so.aaisimulator.models.NodeServiceInstance;
import org.onap.so.aaisimulator.models.Results;
-import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.NodesCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,12 +58,8 @@ public class NodesController {
private final NodesCacheServiceProvider cacheServiceProvider;
- private final CustomerCacheServiceProvider customerCacheServiceProvider;
-
@Autowired
- public NodesController(final CustomerCacheServiceProvider customerCacheServiceProvider,
- final NodesCacheServiceProvider cacheServiceProvider) {
- this.customerCacheServiceProvider = customerCacheServiceProvider;
+ public NodesController(final NodesCacheServiceProvider cacheServiceProvider) {
this.cacheServiceProvider = cacheServiceProvider;
}
@@ -90,12 +87,11 @@ public class NodesController {
return ResponseEntity.ok(new Results(map));
case RAW:
final Optional<ServiceInstance> serviceInstance =
- customerCacheServiceProvider.getServiceInstance(nodeServiceInstance.getGlobalCustomerId(),
- nodeServiceInstance.getServiceType(), nodeServiceInstance.getServiceInstanceId());
+ cacheServiceProvider.getServiceInstance(nodeServiceInstance);
if (serviceInstance.isPresent()) {
return ResponseEntity.ok(serviceInstance.get());
}
- LOGGER.info("Unable to find Service instance in cahce using {}", nodeServiceInstance);
+ LOGGER.error("Unable to find Service instance in cahce using {}", nodeServiceInstance);
return getRequestErrorResponseEntity(request);
default:
break;
@@ -103,4 +99,17 @@ public class NodesController {
LOGGER.error("invalid format type :{}", format);
return getRequestErrorResponseEntity(request);
}
+
+ @GetMapping(value = "/generic-vnfs", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getGenericVnfs(@RequestParam(name = "vnf-name") final String vnfName,
+ final HttpServletRequest request) {
+ LOGGER.info("will find GenericVnfs for name: {}", vnfName);
+ final Optional<GenericVnfs> optional = cacheServiceProvider.getGenericVnfs(vnfName);
+ if (optional.isPresent()) {
+ LOGGER.info("found matching GenericVnfs for name: {}", vnfName);
+ return ResponseEntity.ok(optional.get());
+ }
+ LOGGER.error("Unable to find GenericVnfs in cahce using {}", vnfName);
+ return getRequestErrorResponseEntity(request, GENERIC_VNF);
+ }
}
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
new file mode 100644
index 00000000..a80477cd
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/PlatformController.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.controller;
+
+import static org.onap.so.aaisimulator.utils.Constants.PLATFORMS_URL;
+import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getRequestErrorResponseEntity;
+import static org.onap.so.aaisimulator.utils.RequestErrorResponseUtils.getResourceVersion;
+import java.util.Optional;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+import org.onap.aai.domain.yang.Platform;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.so.aaisimulator.service.providers.PlatformCacheServiceProvider;
+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.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Controller
+@RequestMapping(path = PLATFORMS_URL)
+public class PlatformController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PlatformController.class);
+
+ private final PlatformCacheServiceProvider cacheServiceProvider;
+
+ @Autowired
+ public PlatformController(final PlatformCacheServiceProvider cacheServiceProvider) {
+ this.cacheServiceProvider = cacheServiceProvider;
+ }
+
+ @PutMapping(value = "{platform-name}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putPlatform(@RequestBody final Platform platform,
+ @PathVariable("platform-name") final String platformName, final HttpServletRequest request) {
+ LOGGER.info("Will add Platform to cache with key 'platform-name': {} ...", platform.getPlatformName());
+
+ if (platform.getResourceVersion() == null || platform.getResourceVersion().isEmpty()) {
+ platform.setResourceVersion(getResourceVersion());
+
+ }
+ cacheServiceProvider.putPlatform(platformName, platform);
+ return ResponseEntity.accepted().build();
+ }
+
+ @GetMapping(value = "/{platform-name}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getPlatform(@PathVariable("platform-name") final String platformName,
+ final HttpServletRequest request) {
+ LOGGER.info("retrieving Platform for 'platform-name': {} ...", platformName);
+ final Optional<Platform> optional = cacheServiceProvider.getPlatform(platformName);
+ if (optional.isPresent()) {
+ final Platform platform = optional.get();
+ LOGGER.info("found Platform {} in cache", platform);
+ return ResponseEntity.ok(platform);
+ }
+ LOGGER.error("Unable to find Platform in cahce using {}", platformName);
+ return getRequestErrorResponseEntity(request);
+ }
+
+ @PutMapping(value = "/{platform-name}/relationship-list/relationship",
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putSericeInstanceRelationShip(@PathVariable("platform-name") final String platformName,
+ @RequestBody final Relationship relationship, final HttpServletRequest request) {
+ LOGGER.info("Will add {} relationship to : {} ...", relationship.getRelatedTo());
+
+ final Optional<Relationship> optional =
+ cacheServiceProvider.addRelationShip(platformName, relationship, request.getRequestURI());
+
+ if (optional.isPresent()) {
+ final Relationship resultantRelationship = optional.get();
+ LOGGER.info("Relationship add, sending resultant relationship: {} in response ...", resultantRelationship);
+ return ResponseEntity.accepted().body(resultantRelationship);
+ }
+
+ LOGGER.error("Couldn't add {} relationship for 'platform-name': {} ...", relationship.getRelatedTo(),
+ platformName);
+
+ return RequestErrorResponseUtils.getRequestErrorResponseEntity(request);
+
+ }
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/Clearable.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/Clearable.java
new file mode 100644
index 00000000..dd4ace4d
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/Clearable.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.service.providers;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface Clearable {
+ void clearAll();
+}
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 f20bd15b..bf30013a 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
@@ -30,7 +30,7 @@ import org.onap.aai.domain.yang.ServiceSubscription;
* @author waqas.ikram@ericsson.com
*
*/
-public interface CustomerCacheServiceProvider {
+public interface CustomerCacheServiceProvider extends Clearable {
Optional<Customer> getCustomer(final String globalCustomerId);
@@ -59,8 +59,4 @@ public interface CustomerCacheServiceProvider {
Optional<ServiceInstance> addRelationShip(final String globalCustomerId, final String serviceType,
final String serviceInstanceId, final Relationship relationship);
- void clearAll();
-
-
-
}
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 e2bcc9a4..213ecf69 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
@@ -27,14 +27,14 @@ import org.onap.aai.domain.yang.Relationship;
* @author Waqas Ikram (waqas.ikram@est.tech)
*
*/
-public interface GenericVnfCacheServiceProvider {
+public interface GenericVnfCacheServiceProvider extends Clearable {
void putGenericVnf(final String vnfId, final GenericVnf genericVnf);
Optional<GenericVnf> getGenericVnf(final String vnfId);
-
+
boolean addRelationShip(final String vnfId, final Relationship relationship);
- void clearAll();
+ 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 709f80d7..7ff012f6 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
@@ -21,6 +21,7 @@ package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.GENERIC_VNF_CACHE;
import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipList;
@@ -70,7 +71,7 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
public boolean addRelationShip(final String vnfId, final Relationship relationship) {
final Optional<GenericVnf> optional = getGenericVnf(vnfId);
if (optional.isPresent()) {
- GenericVnf genericVnf = optional.get();
+ final GenericVnf genericVnf = optional.get();
RelationshipList relationshipList = genericVnf.getRelationshipList();
if (relationshipList == null) {
relationshipList = new RelationshipList();
@@ -83,7 +84,32 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
}
@Override
+ public Optional<String> getGenericVnfId(final String vnfName) {
+ final Cache cache = getCache(GENERIC_VNF_CACHE.getName());
+ if (cache != null) {
+ final Object nativeCache = cache.getNativeCache();
+ if (nativeCache instanceof ConcurrentHashMap) {
+ @SuppressWarnings("unchecked")
+ final ConcurrentHashMap<Object, Object> concurrentHashMap =
+ (ConcurrentHashMap<Object, Object>) nativeCache;
+ for (final Object key : concurrentHashMap.keySet()) {
+ final GenericVnf value = cache.get(key, GenericVnf.class);
+ final String genericVnfName = value.getVnfName();
+ if (value != null && genericVnfName.equals(vnfName)) {
+ final String genericVnfId = value.getVnfId();
+ LOGGER.info("Found matching vnf for name: {}, vnf-id: {}", genericVnfName, genericVnfId);
+ return Optional.of(genericVnfId);
+ }
+ }
+ }
+ }
+ LOGGER.info("No match found for vnf name: {}", vnfName);
+ return Optional.empty();
+ }
+
+ @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/NodesCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProvider.java
index 0dbd45eb..02327469 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProvider.java
@@ -20,18 +20,22 @@
package org.onap.so.aaisimulator.service.providers;
import java.util.Optional;
+import org.onap.aai.domain.yang.GenericVnfs;
+import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.aaisimulator.models.NodeServiceInstance;
/**
* @author waqas.ikram@ericsson.com
*
*/
-public interface NodesCacheServiceProvider {
+public interface NodesCacheServiceProvider extends Clearable {
void putNodeServiceInstance(final String serviceInstanceId, final NodeServiceInstance nodeServiceInstance);
Optional<NodeServiceInstance> getNodeServiceInstance(final String serviceInstanceId);
- void clearAll();
+ Optional<GenericVnfs> getGenericVnfs(final String vnfName);
+
+ Optional<ServiceInstance> getServiceInstance(final NodeServiceInstance nodeServiceInstance);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java
index ca4765e5..4ea255f5 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java
@@ -22,6 +22,9 @@ package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.NODES_CACHE;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
+import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.aaisimulator.models.NodeServiceInstance;
import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
@@ -38,11 +41,17 @@ import org.springframework.stereotype.Service;
@Service
public class NodesCacheServiceProviderImpl extends AbstractCacheServiceProvider implements NodesCacheServiceProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(NodesCacheServiceProviderImpl.class);
+ private final GenericVnfCacheServiceProvider cacheServiceProvider;
+ private final CustomerCacheServiceProvider customerCacheServiceProvider;
@Autowired
- public NodesCacheServiceProviderImpl(final CacheManager cacheManager) {
+ public NodesCacheServiceProviderImpl(final CacheManager cacheManager,
+ final GenericVnfCacheServiceProvider cacheServiceProvider,
+ final CustomerCacheServiceProvider customerCacheServiceProvider) {
super(cacheManager);
+ this.cacheServiceProvider = cacheServiceProvider;
+ this.customerCacheServiceProvider = customerCacheServiceProvider;
}
@Override
@@ -64,6 +73,27 @@ public class NodesCacheServiceProviderImpl extends AbstractCacheServiceProvider
}
@Override
+ public Optional<GenericVnfs> getGenericVnfs(final String vnfName) {
+ final Optional<String> genericVnfId = cacheServiceProvider.getGenericVnfId(vnfName);
+ if (genericVnfId.isPresent()) {
+ final Optional<GenericVnf> genericVnf = cacheServiceProvider.getGenericVnf(genericVnfId.get());
+ if (genericVnf.isPresent()) {
+ final GenericVnfs genericVnfs = new GenericVnfs();
+ genericVnfs.getGenericVnf().add(genericVnf.get());
+ return Optional.of(genericVnfs);
+ }
+ }
+ LOGGER.error("Unable to find GenericVnf for name: {}", vnfName);
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<ServiceInstance> getServiceInstance(final NodeServiceInstance nodeServiceInstance) {
+ return customerCacheServiceProvider.getServiceInstance(nodeServiceInstance.getGlobalCustomerId(),
+ nodeServiceInstance.getServiceType(), nodeServiceInstance.getServiceInstanceId());
+ }
+
+ @Override
public void clearAll() {
final Cache cache = getCache(NODES_CACHE.getName());
final ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) cache.getNativeCache();
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 e34aa70a..d7f3f129 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
@@ -27,13 +27,12 @@ import org.onap.aai.domain.yang.Relationship;
* @author waqas.ikram@ericsson.com
*
*/
-public interface OwnEntityCacheServiceProvider {
+public interface OwnEntityCacheServiceProvider extends Clearable {
void putOwningEntity(final String owningEntityId, final OwningEntity owningEntity);
Optional<OwningEntity> getOwningEntity(final String owningEntityId);
boolean putOwningEntityRelationShip(String owningEntityId, Relationship relationship);
-
- void clearAll();
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProvider.java
new file mode 100644
index 00000000..65788bcd
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProvider.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.service.providers;
+
+import java.util.Optional;
+import org.onap.aai.domain.yang.Platform;
+import org.onap.aai.domain.yang.Relationship;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface PlatformCacheServiceProvider extends Clearable {
+
+ void putPlatform(final String platformName, final Platform platform);
+
+ Optional<Platform> getPlatform(final String platformName);
+
+ Optional<Relationship> addRelationShip(final String platformName, 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/PlatformCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProviderImpl.java
new file mode 100644
index 00000000..f4c1007d
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/PlatformCacheServiceProviderImpl.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.service.providers;
+
+import static org.onap.so.aaisimulator.utils.CacheName.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 java.util.Optional;
+import org.onap.aai.domain.yang.Platform;
+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;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Service
+public class PlatformCacheServiceProviderImpl extends AbstractCacheServiceProvider
+ implements PlatformCacheServiceProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PlatformCacheServiceProviderImpl.class);
+
+ @Autowired
+ public PlatformCacheServiceProviderImpl(final CacheManager cacheManager) {
+ super(cacheManager);
+ }
+
+ @Override
+ public void putPlatform(final String platformName, final Platform platform) {
+ LOGGER.info("Adding Platform to cache with key: {} ...", platformName);
+ final Cache cache = getCache(PLATFORM_CACHE.getName());
+ cache.put(platformName, platform);
+ }
+
+ @Override
+ public Optional<Platform> getPlatform(final String platformName) {
+ LOGGER.info("getting Platform from cache using key: {}", platformName);
+ final Cache cache = getCache(PLATFORM_CACHE.getName());
+ final Platform value = cache.get(platformName, Platform.class);
+ if (value != null) {
+ return Optional.of(value);
+ }
+ LOGGER.error("Unable to find Platform in cache using key:{} ", platformName);
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<Relationship> addRelationShip(final String platformName, final Relationship relationship,
+ final String requestUri) {
+ final Optional<Platform> optional = getPlatform(platformName);
+ if (optional.isPresent()) {
+ final Platform platform = optional.get();
+ RelationshipList relationshipList = platform.getRelationshipList();
+ if (relationshipList == null) {
+ relationshipList = new RelationshipList();
+ 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);
+
+ final RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey(PLATFORM_PLATFORM_NAME);
+ relationshipData.setRelationshipValue(platform.getPlatformName());
+ resultantRelationship.getRelationshipData().add(relationshipData);
+
+ return Optional.of(resultantRelationship);
+ }
+ LOGGER.error("Unable to find Platform ...");
+ return Optional.empty();
+ }
+
+ @Override
+ public void clearAll() {
+ clearCahce(PLATFORM_CACHE.getName());
+ }
+
+}
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 60f763c7..3e1976cd 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
@@ -27,7 +27,7 @@ import org.onap.aai.domain.yang.Relationship;
* @author waqas.ikram@ericsson.com
*
*/
-public interface ProjectCacheServiceProvider {
+public interface ProjectCacheServiceProvider extends Clearable {
void putProject(final String projectName, final Project project);
@@ -35,5 +35,4 @@ public interface ProjectCacheServiceProvider {
boolean putProjectRelationShip(final String projectName, final Relationship relationship);
- void clearAll();
}
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 9eaedfda..7f2b3bbc 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
@@ -45,7 +45,6 @@ public class ProjectCacheServiceProviderImpl extends AbstractCacheServiceProvide
private static final Logger LOGGER = LoggerFactory.getLogger(ProjectCacheServiceProviderImpl.class);
-
@Autowired
public ProjectCacheServiceProviderImpl(final CacheManager cacheManager) {
super(cacheManager);
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java
index e276a045..c39daa0b 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/CacheName.java
@@ -29,7 +29,8 @@ public enum CacheName {
PROJECT_CACHE("project-cache"),
NODES_CACHE("nodes-cache"),
GENERIC_VNF_CACHE("generic-vnf-cache"),
- OWNING_ENTITY_CACHE("owning-entity-cache");
+ OWNING_ENTITY_CACHE("owning-entity-cache"),
+ PLATFORM_CACHE("platform-cache");
private String name;
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/utils/Constants.java
index 9078f036..94bee270 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
@@ -37,6 +37,8 @@ public class Constants {
public static final String OWNING_ENTITY_URL = BUSINESS_URL + "/owning-entities/owning-entity";
+ public static final String PLATFORMS_URL = BUSINESS_URL + "/platforms/platform/";
+
public static final String NETWORK_URL = BASE_URL + "/network";
public static final String GENERIC_VNFS_URL = NETWORK_URL + "/generic-vnfs/";
@@ -71,6 +73,12 @@ public class Constants {
public static final String GENERIC_VNF = "generic-vnf";
+ public static final String PLATFORM = "platform";
+
+ public static final String USES = "org.onap.relationships.inventory.Uses";
+
+ public static final String PLATFORM_PLATFORM_NAME = "platform.platform-name";
+
public static final String SERVICE_SUBSCRIPTION = "service-subscription";
public static final String CUSTOMER_TYPE = "Customer";
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 5327a1fe..abff7499 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
@@ -27,6 +27,7 @@ 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.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;
@@ -34,7 +35,6 @@ import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_TYPE;
import static org.onap.so.aaisimulator.utils.TestConstants.VNF_ID;
-import static org.onap.so.aaisimulator.utils.TestUtils.getJsonString;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
@@ -49,6 +49,7 @@ import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
+import org.onap.so.aaisimulator.service.providers.PlatformCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.onap.so.simulator.model.UserCredentials;
@@ -65,7 +66,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.web.util.UriComponentsBuilder;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -92,17 +92,21 @@ public class GenericVnfsControllerTest {
@Autowired
private GenericVnfCacheServiceProvider genericVnfCacheServiceProvider;
+ @Autowired
+ private PlatformCacheServiceProvider platformVnfCacheServiceProvider;
+
@After
public void after() {
customerCacheServiceProvider.clearAll();
genericVnfCacheServiceProvider.clearAll();
+ platformVnfCacheServiceProvider.clearAll();
}
@Test
public void test_putGenericVnf_successfullyAddedToCache() throws Exception {
final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> genericVnfResponse = invokeHttpPut(genericVnfUrl, getGenericVnf());
+ final ResponseEntity<Void> genericVnfResponse = invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf());
assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
final ResponseEntity<GenericVnf> response = invokeHttpGet(genericVnfUrl, GenericVnf.class);
@@ -119,20 +123,11 @@ public class GenericVnfsControllerTest {
@Test
public void test_putGenericVnfRelation_successfullyAddedToCache() throws Exception {
- final ResponseEntity<Void> customerResponse = invokeHttpPut(getUrl(CUSTOMERS_URL), getCustomer());
- assertEquals(HttpStatus.ACCEPTED, customerResponse.getStatusCode());
-
- final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
- final ResponseEntity<Void> serviceInstanceResponse = invokeHttpPut(serviceInstanceUrl, getServiceInstance());
- assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
-
- final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
- final ResponseEntity<Void> genericVnfResponse = invokeHttpPut(genericVnfUrl, getGenericVnf());
- assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
+ addCustomerServiceAndGenericVnf();
final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_URL);
final ResponseEntity<Void> genericVnfRelationShipResponse =
- invokeHttpPut(genericVnfRelationShipUrl, getRelationShip());
+ invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getRelationShip());
assertEquals(HttpStatus.ACCEPTED, genericVnfRelationShipResponse.getStatusCode());
@@ -148,6 +143,8 @@ public class GenericVnfsControllerTest {
assertFalse(actualRelationshipList.getRelationship().isEmpty());
final Relationship actualRelationShip = actualRelationshipList.getRelationship().get(0);
+ assertEquals(Constants.COMPOSED_OF, actualRelationShip.getRelationshipLabel());
+
assertFalse(actualRelationShip.getRelatedToProperty().isEmpty());
assertFalse(actualRelationShip.getRelationshipData().isEmpty());
final RelatedToProperty actualRelatedToProperty = actualRelationShip.getRelatedToProperty().get(0);
@@ -193,6 +190,57 @@ public class GenericVnfsControllerTest {
}
+ @Test
+ public void test_putGenericVnfRelationToPlatform_successfullyAddedToCache() throws Exception {
+ addCustomerServiceAndGenericVnf();
+
+ final String platformUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME);
+ final ResponseEntity<Void> platformResponse = invokeHttpPut(platformUrl, TestUtils.getPlatform());
+ assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
+
+ final String genericVnfRelationShipUrl = getUrl(GENERIC_VNF_URL, VNF_ID, RELATIONSHIP_URL);
+ final ResponseEntity<Void> genericVnfRelationShipResponse =
+ invokeHttpPut(genericVnfRelationShipUrl, TestUtils.getPlatformRelatedLink());
+
+ assertEquals(HttpStatus.ACCEPTED, genericVnfRelationShipResponse.getStatusCode());
+
+ final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
+ assertTrue(genericVnfOptional.isPresent());
+ final GenericVnf actualGenericVnf = genericVnfOptional.get();
+ final RelationshipList relationshipList = actualGenericVnf.getRelationshipList();
+ assertNotNull(relationshipList);
+ assertFalse(relationshipList.getRelationship().isEmpty());
+
+ final Relationship relationship = relationshipList.getRelationship().get(0);
+
+ assertEquals(Constants.USES, relationship.getRelationshipLabel());
+ assertFalse(relationship.getRelationshipData().isEmpty());
+ assertEquals(1, relationship.getRelationshipData().size());
+
+ final List<RelationshipData> relationshipData = relationship.getRelationshipData();
+
+ final RelationshipData platformRelationshipData =
+ getRelationshipData(relationshipData, Constants.PLATFORM_PLATFORM_NAME);
+ assertNotNull(platformRelationshipData);
+ assertEquals(PLATFORM_NAME, platformRelationshipData.getRelationshipValue());
+
+ }
+
+ private void addCustomerServiceAndGenericVnf() throws Exception, IOException {
+ final ResponseEntity<Void> customerResponse = invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer());
+ assertEquals(HttpStatus.ACCEPTED, customerResponse.getStatusCode());
+
+ final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
+ final ResponseEntity<Void> serviceInstanceResponse =
+ invokeHttpPut(serviceInstanceUrl, TestUtils.getServiceInstance());
+ assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
+
+ final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
+ final ResponseEntity<Void> genericVnfResponse = invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf());
+ assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
+
+ }
+
private RelationshipData getRelationshipData(final List<RelationshipData> relationshipData, final String key) {
return relationshipData.stream().filter(data -> data.getRelationshipKey().equals(key)).findFirst().orElse(null);
}
@@ -215,28 +263,7 @@ public class GenericVnfsControllerTest {
}
private String getUrl(final String... urls) {
- final UriComponentsBuilder baseUri = UriComponentsBuilder.fromUriString("https://localhost:" + port);
- for (final String url : urls) {
- baseUri.path(url);
-
- }
- return baseUri.toUriString();
- }
-
- private String getCustomer() throws IOException {
- return getJsonString("test-data/business-customer.json");
- }
-
- private String getServiceInstance() throws IOException {
- return getJsonString("test-data/service-instance.json");
- }
-
- private String getGenericVnf() throws IOException {
- return getJsonString("test-data/generic-vnf.json");
- }
-
- private String getRelationShip() throws IOException {
- return getJsonString("test-data/relation-ship.json");
+ return TestUtils.getUrl(port, urls);
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
index e67d0987..fb9a1148 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
@@ -23,20 +23,26 @@ 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.NODES_URL;
import static org.onap.so.aaisimulator.utils.Constants.RESOURCE_LINK;
import static org.onap.so.aaisimulator.utils.Constants.RESOURCE_TYPE;
import static org.onap.so.aaisimulator.utils.Constants.SERVICE_RESOURCE_TYPE;
import static org.onap.so.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNFS_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.SERVICE_INSTANCE_ID;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
-import static org.onap.so.aaisimulator.utils.TestUtils.getJsonString;
+import static org.onap.so.aaisimulator.utils.TestConstants.VNF_ID;
import java.io.IOException;
import java.util.Map;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.aaisimulator.models.Format;
import org.onap.so.aaisimulator.models.Results;
@@ -94,17 +100,10 @@ public class NodesControllerTest {
public void test_getNodesSericeInstance_usingServiceInstanceId_ableToRetrieveServiceInstanceFromCache()
throws Exception {
- final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
-
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
-
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- final ResponseEntity<Void> response2 = invokeHttpPut(url, getServiceInstance());
- assertEquals(HttpStatus.ACCEPTED, response2.getStatusCode());
+ invokeCustomerandServiceInstanceUrls();
final ResponseEntity<ServiceInstance> actual =
- restTemplate.exchange(getNodesEndPointUrl() + SERVICE_INSTANCE_URL, HttpMethod.GET,
+ restTemplate.exchange(getUrl(Constants.NODES_URL, SERVICE_INSTANCE_URL), HttpMethod.GET,
new HttpEntity<>(getHttpHeaders()), ServiceInstance.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
@@ -121,18 +120,11 @@ public class NodesControllerTest {
public void test_getNodesSericeInstance_usingServiceInstanceIdAndFormatPathed_ableToRetrieveServiceInstanceFromCache()
throws Exception {
- final String url = getCustomerEndPointUrl() + SERVICE_SUBSCRIPTIONS_URL + SERVICE_INSTANCE_URL;
-
- final ResponseEntity<Void> response = invokeHttpPut(getCustomerEndPointUrl(), getCustomer());
-
- assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
-
- final ResponseEntity<Void> response2 = invokeHttpPut(url, getServiceInstance());
- assertEquals(HttpStatus.ACCEPTED, response2.getStatusCode());
+ invokeCustomerandServiceInstanceUrls();
final ResponseEntity<Results> actual = restTemplate.exchange(
- getNodesEndPointUrl() + SERVICE_INSTANCE_URL + "?format=" + Format.PATHED.getValue(), HttpMethod.GET,
- new HttpEntity<>(getHttpHeaders()), Results.class);
+ getUrl(Constants.NODES_URL, SERVICE_INSTANCE_URL) + "?format=" + Format.PATHED.getValue(),
+ HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), Results.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
@@ -148,21 +140,43 @@ public class NodesControllerTest {
}
- private String getNodesEndPointUrl() {
- return TestUtils.getBaseUrl(port) + Constants.NODES_URL;
- }
+ @Test
+ public void test_getNodesGenericVnfs_usingVnfName_ableToRetrieveItFromCache() throws Exception {
+ invokeCustomerandServiceInstanceUrls();
+ final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
+ final ResponseEntity<Void> genericVnfResponse = invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf());
+ assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
+
+ final String nodeGenericVnfsUrl = getUrl(NODES_URL, GENERIC_VNFS_URL) + "?vnf-name=" + GENERIC_VNF_NAME;
+ final ResponseEntity<GenericVnfs> actual = restTemplate.exchange(nodeGenericVnfsUrl, HttpMethod.GET,
+ new HttpEntity<>(getHttpHeaders()), GenericVnfs.class);
+
+ assertEquals(HttpStatus.OK, actual.getStatusCode());
+ assertTrue(actual.hasBody());
+
+ final GenericVnfs genericVnfs = actual.getBody();
+ assertEquals(1, genericVnfs.getGenericVnf().size());
+
+ final GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0);
+ assertEquals(GENERIC_VNF_NAME, genericVnf.getVnfName());
+ assertEquals(VNF_ID, genericVnf.getVnfId());
- private String getCustomerEndPointUrl() {
- return TestUtils.getBaseUrl(port) + CUSTOMERS_URL;
}
- private String getCustomer() throws Exception, IOException {
- return getJsonString("test-data/business-customer.json");
+ private void invokeCustomerandServiceInstanceUrls() throws Exception, IOException {
+ final String url = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
+
+ final ResponseEntity<Void> response = invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer());
+
+ assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
+
+ final ResponseEntity<Void> response2 = invokeHttpPut(url, TestUtils.getServiceInstance());
+ assertEquals(HttpStatus.ACCEPTED, response2.getStatusCode());
}
- private String getServiceInstance() throws Exception, IOException {
- return getJsonString("test-data/service-instance.json");
+ private String getUrl(final String... urls) {
+ return TestUtils.getUrl(port, urls);
}
private ResponseEntity<Void> invokeHttpPut(final String url, final Object obj) {
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
new file mode 100644
index 00000000..cb704795
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/PlatformControllerTest.java
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aaisimulator.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.domain.yang.Platform;
+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.PlatformCacheServiceProvider;
+import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.aaisimulator.utils.TestConstants;
+import org.onap.so.aaisimulator.utils.TestUtils;
+import org.onap.so.simulator.model.UserCredentials;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ActiveProfiles("test")
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@Configuration
+public class PlatformControllerTest {
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Autowired
+ private UserCredentials userCredentials;
+
+ @Autowired
+ private PlatformCacheServiceProvider platformCacheServiceProvider;
+
+
+ @After
+ public void after() {
+ platformCacheServiceProvider.clearAll();
+ }
+
+ @Test
+ public void test_putPlatform_successfullyAddedToCache() throws Exception {
+
+ final String platformUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME);
+ final ResponseEntity<Void> platformResponse = invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
+
+ final ResponseEntity<Platform> response = invokeHttpGet(platformUrl, Platform.class);
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+
+ assertTrue(response.hasBody());
+
+ final Platform actualPlatform = response.getBody();
+ assertEquals(PLATFORM_NAME, actualPlatform.getPlatformName());
+ assertNotNull("resource version should not be null", actualPlatform.getResourceVersion());
+
+ }
+
+ @Test
+ public void test_putGenericVnfRelationShipToPlatform_successfullyAddedToCache() throws Exception {
+
+ final String platformUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME);
+ final ResponseEntity<Void> platformResponse = invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
+
+ final String platformRelationShipUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME, RELATIONSHIP_URL);
+
+ final ResponseEntity<Relationship> responseEntity =
+ invokeHttpPut(platformRelationShipUrl, TestUtils.getPlatformRelationShip(), Relationship.class);
+ assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
+
+ final Optional<Platform> optional = platformCacheServiceProvider.getPlatform(PLATFORM_NAME);
+ assertTrue(optional.isPresent());
+
+ final Platform actual = optional.get();
+
+ assertNotNull(actual.getRelationshipList());
+ final List<Relationship> relationshipList = actual.getRelationshipList().getRelationship();
+ assertFalse("Relationship list should not be empty", relationshipList.isEmpty());
+ final Relationship relationship = relationshipList.get(0);
+
+ assertFalse("RelationshipData list should not be empty", relationship.getRelationshipData().isEmpty());
+ assertFalse("RelatedToProperty list should not be empty", relationship.getRelatedToProperty().isEmpty());
+
+ final RelationshipData relationshipData = relationship.getRelationshipData().get(0);
+ assertEquals(Constants.GENERIC_VNF_VNF_ID, relationshipData.getRelationshipKey());
+ assertEquals(TestConstants.VNF_ID, relationshipData.getRelationshipValue());
+
+ final RelatedToProperty relatedToProperty = relationship.getRelatedToProperty().get(0);
+ assertEquals(Constants.GENERIC_VNF_VNF_NAME, relatedToProperty.getPropertyKey());
+ assertEquals(TestConstants.GENERIC_VNF_NAME, relatedToProperty.getPropertyValue());
+
+ }
+
+ private <T> ResponseEntity<T> invokeHttpGet(final String url, final Class<T> clazz) {
+ return restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), clazz);
+ }
+
+ private <T> ResponseEntity<T> invokeHttpPut(final String url, final Object obj, final Class<T> clazz) {
+ final HttpEntity<?> httpEntity = getHttpEntity(obj);
+ return restTemplate.exchange(url, HttpMethod.PUT, httpEntity, clazz);
+ }
+
+ private HttpEntity<?> getHttpEntity(final Object obj) {
+ return new HttpEntity<>(obj, getHttpHeaders());
+ }
+
+ private HttpHeaders getHttpHeaders() {
+ return TestUtils.getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername());
+ }
+
+ private String getUrl(final String... urls) {
+ return TestUtils.getUrl(port, urls);
+ }
+
+}
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 ed2c9e66..5bb759fc 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
@@ -53,7 +53,11 @@ public class TestConstants {
public static final String GENERIC_VNF_URL = Constants.GENERIC_VNFS_URL + "/generic-vnf/";
- public static final String RELATED_TO_URL = "/related-to/generic-vnfs";
+ public static final String GENERIC_VNFS_URL = "/generic-vnfs";
+
+ public static final String RELATED_TO_URL = "/related-to" + GENERIC_VNFS_URL;
+
+ public static final String PLATFORM_NAME = "PLATFORM_APP_ID_1";
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 4dfe9c2c..880e7995 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
@@ -26,6 +26,7 @@ import java.util.Base64;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
+import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
@@ -67,6 +68,43 @@ public class TestUtils {
return "https://localhost:" + port;
}
+ public static String getCustomer() throws Exception, IOException {
+ return getJsonString("test-data/business-customer.json");
+ }
+
+ public static String getServiceInstance() throws IOException {
+ return getJsonString("test-data/service-instance.json");
+ }
+
+ public static String getGenericVnf() throws IOException {
+ return getJsonString("test-data/generic-vnf.json");
+ }
+
+ public static String getRelationShip() throws IOException {
+ return getJsonString("test-data/relation-ship.json");
+ }
+
+ public static String getPlatformRelatedLink() throws IOException {
+ return getJsonString("test-data/platform-related-link.json");
+ }
+
+ public static String getPlatform() throws IOException {
+ return getJsonString("test-data/platform.json");
+ }
+
+ public static String getPlatformRelationShip() throws IOException {
+ return getJsonString("test-data/platform-relationship.json");
+ }
+
+ public static String getUrl(final int port, final String... urls) {
+ final UriComponentsBuilder baseUri = UriComponentsBuilder.fromUriString("https://localhost:" + port);
+ for (final String url : urls) {
+ baseUri.path(url);
+
+ }
+ return baseUri.toUriString();
+ }
+
private TestUtils() {}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-related-link.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-related-link.json
new file mode 100644
index 00000000..6e0de8ec
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-related-link.json
@@ -0,0 +1,3 @@
+{
+ "related-link": "/business/platforms/platform/PLATFORM_APP_ID_1"
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-relationship.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-relationship.json
new file mode 100644
index 00000000..a53ffa9c
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform-relationship.json
@@ -0,0 +1,13 @@
+{
+ "related-to": "generic-vnf",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/network/generic-vnfs/generic-vnf/dfd02fb5-d7fb-4aac-b3c4-cd6b60058701",
+ "relationship-data": [{
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "dfd02fb5-d7fb-4aac-b3c4-cd6b60058701"
+ }],
+ "related-to-property": [{
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "EsyVnfInstantiationTest2"
+ }]
+} \ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform.json b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform.json
new file mode 100644
index 00000000..d94f2f02
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/resources/test-data/platform.json
@@ -0,0 +1,3 @@
+{
+ "platform-name": "PLATFORM_APP_ID_1"
+}