aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
authoralexanb <alexander.borovitzky@guest.telecomitalia.it>2020-09-30 21:02:44 +0300
committeralexanb <alexander.borovitzky@guest.telecomitalia.it>2020-10-01 12:22:55 +0300
commit289aa8a1de4c0b0c32bfbe13c4da48dc5da64795 (patch)
tree9a09c523b8c22e280ab29e8ffa223f862542dbb8 /bpmn/so-bpmn-infrastructure-common/src
parentf2f9bec9aee2de5135226b24c70708a5df5ca525 (diff)
Use Allotted Resources in Deallocate and Modify flows
Issue-ID: SO-3280 Change-Id: I5c325cb45e3230fc7d7e2190233c6ee91b7175b6 Signed-off-by: alexanb <alexander.borovitzky@guest.telecomitalia.it>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy129
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy32
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy176
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy100
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy49
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy79
6 files changed, 420 insertions, 145 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
index 567725246e..646861a6a0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
@@ -246,11 +246,61 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
void getNSSIAssociatedProfiles(DelegateExecution execution) {
LOGGER.trace("${getPrefix()} Start getNSSIAssociatedProfiles")
+ List<SliceProfile> associatedProfiles = new ArrayList<>()
+
+ AAIResourcesClient client = getAAIClient()
+
def currentNSSI = execution.getVariable("currentNSSI")
ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
+ String nssiId = currentNSSI['nssiId']
+
+ // NSSI
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ AAIResultWrapper nssiWrapper = client.get(nssiUri)
+ Optional<Relationships> nssiRelationships = nssiWrapper.getRelationships()
+
+ if (nssiRelationships.isPresent()) {
+ // Allotted Resource
+ for (AAIResourceUri allottedResourceUri : nssiRelationships.get().getRelatedUris(Types.ALLOTTED_RESOURCE)) {
+ AAIResultWrapper arWrapper = client.get(allottedResourceUri)
+ Optional<Relationships> arRelationships = arWrapper.getRelationships()
+
+ boolean isFound = false
+ if(arRelationships.isPresent()) {
+ // Slice Profile Instance
+ for (AAIResourceUri sliceProfileInstanceUri : arRelationships.get().getRelatedUris(Types.SERVICE_INSTANCE)) {
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+ if(sliceProfileInstance.getServiceRole().equals("slice-profile-instance")) { // Service instance as a Slice Profile Instance
+ associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+
+ currentNSSI['sliceProfileInstanceUri'] = sliceProfileInstanceUri
+
+ isFound = true
+ break // Should be only one
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No Slice Profile Instance found")
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for Allotted Resource")
+ }
+
+ if(isFound) {
+ break
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for nssi id = " + nssiId)
+ }
if(associatedProfiles.isEmpty()) {
String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId())
@@ -587,13 +637,13 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param constituteVnf
* @return List<VfModules>
*/
- List<VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
+ List<org.onap.so.serviceinstancebeans.VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
AAIResourcesClient client = getAAIClient()
- List<VfModules> vfModuless = new ArrayList<>()
+ List<org.onap.so.serviceinstancebeans.VfModules> vfModuless = new ArrayList<>()
for (VfModule vfModule : constituteVnf.getVfModules().getVfModule()) {
- VfModules vfmodules = new VfModules()
+ org.onap.so.serviceinstancebeans.VfModules vfmodules = new org.onap.so.serviceinstancebeans.VfModules()
ModelInfo vfModuleModelInfo = new ModelInfo()
vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId())
@@ -703,7 +753,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
Vnfs vnf = new Vnfs()
// Line of Business
- LineOfBusiness lob = new LineOfBusiness()
+ org.onap.so.serviceinstancebeans.LineOfBusiness lob = new org.onap.so.serviceinstancebeans.LineOfBusiness()
lob.setLineOfBusinessName("VNF")
vnf.setLineOfBusiness(lob)
@@ -739,8 +789,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* Prepare Service
* @return Service
*/
- Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
- Service service = new Service()
+ org.onap.so.serviceinstancebeans.Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
+ org.onap.so.serviceinstancebeans.Service service = new org.onap.so.serviceinstancebeans.Service()
// Model Info
service.setModelInfo(prepareServiceModelInfo(networkServiceInstance, modelInfo))
@@ -793,21 +843,21 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
* @return OwningEntity
*/
- OwningEntity prepareOwningEntity(DelegateExecution execution) {
+ org.onap.so.serviceinstancebeans.OwningEntity prepareOwningEntity(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)currentNSSI['networkServiceInstanceUri']
- OwningEntity owningEntity = new OwningEntity()
+ org.onap.so.serviceinstancebeans.OwningEntity owningEntity = new org.onap.so.serviceinstancebeans.OwningEntity()
AAIResultWrapper wrapper = client.get(networkServiceInstanceUri)
Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships()
if (owningEntityRelationshipsOps.isPresent()) {
List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedUris(Types.OWNING_ENTITY)
if (!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) {
- Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
+ Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.v19.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
if (owningEntityOpt.isPresent()) {
owningEntity.setOwningEntityId(owningEntityOpt.get().getOwningEntityId())
owningEntity.setOwningEntityName(owningEntityOpt.get().getOwningEntityName())
@@ -825,12 +875,12 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
* @return Project
*/
- Project prepareProject(DelegateExecution execution) {
+ org.onap.so.serviceinstancebeans.Project prepareProject(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
- Project project = new Project()
+ org.onap.so.serviceinstancebeans.Project project = new org.onap.so.serviceinstancebeans.Project()
AAIResourceUri cloudRegionRelatedAAIUri = (AAIResourceUri)currentNSSI['cloudRegionRelatedAAIUri']
@@ -840,7 +890,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
if (cloudRegionOps.isPresent()) {
List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedUris(Types.PROJECT)
if (!(projectAAIUris == null || projectAAIUris.isEmpty())) {
- Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0))
+ Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.v19.Project.class, projectAAIUris.get(0))
if (projectOpt.isPresent()) {
project.setProjectName(projectOpt.get().getProjectName())
}
@@ -950,23 +1000,49 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
def currentNSSI = execution.getVariable("currentNSSI")
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
-
String nssiId = currentNSSI['nssiId']
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
+ AAIResourceUri sliceProfileInstanceUri = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
- String currentSNSSAI = currentNSSI['S-NSSAI']
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+
+ List<SliceProfile> associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+
+ String currentSNSSAI = currentNSSI['S-NSSAI']
+
+ if(!(associatedProfiles == null || associatedProfiles.isEmpty())) {
+ // Removes slice profile which contains given S-NSSAI and updates Slice Profile Instance
+ associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+
+ try {
+ client.update(sliceProfileInstanceUri, sliceProfileInstance)
+
+ currentNSSI['sliceProfileInstance'] = sliceProfileInstance
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profiles found")
+ }
- associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found")
+ }
+ // Removes SLice Profile Instance association with NSSI
try {
- getAAIClient().update(nssiUri, nssi)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ client.disconnect(nssiUri, sliceProfileInstanceUri)
+ }
+ catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance association with NSSI dosconnect call: " + e.getMessage())
}
+
LOGGER.trace("${getPrefix()} Exit removeSPAssociationWithNSSI")
}
@@ -982,17 +1058,10 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
def currentNSSI = execution.getVariable("currentNSSI")
- SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI['sliceProfileS-NSSAI']
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String nssiId = currentNSSI['nssiId']
-
- // global-customer-id, service-type, service-instance-id, profile-id
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId()))
+ AAIResourceUri sliceProfileInstanceURI = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
try {
- client.delete(sliceProfileUri)
+ client.delete(sliceProfileInstanceURI)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
index 055cbfc9cc..fe881eb888 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
@@ -22,10 +22,14 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.v19.AllottedResource
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aaiclient.client.aai.AAIResourcesClient
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.Relationships
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -299,12 +303,38 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
String nssiId = currentNSSI['nssiId']
String nsiId = currentNSSI['nsiId']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ // NSSI
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ ServiceInstance nssi = currentNSSI['nssi']
+
+ String allottedResourceId = null
+
+ // Removes Allotted resource
+ List<AllottedResource> allottedResources = nssi.getAllottedResources()?.getAllottedResource()
+ if(allottedResources != null && allottedResources.size() == 1) { // Shouldn contain one allotted resource
+ allottedResourceId = allottedResources.get(0).getId()
+ allottedResources.remove(0)
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No allotted resource found for NSSI id = " + nssiId)
+ }
+
+ try {
+ client.update(nssiUri, nssi)
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage())
+ }
+
+
+ // Remove association between NSI and Allotted Resource
AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId))
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResourceId))
try {
- client.disconnect(nssiUri, nsiUri)
+ client.disconnect(nsiUri, allottedResourceUri)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
index 4ccea61ed4..ff16184f02 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
@@ -22,8 +22,11 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.v19.AllottedResource
+import org.onap.aai.domain.yang.v19.AllottedResources
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aai.domain.yang.v19.SliceProfile
+import org.onap.aai.domain.yang.v19.SliceProfiles
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
@@ -37,6 +40,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import static org.apache.commons.lang3.StringUtils.isAllLowerCase
import static org.apache.commons.lang3.StringUtils.isBlank
class DoModifyCoreNSSI extends DoCommonCoreNSSI {
@@ -51,22 +55,18 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class)
+
/**
- * Creates Slice Profile Instance
+ * Prepares Slice Profile
* @param execution
+ * @return SLice Profile
*/
- void createSliceProfileInstance(DelegateExecution execution) {
- LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
-
+ SliceProfile prepareSliceProfile(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
String sliceProfileID = currentNSSI['sliceProfileId']
Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class)
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String nssiId = currentNSSI['nssiId']
-
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setServiceAreaDimension("")
sliceProfile.setPayloadSize(0)
@@ -112,14 +112,80 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
sliceProfile.setProfileId(sliceProfileID)
sliceProfile.setE2ELatency(0)
+ return sliceProfile
+ }
+
+
+ /**
+ * Prepares Slice Profile Instance
+ * @param execution
+ * @return Slice Profile Instance
+ */
+ ServiceInstance prepareSliceProfileInstance(DelegateExecution execution) {
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ String sliceProfileInstanceId = UUID.randomUUID().toString()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+
+
+ String sliceInstanceName = "sliceprofile_" + sliceProfileInstanceId
+ sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
+
+ String serviceType = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "sST")
+ sliceProfileInstance.setServiceType(serviceType)
+
+ String serviceStatus = "deactivated"
+ sliceProfileInstance.setOrchestrationStatus(serviceStatus)
+
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "plmnIdList")
+ sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
+
+ String serviceRole = "slice-profile-instance"
+ sliceProfileInstance.setServiceRole(serviceRole)
+ List<String> snssaiList = (List<String>)currentNSSI['S-NSSAIs']
+ String snssai = snssaiList.get(0)
+
+ sliceProfileInstance.setEnvironmentContext(snssai)
+ sliceProfileInstance.setWorkloadContext("CN-NF")
+
+ // TO DO: Model info
+
+ return sliceProfileInstance
+ }
+
+
+
+ /**
+ * Creates Slice Profile Instance
+ * @param execution
+ */
+ void createSliceProfileInstance(DelegateExecution execution) {
+ LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ SliceProfile sliceProfile = prepareSliceProfile(execution)
+
+ ServiceInstance sliceProfileInstance = prepareSliceProfileInstance(execution)
+
+ SliceProfiles sliceProfiles = new SliceProfiles()
+ sliceProfiles.getSliceProfile().add(sliceProfile)
+ sliceProfileInstance.setSliceProfiles(sliceProfiles)
+
try {
AAIResourcesClient client = getAAIClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
- client.create(uri, sliceProfile)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).
+ serviceInstance(sliceProfileInstance.getServiceInstanceId()))
+ client.create(uri, sliceProfileInstance)
- currentNSSI['createdSliceProfile'] = sliceProfile
+ currentNSSI['createdSliceProfileInstanceId'] = sliceProfileInstance.getServiceInstanceId()
} catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Slice Profile create call:" + ex.getMessage())
}
LOGGER.trace("${PREFIX} Exit createSliceProfileInstance")
@@ -127,6 +193,42 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
/**
+ * Creates Allotted Resource
+ * @param execution
+ * @return AllottedResource
+ */
+ AllottedResource createAllottedResource(DelegateExecution execution) {
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId']
+
+ AllottedResource allottedResource = new AllottedResource()
+
+ String allottedResourceId = UUID.randomUUID().toString()
+
+ allottedResource.setId(allottedResourceId)
+
+ // TO DO: No other info
+
+ try {
+ AAIResourcesClient client = getAAIClient()
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId))
+
+ client.create(allottedResourceUri, allottedResource)
+
+ currentNSSI['allottedResourceUri'] = allottedResourceUri
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Allotted Resource create call:" + ex.getMessage())
+ }
+
+ return allottedResource
+ }
+
+
+
+ /**
* Creates Slice Profile association with NSSI
* @param execution
*/
@@ -135,26 +237,48 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
def currentNSSI = execution.getVariable("currentNSSI")
- String sliceProfileID = currentNSSI['sliceProfileId']
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
String nssiId = currentNSSI['nssiId']
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
+ String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId']
+ AAIResourcesClient client = getAAIClient()
+
+ // Creates Allotted Resource
+ AllottedResource allottedResource = createAllottedResource(execution)
+ AAIResourceUri allottedResourceUri = (AAIResourceUri)currentNSSI['allottedResourceUri']
+
+ // Updates Slice Profile Instance with Allotted Resource
try {
- SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
- associatedProfiles.add(createdSliceProfile)
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId))
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+
+ AllottedResources allottedResources = sliceProfileInstance.getAllottedResources()
+ if(allottedResources == null) {
+ allottedResources = new AllottedResources()
+ }
+
+ allottedResources.getAllottedResource().add(allottedResource)
+ sliceProfileInstance.setAllottedResources(allottedResources)
+
+ client.update(sliceProfileInstanceUri, sliceProfileInstance)
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found with id = " + sliceProfileInstanceId)
+ }
+
+ } catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance update call: " + e.getMessage())
+ }
- getAAIClient().update(nssiUri, nssi)
- getAAIClient().connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage())
+ // Associates NSSI with Allotted Resource
+ try {
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ client.connect(nssiUri, allottedResourceUri, AAIEdgeLabel.USES)
+ } catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI with Allotted Resource connect call: " + e.getMessage())
}
LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
index 6ca3937d68..9707dd2242 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
@@ -36,6 +36,7 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.T
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.serviceinstancebeans.RequestDetails
import javax.ws.rs.core.Response
@@ -185,8 +186,10 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ String nssiId = "5G-999"
ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
+ nssi.setServiceInstanceId(nssiId)
+ currentNSSI.put("nssiId", nssiId)
SliceProfiles sliceProfiles = new SliceProfiles()
@@ -194,13 +197,49 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
slProfiles.add(new SliceProfile())
slProfiles.add(new SliceProfile())
- nssi.setSliceProfiles(sliceProfiles)
+ //nssi.setSliceProfiles(sliceProfiles)
currentNSSI.put("nssi", nssi)
- DoCommonCoreNSSI obj = new DoCommonCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
+ DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
+ when(spy.getAAIClient()).thenReturn(client)
+
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
+ Relationships rsMock = mock(Relationships.class)
+ Optional<Relationships> orsMock = Optional.of(rsMock)
+ List<AAIResourceUri> allottedUris = new ArrayList<>()
+ AAIResourceUri allottedUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment("allotted-id"))
+ allottedUris.add(allottedUri)
+
+ when(client.get(nssiUri)).thenReturn(wrapperMock)
+ when(wrapperMock.getRelationships()).thenReturn(orsMock)
+ when(rsMock.getRelatedUris(Types.ALLOTTED_RESOURCE)).thenReturn(allottedUris)
+
+ String sliceProfileInstanceId = "slice-profile-instance-id"
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ sliceProfileInstance.setServiceRole("slice-profile-instance")
+
+ List<AAIResourceUri> sliceProfileInstanceUris = new ArrayList<>()
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstance.getServiceInstanceId()))
+ sliceProfileInstanceUris.add(sliceProfileInstanceUri)
+
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(allottedUri)).thenReturn(wrapperMock)
+ when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(sliceProfileInstanceUris)
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+
+
+ SliceProfiles sps = new SliceProfiles()
+ sps.getSliceProfile().addAll(slProfiles)
+ sliceProfileInstance.setSliceProfiles(sps)
+
+ spy.getNSSIAssociatedProfiles(mockExecution)
List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
+ assertTrue("sliceProfileInstanceUri not found in contect Map", currentNSSI.get("sliceProfileInstanceUri") != null)
assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
}
@@ -262,6 +301,20 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-subscriber-id").serviceSubscription("subscription-service-type").
+ serviceInstance("slice-profile-instance-id"))
+
+ String sliceProfileInstanceId = "slice-profile-instance-id"
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ sliceProfileInstance.setServiceRole("slice-profile-instance")
+
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+
+ currentNSSI.put("sliceProfileInstanceUri", sliceProfileInstanceUri)
+
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
@@ -284,13 +337,19 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
associatedProfiles.add(sliceProfile2)
associatedProfiles.add(sliceProfile3)
+ SliceProfiles sps = new SliceProfiles()
+ sps.getSliceProfile().addAll(associatedProfiles)
+ sliceProfileInstance.setSliceProfiles(sps)
+
int sizeBefore = associatedProfiles.size()
- doNothing().when(client).update(nssiUri, nssi)
+ doNothing().when(client).update(sliceProfileInstanceUri, sliceProfileInstance)
+
+ doNothing().when(client). disconnect(nssiUri, sliceProfileInstanceUri)
spy.removeSPAssociationWithNSSI(mockExecution)
- assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
+ assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("sliceProfileInstance")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
}
@@ -300,30 +359,16 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
- String globalSubscriberId = "global-id"
- String subscriptionServiceType = "subscription-service-type"
- String nssiId = "5G-999"
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-subscriber-id").serviceSubscription("subscription-service-type").
+ serviceInstance("slice-profile-instance-id"))
- when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
- when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
-
- currentNSSI.put("nssiId", nssiId)
-
- String theSNSSAI = "theS-NSSAI"
-
- SliceProfile sliceProfile = new SliceProfile()
- sliceProfile.setSNssai(theSNSSAI)
- sliceProfile.setProfileId("prof-id")
-
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
-
- currentNSSI.put("sliceProfileS-NSSAI", sliceProfile)
+ currentNSSI.put("sliceProfileInstanceUri", uri)
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
- doNothing().when(client).delete(nssiUri)
+ doNothing().when(client).delete(uri)
spy.deleteSliceProfileInstance(mockExecution)
@@ -426,8 +471,13 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
prepareProject(cloudRegionAAIUri)
- String requestDetails = spy.prepareRequestDetails(mockExecution)
+ String prepareRequestDetailsResponse = spy.prepareRequestDetails(mockExecution)
+
+ JsonUtils jsonUtil = new JsonUtils()
+ String errorCode = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorCode")
+ String errMsg = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorMessage")
+ assertTrue(errMsg, errorCode == null || errorCode.isEmpty())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
index c6e874591f..26b96a0a4a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
@@ -26,6 +26,7 @@ import org.mockito.Mockito
import org.onap.aai.domain.yang.v19.*
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
@@ -153,31 +154,6 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
@Test
- void testGetNSSIAssociatedProfiles() {
- def currentNSSI = [:]
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
-
- ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
-
- SliceProfiles sliceProfiles = new SliceProfiles()
-
- List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
- slProfiles.add(new SliceProfile())
- slProfiles.add(new SliceProfile())
-
- nssi.setSliceProfiles(sliceProfiles)
- currentNSSI.put("nssi", nssi)
-
- DoDeallocateCoreNSSI obj = new DoDeallocateCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
-
- List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
- assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
- }
-
-
- @Test
void testCalculateSNSSAI() {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
@@ -232,9 +208,30 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("nsiId", nsiId)
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId(nssiId)
+
+ AllottedResources allottedResources = new AllottedResources()
+ AllottedResource allottedResource = new AllottedResource()
+ allottedResource.setId(UUID.randomUUID().toString())
+ allottedResources.getAllottedResource().add(allottedResource)
+ nssi.setAllottedResources(allottedResources)
+
+ currentNSSI.put("nssi", nssi)
+
AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId))
- doNothing().when(client).disconnect(nssiUri, nsiUri)
+ doNothing().when(client).update(nssiUri, nssi)
+
+ String globalSubscriberId = "globalSubscriberId"
+ String subscriptionServiceType = "subscription-service-type"
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
+
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResource.getId()))
+
+ doNothing().when(client).disconnect(nsiUri, allottedResourceUri)
spy.removeNSSIAssociationWithNSI(mockExecution)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
index 32c4c1aa57..ac6f897dfa 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
@@ -23,6 +23,8 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.Before
import org.junit.Test
+import org.mockito.Mockito
+import org.onap.aai.domain.yang.v19.AllottedResource
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aai.domain.yang.v19.SliceProfile
import org.onap.aai.domain.yang.v19.SliceProfiles
@@ -46,31 +48,6 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
@Test
- void testGetNSSIAssociatedProfiles() {
- def currentNSSI = [:]
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
-
- ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
-
- SliceProfiles sliceProfiles = new SliceProfiles()
-
- List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
- slProfiles.add(new SliceProfile())
- slProfiles.add(new SliceProfile())
-
- nssi.setSliceProfiles(sliceProfiles)
- currentNSSI.put("nssi", nssi)
-
- DoModifyCoreNSSI obj = new DoModifyCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
-
- List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
- assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
- }
-
-
- @Test
void testCalculateSNSSAISliceProfileInstanceHasToBeDeleted() {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
@@ -154,9 +131,15 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
String sliceProfileId = "sliceProfileId"
- currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"],\"expDataRateUL\":\"12\"}")
+ currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"],\"expDataRateUL\":\"12\",\"expDataRateDL\":\"5\"," +
+ "\"activityFactor\":\"2\",\"resourceSharingLevel\":\"resource-sharing-level\",\"uEMobilityLevel\":\"ue-mobility-level\",\"coverageAreaTAList\":\"coverage-area-ta-list\"," +
+ "\"maxNumberofUEs\":\"10000\",\"latency\":\"7\"}")
currentNSSI.put("sliceProfileId", sliceProfileId)
+ List<String> snssais = new ArrayList<>()
+ snssais.add("s-nssai")
+ currentNSSI.put("S-NSSAIs", snssais)
+
DoModifyCoreNSSI spy = spy(DoModifyCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
@@ -169,17 +152,21 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("nssiId", nssiId)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(UUID.randomUUID().toString())
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).
+ serviceInstance(sliceProfileInstance.getServiceInstanceId()))
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setProfileId(sliceProfileId)
- doNothing().when(client).create(uri, sliceProfile)
+ doNothing().when(client).create(uri, sliceProfileInstance)
spy.createSliceProfileInstance(mockExecution)
- assertNotNull("Slice Profile doesn't exist", currentNSSI.get("createdSliceProfile"))
- assertTrue("Unexpected Slice Profile Id", ((SliceProfile)currentNSSI.get("createdSliceProfile")).getProfileId().equals(sliceProfile.getProfileId()))
+ assertTrue("Slice Profile Instance Id doesn't exist", (currentNSSI.get("createdSliceProfileInstanceId")) != null)
+
}
@@ -202,8 +189,19 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
String globalSubscriberId = "globalSubscriberId"
String subscriptionServiceType = "subscriptionServiceType"
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+ String sliceProfileInstanceId = "slice-rpofile-instance-id"
+ currentNSSI.put("createdSliceProfileInstanceId", sliceProfileInstanceId)
+
+ AllottedResource allottedResource = new AllottedResource()
+
+ String allottedResourceId = UUID.randomUUID().toString()
+
+ allottedResource.setId(allottedResourceId)
+
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId))
+ doNothing().when(client).create(allottedResourceUri, allottedResource)
+
+ currentNSSI.put("allottedResourceUri", allottedResourceUri)
when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
@@ -213,19 +211,26 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
SliceProfile sliceProfile = new SliceProfile()
currentNSSI.put("createdSliceProfile", sliceProfile)
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId))
+
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+ doNothing().when(client).update(sliceProfileInstanceUri, sliceProfileInstance)
+
ServiceInstance nssi = new ServiceInstance()
nssi.setServiceInstanceId(nssiId)
nssi.setSliceProfiles(new SliceProfiles())
currentNSSI.put("nssi", nssi)
- int sizeBelore = nssi.getSliceProfiles().getSliceProfile().size()
-
- doNothing().when(client).update(nssiUri, nssi)
- doNothing().when(client).connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
+ doNothing().when(client).connect(nssiUri, sliceProfileInstanceUri, AAIEdgeLabel.USES)
spy.associateSliceProfileInstanceWithNSSI(mockExecution)
- assertTrue("Wrong number of associated slice profiles", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBelore + 1))
}
}