aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-09-25 15:29:13 +0100
committerwaqas.ikram <waqas.ikram@est.tech>2019-09-25 15:29:15 +0100
commita65d54b00ff1e316e0f81fd0107b73f9d1d8aa88 (patch)
tree9cda88df7f7e273ec9f38445b1cce8f343242ead /plans/so/integration-etsi-testing
parenta1f84a15cf98925a334062bfd912c9097c1b5be5 (diff)
Adding required update to aai-simulator for SO-2352
Change-Id: I44f31612095b90796c00f32ee5da1906a9ce0438 Issue-ID: INT-1274 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/config/override-files/sdc-controller/onapheat/override.yaml2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java34
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java63
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java10
-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/test/java/org/onap/so/aaisimulator/controller/CloudRegionsControllerTest.java2
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java89
8 files changed, 199 insertions, 10 deletions
diff --git a/plans/so/integration-etsi-testing/config/override-files/sdc-controller/onapheat/override.yaml b/plans/so/integration-etsi-testing/config/override-files/sdc-controller/onapheat/override.yaml
index 6c8e5941..ed8bd43f 100644
--- a/plans/so/integration-etsi-testing/config/override-files/sdc-controller/onapheat/override.yaml
+++ b/plans/so/integration-etsi-testing/config/override-files/sdc-controller/onapheat/override.yaml
@@ -66,7 +66,7 @@ mso:
activateServerTLSAuth: false
keyStorePassword:
keyStorePath:
- watchDogTimeout: 300
+ watchDogTimeout: 100
isFitlerInEmptyResources: true
messageBusAddress: vm1.mr.simpledemo.onap.org,vm1.mr.simpledemo.onap.org
asdc:
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java
index b356006c..297c2eb0 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrController.java
@@ -23,6 +23,8 @@ import static org.onap.so.aaisimulator.utils.Constants.ESR_SYSTEM_INFO;
import static org.onap.so.aaisimulator.utils.Constants.ESR_SYSTEM_INFO_LIST;
import static org.onap.so.aaisimulator.utils.Constants.ESR_VNFM;
import static org.onap.so.aaisimulator.utils.Constants.EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL;
+import static org.onap.so.aaisimulator.utils.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.List;
@@ -33,10 +35,14 @@ import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.EsrVnfmList;
+import org.onap.aai.domain.yang.Relationship;
import org.onap.so.aaisimulator.service.providers.ExternalSystemCacheServiceProvider;
+import org.onap.so.aaisimulator.utils.HttpServiceUtils;
+import org.onap.so.aaisimulator.utils.RequestErrorResponseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@@ -44,6 +50,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;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -77,8 +84,8 @@ public class ExternalSystemEsrController {
@GetMapping(value = "/esr-vnfm/{vnfm-id}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getEsrVnfm(@PathVariable("vnfm-id") final String vnfmId,
- final HttpServletRequest request) {
- LOGGER.info("Will retrieve ESR VNFM for 'vnfm id': {} ...", vnfmId);
+ @RequestParam(name = "depth", required = false) final Integer depth, final HttpServletRequest request) {
+ LOGGER.info("Will retrieve ESR VNFM for 'vnfm id': {} with depth: {}...", vnfmId, depth);
final Optional<EsrVnfm> optional = cacheServiceProvider.getEsrVnfm(vnfmId);
if (optional.isPresent()) {
@@ -87,7 +94,7 @@ public class ExternalSystemEsrController {
return ResponseEntity.ok(esrVnfm);
}
- LOGGER.error("Couldn't Esr Vnfm for 'vnfm id': {} ...", vnfmId);
+ LOGGER.error("Couldn't Esr Vnfm for 'vnfm id': {} with depth: {}...", vnfmId, depth);
return getRequestErrorResponseEntity(request, ESR_VNFM);
}
@@ -144,4 +151,25 @@ public class ExternalSystemEsrController {
return getRequestErrorResponseEntity(request, ESR_SYSTEM_INFO);
}
+ @PutMapping(value = "/esr-vnfm/{vnfm-id}" + RELATIONSHIP_LIST_RELATIONSHIP_URL,
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> putEsrVnfmRelationShip(@RequestBody final Relationship relationship,
+ @PathVariable("vnfm-id") final String vnfmId, final HttpServletRequest request) {
+ LOGGER.info("Will put RelationShip for 'vnfm-id': {} ...", vnfmId);
+
+ 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(), vnfmId, relationship);
+ if (result) {
+ LOGGER.info("added created bi directional relationship with {}", relationship.getRelatedLink());
+ return ResponseEntity.accepted().build();
+ }
+ }
+ LOGGER.error("Unable to add relationship for related link: {}", relationship.getRelatedLink());
+ return RequestErrorResponseUtils.getRequestErrorResponseEntity(request, ESR_VNFM);
+ }
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java
index 5589ff43..b1f90215 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProvider.java
@@ -24,6 +24,8 @@ import java.util.Optional;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
+import org.onap.aai.domain.yang.Relationship;
+import org.springframework.http.HttpHeaders;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -40,4 +42,7 @@ public interface ExternalSystemCacheServiceProvider extends Clearable {
Optional<EsrSystemInfoList> getEsrSystemInfoList(final String vnfmId);
boolean putEsrSystemInfo(final String vnfmId, final String esrSystemInfoId, final EsrSystemInfo esrSystemInfo);
+
+ boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl, final String requestURI,
+ final String vnfmId, Relationship relationship);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java
index 3c44bed4..b5b1da0f 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ExternalSystemCacheServiceProviderImpl.java
@@ -20,6 +20,11 @@
package org.onap.so.aaisimulator.service.providers;
import static org.onap.so.aaisimulator.utils.CacheName.ESR_VNFM_CACHE;
+import static org.onap.so.aaisimulator.utils.Constants.DEPENDS_ON;
+import static org.onap.so.aaisimulator.utils.Constants.ESR_VNFM;
+import static org.onap.so.aaisimulator.utils.Constants.ESR_VNFM_VNFM_ID;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getRelationShipListRelatedLink;
+import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -28,12 +33,16 @@ import java.util.concurrent.ConcurrentHashMap;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
+import org.onap.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.http.HttpHeaders;
import org.springframework.stereotype.Service;
/**
@@ -46,9 +55,14 @@ public class ExternalSystemCacheServiceProviderImpl extends AbstractCacheService
private static final Logger LOGGER = LoggerFactory.getLogger(ExternalSystemCacheServiceProviderImpl.class);
+ private final HttpRestServiceProvider httpRestServiceProvider;
+
@Autowired
- public ExternalSystemCacheServiceProviderImpl(final CacheManager cacheManager) {
+ public ExternalSystemCacheServiceProviderImpl(final CacheManager cacheManager,
+ final HttpRestServiceProvider httpRestServiceProvider) {
super(cacheManager);
+ this.httpRestServiceProvider = httpRestServiceProvider;
+
}
@Override
@@ -130,6 +144,53 @@ public class ExternalSystemCacheServiceProviderImpl extends AbstractCacheService
return false;
}
+ @Override
+ public boolean addRelationShip(final HttpHeaders incomingHeader, final String targetBaseUrl,
+ final String requestUriString, final String vnfmId, final Relationship relationship) {
+ try {
+ final Optional<EsrVnfm> optional = getEsrVnfm(vnfmId);
+ if (optional.isPresent()) {
+ final EsrVnfm esrVnfm = optional.get();
+ final String targetUrl = getTargetUrl(targetBaseUrl, relationship.getRelatedLink());
+ final Relationship outGoingRelationShip =
+ getRelationship(getRelationShipListRelatedLink(requestUriString), esrVnfm);
+ final Optional<Relationship> optionalRelationship = httpRestServiceProvider.put(incomingHeader,
+ outGoingRelationShip, targetUrl, Relationship.class);
+ if (optionalRelationship.isPresent()) {
+ final Relationship resultantRelationship = optionalRelationship.get();
+
+ RelationshipList relationshipList = esrVnfm.getRelationshipList();
+ if (relationshipList == null) {
+ relationshipList = new RelationshipList();
+ esrVnfm.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 vnfmId: {}", vnfmId, exception);
+ }
+ LOGGER.error("Unable to add relationship in cache for vnfmId: {}", vnfmId);
+ return false;
+ }
+
+ private Relationship getRelationship(final String relatedLink, final EsrVnfm esrVnfm) {
+ final Relationship relationShip = new Relationship();
+ relationShip.setRelatedTo(ESR_VNFM);
+ relationShip.setRelationshipLabel(DEPENDS_ON);
+ relationShip.setRelatedLink(relatedLink);
+
+ final RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey(ESR_VNFM_VNFM_ID);
+ relationshipData.setRelationshipValue(esrVnfm.getVnfmId());
+ relationShip.getRelationshipData().add(relationshipData);
+
+ return relationShip;
+ }
+
private List<EsrSystemInfo> getEsrSystemInfoList(final EsrVnfm esrVnfm) {
EsrSystemInfoList esrSystemInfoList = esrVnfm.getEsrSystemInfoList();
if (esrSystemInfoList == null) {
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 3a12dfdc..e7a42106 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
@@ -121,7 +121,7 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
final GenericVnf genericVnf = optional.get();
final String targetUrl = getTargetUrl(targetBaseUrl, relationship.getRelatedLink());
final Relationship outGoingRelationShip =
- getRelationship(getRelationShipListRelatedLink(requestUriString), genericVnf);
+ getRelationship(getRelationShipListRelatedLink(requestUriString), genericVnf, COMPOSED_OF);
final Optional<Relationship> optionalRelationship = httpRestServiceProvider.put(incomingHeader,
outGoingRelationShip, targetUrl, Relationship.class);
if (optionalRelationship.isPresent()) {
@@ -160,7 +160,8 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
LOGGER.info("Successfully added relation to GenericVnf for vnfId: {}", vnfId);
final String relatedLink = getBiDirectionalRelationShipListRelatedLink(requestURI);
- final Relationship resultantRelationship = getRelationship(relatedLink, genericVnf);
+ final Relationship resultantRelationship =
+ getRelationship(relatedLink, genericVnf, relationship.getRelationshipLabel());
return Optional.of(resultantRelationship);
}
return Optional.empty();
@@ -230,10 +231,11 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv
return false;
}
- private Relationship getRelationship(final String relatedLink, final GenericVnf genericVnf) {
+ private Relationship getRelationship(final String relatedLink, final GenericVnf genericVnf,
+ final String relationshipLabel) {
final Relationship relationShip = new Relationship();
relationShip.setRelatedTo(GENERIC_VNF);
- relationShip.setRelationshipLabel(COMPOSED_OF);
+ relationShip.setRelationshipLabel(relationshipLabel);
relationShip.setRelatedLink(relatedLink);
final RelationshipData relationshipData = new RelationshipData();
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 48735309..297f4525 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
@@ -130,6 +130,10 @@ public class Constants {
public static final String ESR_SYSTEM_INFO_LIST = "esr-system-info-list";
+ public static final String ESR_VNFM_VNFM_ID = "esr-vnfm.vnfm-id";
+
+ public static final String DEPENDS_ON = "tosca.relationships.DependsOn";
+
public static final String VSERVER_VSERVER_NAME = "vserver.vserver-name";
public static final String VSERVER_VSERVER_ID = "vserver.vserver-id";
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 334a0ebb..f8e7bf74 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
@@ -228,7 +228,7 @@ public class CloudRegionsControllerTest extends AbstractSpringBootTest {
final Relationship relationship = relationshipList.getRelationship().get(0);
- assertEquals(Constants.COMPOSED_OF, relationship.getRelationshipLabel());
+ assertEquals(Constants.BELONGS_TO, relationship.getRelationshipLabel());
assertFalse(relationship.getRelationshipData().isEmpty());
assertEquals(1, relationship.getRelationshipData().size());
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java
index 874fab16..fe656dda 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ExternalSystemEsrControllerTest.java
@@ -20,9 +20,12 @@
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.Constants.EXTERNAL_SYSTEM_ESR_VNFM_LIST_URL;
+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.ESR_PASSWORD;
import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SERVICE_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.ESR_SYSTEM_INFO_ID;
@@ -34,16 +37,27 @@ import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VENDOR;
import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VIM_ID;
import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VNFM_ID;
import static org.onap.so.aaisimulator.utils.TestConstants.ESR_VNFM_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_INSTANCE_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.SERVICE_SUBSCRIPTIONS_URL;
import static org.onap.so.aaisimulator.utils.TestConstants.SYSTEM_NAME;
+import static org.onap.so.aaisimulator.utils.TestConstants.VNF_ID;
import java.io.IOException;
import java.util.List;
+import java.util.Optional;
import org.junit.After;
import org.junit.Test;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.EsrVnfmList;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
+import org.onap.aai.domain.yang.RelationshipList;
import org.onap.so.aaisimulator.service.providers.ExternalSystemCacheServiceProvider;
+import org.onap.so.aaisimulator.service.providers.GenericVnfCacheServiceProvider;
+import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -58,9 +72,14 @@ public class ExternalSystemEsrControllerTest extends AbstractSpringBootTest {
@Autowired
private ExternalSystemCacheServiceProvider externalSystemCacheServiceProvider;
+
+ @Autowired
+ private GenericVnfCacheServiceProvider genericVnfCacheServiceProvider;
+
@After
public void after() {
externalSystemCacheServiceProvider.clearAll();
+ genericVnfCacheServiceProvider.clearAll();
}
@Test
@@ -136,9 +155,79 @@ public class ExternalSystemEsrControllerTest extends AbstractSpringBootTest {
}
+ @Test
+ public void test_putEsrRelationToGenericVnfm_successfullyAddedToCache() throws Exception {
+ final String esrVnfmUrl = getUrl(ESR_VNFM_URL, ESR_VNFM_ID);
+
+ addEsrVnfmAndAssertResponse(esrVnfmUrl);
+ addCustomerServiceAndGenericVnf();
+
+ final String relationShipUrl = esrVnfmUrl + RELATIONSHIP_LIST_RELATIONSHIP_URL;
+
+ final ResponseEntity<Void> response = testRestTemplateService.invokeHttpPut(relationShipUrl,
+ TestUtils.getGenericVnfRelatedLink(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
+
+ final Optional<EsrVnfm> optional = externalSystemCacheServiceProvider.getEsrVnfm(ESR_VNFM_ID);
+ assertTrue(optional.isPresent());
+
+ final EsrVnfm actualEsrVnfm = optional.get();
+ final RelationshipList relationshipList = actualEsrVnfm.getRelationshipList();
+ assertNotNull(relationshipList);
+ assertFalse(relationshipList.getRelationship().isEmpty());
+
+ final Relationship relationship = relationshipList.getRelationship().get(0);
+
+ assertEquals(Constants.DEPENDS_ON, relationship.getRelationshipLabel());
+ assertFalse(relationship.getRelationshipData().isEmpty());
+ assertEquals(1, relationship.getRelationshipData().size());
+
+ final RelationshipData relationshipData =
+ getRelationshipData(relationship.getRelationshipData(), Constants.GENERIC_VNF_VNF_ID);
+ assertNotNull(relationshipData);
+ assertEquals(VNF_ID, relationshipData.getRelationshipValue());
+
+ final Optional<GenericVnf> genericVnfOptional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
+ assertTrue(genericVnfOptional.isPresent());
+ final GenericVnf actualGenericVnf = genericVnfOptional.get();
+ final RelationshipList relationshipListGenericVnf = actualGenericVnf.getRelationshipList();
+ assertNotNull(relationshipListGenericVnf);
+ assertFalse(relationshipListGenericVnf.getRelationship().isEmpty());
+
+ final Relationship relationshipGenericVnf = relationshipListGenericVnf.getRelationship().get(0);
+
+ assertEquals(Constants.DEPENDS_ON, relationshipGenericVnf.getRelationshipLabel());
+ assertFalse(relationshipGenericVnf.getRelationshipData().isEmpty());
+ assertEquals(1, relationshipGenericVnf.getRelationshipData().size());
+
+ final RelationshipData esrRelationshipData =
+ getRelationshipData(relationshipGenericVnf.getRelationshipData(), Constants.ESR_VNFM_VNFM_ID);
+ assertNotNull(esrRelationshipData);
+ assertEquals(ESR_VNFM_ID, esrRelationshipData.getRelationshipValue());
+
+
+ }
+
private void addEsrVnfmAndAssertResponse(final String esrVnfmUrl) throws IOException {
final ResponseEntity<Void> esrVnfmResponse =
testRestTemplateService.invokeHttpPut(esrVnfmUrl, TestUtils.getEsrVnfm(), Void.class);
assertEquals(HttpStatus.ACCEPTED, esrVnfmResponse.getStatusCode());
}
+
+ private void addCustomerServiceAndGenericVnf() throws Exception, IOException {
+ final ResponseEntity<Void> customerResponse =
+ testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, customerResponse.getStatusCode());
+
+ final String serviceInstanceUrl = getUrl(CUSTOMERS_URL, SERVICE_SUBSCRIPTIONS_URL, SERVICE_INSTANCE_URL);
+ final ResponseEntity<Void> serviceInstanceResponse =
+ testRestTemplateService.invokeHttpPut(serviceInstanceUrl, TestUtils.getServiceInstance(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, serviceInstanceResponse.getStatusCode());
+
+ final String genericVnfUrl = getUrl(GENERIC_VNF_URL, VNF_ID);
+ final ResponseEntity<Void> genericVnfResponse =
+ testRestTemplateService.invokeHttpPut(genericVnfUrl, TestUtils.getGenericVnf(), Void.class);
+ assertEquals(HttpStatus.ACCEPTED, genericVnfResponse.getStatusCode());
+
+ }
}