summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/pom.xml1
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy56
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy54
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy68
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy187
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy12
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy54
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy39
11 files changed, 408 insertions, 75 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml
index 846af27b96..b287594a12 100644
--- a/bpmn/so-bpmn-infrastructure-common/pom.xml
+++ b/bpmn/so-bpmn-infrastructure-common/pom.xml
@@ -229,6 +229,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
+ <version>${logback-core.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy
index d0fe1e9469..e54193470d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateSliceService.groovy
@@ -20,6 +20,7 @@
package org.onap.so.bpmn.infrastructure.scripts
+import static org.apache.commons.lang3.StringUtils.isBlank
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -27,6 +28,15 @@ import org.apache.commons.lang3.StringUtils
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.logging.filter.base.ErrorCode
+import javax.ws.rs.NotFoundException
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.aaiclient.client.aai.AAIResourcesClient
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+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.beans.nsmf.*
import org.onap.so.beans.nsmf.oof.SubnetType
import org.onap.so.bpmn.common.scripts.*
@@ -160,8 +170,10 @@ class DoActivateSliceService extends AbstractServiceTaskProcessor {
actDeActNssi.setNssiId(nssInstance.nssiId)
actDeActNssi.setSnssaiList(Arrays.asList(customerInfo.snssai))
+ String sliceProfileId = getRelatedSliceProfileId(execution, customerInfo.globalSubscriberId, customerInfo.subscriptionServiceType, nssInstance.nssiId, customerInfo.snssai, "slice-profile")
+ actDeActNssi.setSliceProfileId(sliceProfileId)
- nbiRequest.setEsrInfo(esrInfo)
+ nbiRequest.setEsrInfo(esrInfo)
nbiRequest.setServiceInfo(serviceInfo)
nbiRequest.setActDeActNssi(actDeActNssi)
execution.setVariable("nbiRequest", nbiRequest)
@@ -176,6 +188,48 @@ class DoActivateSliceService extends AbstractServiceTaskProcessor {
logger.debug("***** Exit processDecomposition *****")
}
+ private String getRelatedSliceProfileId(DelegateExecution execution, String globalSubscriberId, String subscriptionServiceType, String instanceId, String snssai, String role) {
+ logger.debug("${Prefix} - Get Related Slice Profile")
+ if( isBlank(role) || isBlank(instanceId)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Role and instanceId are mandatory")
+ }
+
+ String nssiId;
+ AAIResourcesClient client = getAAIClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId))
+ if (!client.exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}")
+ }
+ AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ if(si.isPresent()) {
+ List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship()
+ for (Relationship relationship : relationshipList) {
+ String relatedTo = relationship.getRelatedTo()
+ if (relatedTo.toLowerCase() == "service-instance") {
+ String relatioshipurl = relationship.getRelatedLink()
+ String serviceInstanceId =
+ relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length())
+ uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId))
+ if (!client.exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500,
+ "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}")
+ }
+ AAIResultWrapper wrapper01 = client.get(uri, NotFoundException.class)
+ Optional<ServiceInstance> serviceInstance = wrapper01.asBean(ServiceInstance.class)
+ if (serviceInstance.isPresent()) {
+ ServiceInstance instance = serviceInstance.get()
+ if (role.equalsIgnoreCase(instance.getServiceRole()) && snssai.equalsIgnoreCase(instance.getEnvironmentContext())) {
+ nssiId = instance.getServiceInstanceId()
+ }
+ }
+ }
+ }
+ }
+ return nssiId
+ logger.debug("${Prefix} - Exit Get Related Slice Profile instances")
+ }
+
/**
* send Create Request NSSMF
* @param execution
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy
index 9800428c68..a11270465a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy
@@ -369,7 +369,6 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
modifySliceParams.addProperty("snssaiList", snssaiList)
modifySliceParams.addProperty("sliceProfileId", sliceProfileId)
modifySliceParams.addProperty("nsiInfo", nsiInfo)
- modifySliceParams.addProperty("scriptName", scriptName)
execution.setVariable("modifySliceParams", modifySliceParams.toString())
//create operation status in request db
@@ -639,15 +638,15 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
ANServiceInstance.setServiceType(execution.getVariable("sst") as String)
ANServiceInstance.setOrchestrationStatus(serviceStatus)
String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList") as String
- ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
+ ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
ANServiceInstance.setServiceRole(serviceRole)
List<String> snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
String snssai = snssaiList.get(0)
- ANServiceInstance.setEnvironmentContext(snssai)
String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
String modelUuid = execution.getVariable("modelUuid") as String
ANServiceInstance.setModelInvariantId(modelInvariantUuid)
ANServiceInstance.setModelVersionId(modelUuid)
+ ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type
ANServiceInstance.setWorkloadContext("AN")
String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile") as String, "resourceSharingLevel")
ANServiceInstance.setServiceFunction(serviceFunctionAn)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy
index 2e0f3cfd66..4681713fd7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineCreate.groovy
@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory
import org.springframework.web.util.UriUtils
import static org.apache.commons.lang3.StringUtils.isBlank
+import static org.apache.commons.lang3.StringUtils.isNotBlank
class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor {
@@ -333,6 +334,7 @@ class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor {
String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA")
String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB")
+ String epBProtect = jsonUtil.getJsonValue(linkStr, "transportEndpointBProtection")
String modelInvariantId = execution.getVariable("modelInvariantUuid")
String modelVersionId = execution.getVariable("modelUuid")
@@ -340,6 +342,9 @@ class DoCloudLeasedLineCreate extends AbstractServiceTaskProcessor {
resource.setLinkId(linkId)
resource.setLinkName(epA)
resource.setLinkName2(epB)
+ if (isNotBlank(epBProtect)) {
+ resource.setSegmentId(epBProtect)
+ }
resource.setLinkType("TsciConnectionLink")
resource.setInMaint(false)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy
index 5c9877840d..bfd5ac81d3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCloudLeasedLineModify.groovy
@@ -109,6 +109,14 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor {
"transportNetworks", "transportNetworks", true)
logger.debug("transportNetworks: " + execution.getVariable("transportNetworks"))
+ serviceIntentUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr,
+ "modifyAction", "modifyAction");
+ if (isNotBlank(execution.getVariable("modifyAction"))) {
+ logger.debug("modifyAction: " + execution.getVariable("modifyAction"))
+ } else {
+ logger.debug("modifyAction is not set")
+ }
+
if (isBlank(serviceIntentUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr,
"enableSdnc", "enableSdnc"))) {
serviceIntentUtils.setEnableSdncConfig(execution)
@@ -266,12 +274,16 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor {
void updateTsciNetworks(DelegateExecution execution) {
try {
+ if (modifyBandwidthGlobal(execution)) {
+ String netStr = jsonUtil.StringArrayToList(execution.getVariable("transportNetworks")).get(0)
+ int maxBw = getMaxBwFromNetworkJsonStr(execution, netStr)
+ updateNetworkPolicyGlobal(execution, maxBw)
+ return
+ }
List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportNetworks"))
for (String networkStr : networkStrList) {
- updateLogicalLinksInNetwork(execution, networkStr)
- updateNetworkPolicy(execution, networkStr)
+ updateTsciNetwork(execution, networkStr)
}
-
} catch (BpmnError e) {
throw e
} catch (Exception ex) {
@@ -280,6 +292,20 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor {
}
}
+ boolean modifyBandwidthGlobal(DelegateExecution execution) {
+ String modifyAction = execution.getVariable("modifyAction")
+ if (isNotBlank(modifyAction) && modifyAction.equals("bandwidth")) {
+ return true
+ }
+
+ return false
+ }
+
+ void updateTsciNetwork(DelegateExecution execution, String networkStr) {
+ updateLogicalLinksInNetwork(execution, networkStr)
+ updateNetworkPolicy(execution, networkStr)
+ }
+
int getMaxBwFromNetworkJsonStr(DelegateExecution execution, String networkJsonStr) {
int maxBw = 0
try {
@@ -327,6 +353,28 @@ public class DoCloudLeasedLineModify extends AbstractServiceTaskProcessor {
}
}
+ void updateNetworkPolicyGlobal(DelegateExecution execution, int maxBw) {
+ try {
+ List<String> arIdList = execution.getVariable("arIdList")
+ for (String arId : arIdList) {
+ Map<String, String> policyMap = execution.getVariable("arPolicyMap")
+ String policyId = policyMap.get(arId)
+ if (isBlank(policyId)) {
+ String msg = String.format("ERROR: updateNetworkPolicy: policyId not found. arId=%s", arId)
+ logger.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ updatePolicyMaxBandwidthInAAI(execution, policyId, maxBw)
+ }
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = String.format("ERROR: updateNetworkPolicy: exception: %s", ex.getMessage())
+ logger.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+ }
+
void updateNetworkPolicy(DelegateExecution execution, String networkJsonStr) {
try {
int maxBw = getMaxBwFromNetworkJsonStr(execution, networkJsonStr)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
index 5476cb5afa..35b4199909 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
@@ -117,7 +117,7 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{
String modelUuid = modelInfo.getModelUuid()
ss.setModelInvariantId(modelInvariantUuid)
ss.setModelVersionId(modelUuid)
- String serviceInstanceLocationid = serviceProfile.get("plmnIdList")
+ String serviceInstanceLocationid = serviceProfile.get("pLMNIdList")
ss.setServiceInstanceLocationId(serviceInstanceLocationid)
String snssai = serviceProfile.get("sNSSAI")
ss.setEnvironmentContext(snssai)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
index b09161d5cd..ea4c29b202 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy
@@ -34,6 +34,13 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.RequestDBUtil
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.common.scripts.OofUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.oof.adapter.beans.payload.OofRequest
+import javax.ws.rs.core.Response
+import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.db.request.beans.ResourceOperationStatus
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -48,6 +55,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor {
JsonUtils jsonUtil = new JsonUtils()
RequestDBUtil requestDBUtil = new RequestDBUtil()
TnNssmfUtils tnNssmfUtils = new TnNssmfUtils()
+ OofUtils oofUtils = new OofUtils()
JsonSlurper jsonSlurper = new JsonSlurper()
ObjectMapper objectMapper = new ObjectMapper()
private static final Logger logger = LoggerFactory.getLogger(DoDeallocateTnNssi.class)
@@ -92,10 +100,69 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor {
"enableSdnc", "enableSdnc"))) {
tnNssmfUtils.setEnableSdncConfig(execution)
}
+ if (isBlank(additionalPropJsonStr) ||
+ isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution,
+ additionalPropJsonStr,
+ "enableOof", "enableOof"))) {
+ tnNssmfUtils.setEnableOofConfig(execution)
+ }
+ String nsiId = jsonUtil.getJsonValue(additionalPropJsonStr, "nsiId")
+ execution.setVariable("nsiId", nsiId)
logger.debug("Finish preProcessRequest")
}
+ void prepareOOFNssiTerminationRequest(DelegateExecution execution) {
+ logger.debug("Start prepareOOFTnNssiTerminationRequest")
+ String requestId = execution.getVariable("msoRequestId")
+ String messageType = "TN_NSSITermination"
+ String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
+ String serviceInstanceId = execution.getVariable("sliceServiceInstanceId")
+
+ String relatedNsiId = execution.getVariable("nsiId")
+
+ String oofRequest = oofUtils.buildTerminateNxiRequest(requestId,serviceInstanceId, "NSSI",messageType,relatedNsiId)
+ execution.setVariable("oofTnNssiPayload", oofRequest)
+ logger.debug("Finish prepareOOFTnNssiTerminationRequest")
+ }
+
+ void performOofNSSITerminationCall(DelegateExecution execution) {
+ boolean terminateTnNSSI = callOofAdapter(execution,execution.getVariable("oofTnNssiPayload"))
+ execution.setVariable("terminateTnNSSI", terminateTnNSSI)
+ }
+
+ /**
+ * @param execution
+ * @param oofRequest - Request payload to be sent to adapter
+ * @return
+ */
+ boolean callOofAdapter(DelegateExecution execution, Object oofRequest) {
+ logger.debug("Start callOofAdapter")
+ String requestId = execution.getVariable("msoRequestId")
+ String oofAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution)
+ URL requestUrl = new URL(oofAdapterEndpoint)
+ OofRequest oofPayload = new OofRequest()
+ oofPayload.setApiPath("/api/oof/terminate/nxi/v1")
+ oofPayload.setRequestDetails(oofRequest)
+ String requestJson = objectMapper.writeValueAsString(oofPayload)
+ logger.debug("Calling OOF adapter : ${requestUrl} with payload : ${requestJson}")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(requestJson)
+ int responseCode = httpResponse.getStatus()
+ logger.debug("OOF sync response code is: " + responseCode)
+ if(responseCode < 200 || responseCode >= 300){
+ logger.debug("OOF request failed with reason : " + httpResponse)
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+ }else {
+ Map<String,Object> response = objectMapper.readValue(httpResponse.getEntity(),Map.class)
+ boolean terminateResponse = response.get("terminateResponse")
+ if(!terminateResponse) {
+ logger.debug("Terminate response is false because " + response.get("reason"))
+ }
+ return terminateResponse
+ }
+ }
+
void preprocessSdncDeallocateTnNssiRequest(DelegateExecution execution) {
def method = getClass().getSimpleName() + '.preprocessSdncDeallocateTnNssiRequest(' +
'execution=' + execution.getId() + ')'
@@ -174,4 +241,3 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor {
requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus)
}
}
-
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy
index 09bbb81b6b..b1436d5d06 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy
@@ -20,10 +20,16 @@
package org.onap.so.bpmn.infrastructure.scripts
+import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
+import org.json.JSONArray
import com.google.gson.JsonArray
+import com.google.gson.GsonBuilder
import com.google.gson.JsonObject
+import com.google.gson.JsonParser
import groovy.json.JsonSlurper
+import org.onap.so.bpmn.common.scripts.OofUtils
+import com.google.gson.Gson
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.ServiceInstance
@@ -53,6 +59,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
RequestDBUtil requestDBUtil = new RequestDBUtil()
JsonSlurper jsonSlurper = new JsonSlurper()
ObjectMapper objectMapper = new ObjectMapper()
+ OofUtils oofUtils = new OofUtils()
TnNssmfUtils tnNssmfUtils = new TnNssmfUtils()
private static final Logger logger = LoggerFactory.getLogger(TnAllocateNssi.class)
@@ -96,7 +103,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
msg = "Input sliceProfile is null"
logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
+ }
+ else {
execution.setVariable("sliceProfile", sliceProfile)
}
@@ -105,7 +113,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
msg = "Input transportSliceNetworks is null"
logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
+ }
+ else {
execution.setVariable("transportSliceNetworks", transportSliceNetworks)
}
logger.debug("transportSliceNetworks: " + transportSliceNetworks)
@@ -115,7 +124,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
msg = "Input nsiInfo is null"
logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
+ }
+ else {
execution.setVariable("nsiInfo", nsiInfoStr)
}
@@ -123,6 +133,14 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
"enableSdnc", "enableSdnc"))) {
tnNssmfUtils.setEnableSdncConfig(execution)
}
+
+ if (isBlank(additionalPropJsonStr) ||
+ isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution,
+ additionalPropJsonStr,
+ "enableOof", "enableOof"))) {
+ tnNssmfUtils.setEnableOofConfig(execution)
+ }
+
} catch (BpmnError e) {
throw e
} catch (Exception ex) {
@@ -169,6 +187,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
//TN NSST decomposition
String tnModelVersion = tnNsstServiceDecomposition.getModelInfo().getModelVersion()
String tnModelName = tnNsstServiceDecomposition.getModelInfo().getModelName()
+
List<ServiceProxy> serviceProxyList = tnNsstServiceDecomposition.getServiceProxy()
List<String> nsstInfoList = new ArrayList<>()
for (ServiceProxy serviceProxy : serviceProxyList) {
@@ -188,7 +207,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
String msg = "Exception in TN NSST processDecomposition. There is no NSST associated with TN NSST "
logger.info(msg)
//exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- } else {
+ }
+ else {
execution.setVariable("tnNsstInfoList", nsstInfoList)
execution.setVariable("tnModelVersion", tnModelVersion)
execution.setVariable("tnModelName", tnModelName)
@@ -196,6 +216,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
execution.setVariable("maxIndex", maxIndex)
}
+ execution.setVariable("tnNfSliceProfile", execution.getVariable("sliceProfile"))
+ execution.setVariable("tnModelName", tnModelName)
logger.debug("End processDecomposition")
}
@@ -205,90 +227,52 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
logger.debug("get NSSI option OOF Url: " + urlString)
//build oof request body
+
String requestId = execution.getVariable("msoRequestId")
- String messageType = "NSISelectionResponse"
- Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class)
+ String messageType = "NSSISelectionResponse"
+ Map<String, Object> profileInfo = (Map<String, Object>) objectMapper.readValue(execution.getVariable("tnNfSliceProfile"), Map.class)
String modelUuid = execution.getVariable("modelUuid")
String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
String modelName = execution.getVariable("tnModelName")
String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
- List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("nsstInfoList"), List.class)
- JsonArray capabilitiesList = new JsonArray()
- execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1")
+ execution.setVariable("nssiSelection_Url", "/api/oof/selection/nssi/v1")
execution.setVariable("nssiSelection_messageType", messageType)
execution.setVariable("nssiSelection_correlator", requestId)
execution.setVariable("nssiSelection_timeout", timeout)
- String oofRequest = buildSelectTnNssiRequest(requestId, messageType, modelUuid, modelInvariantUuid,
- modelName, profileInfo, nsstInfoList, capabilitiesList, false)
+ String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, modelUuid, modelInvariantUuid, modelName, profileInfo)
execution.setVariable("nssiSelection_oofRequest", oofRequest)
logger.debug("Finish prepareOofSelection")
}
- String buildSelectTnNssiRequest(String requestId, String messageType, String UUID, String invariantUUID,
- String name, Map<String, Object> profileInfo,
- List<String> nsstInfoList, JsonArray capabilitiesList, Boolean preferReuse) {
-
- def transactionId = requestId
- logger.debug("transactionId is: " + transactionId)
- String correlator = requestId
- String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
- ObjectMapper objectMapper = new ObjectMapper()
- String profileJson = objectMapper.writeValueAsString(profileInfo)
- String nsstInfoListString = objectMapper.writeValueAsString(nsstInfoList)
- //Prepare requestInfo object
- JsonObject requestInfo = new JsonObject()
- requestInfo.addProperty("transactionId", transactionId)
- requestInfo.addProperty("requestId", requestId)
- requestInfo.addProperty("callbackUrl", callbackUrl)
- requestInfo.addProperty("sourceId", "SO")
- requestInfo.addProperty("timeout", 600)
- requestInfo.addProperty("numSolutions", 1)
-
- //Prepare serviceInfo object
- JsonObject ranNsstInfo = new JsonObject()
- ranNsstInfo.addProperty("UUID", UUID)
- ranNsstInfo.addProperty("invariantUUID", invariantUUID)
- ranNsstInfo.addProperty("name", name)
-
- JsonObject json = new JsonObject()
- json.add("requestInfo", requestInfo)
- json.add("NSTInfo", ranNsstInfo)
- json.addProperty("serviceProfile", profileJson)
- json.addProperty("NSSTInfo", nsstInfoListString)
- json.add("subnetCapabilities", capabilitiesList)
- json.addProperty("preferReuse", preferReuse)
-
- return json.toString()
- }
-
void processOofSelection(DelegateExecution execution) {
logger.debug(Prefix + "processOofSelection method start")
String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse")
String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
if (requestStatus.equals("completed")) {
- List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions"))
- boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI")
- if (existingNSI) {
- def sharedNSISolution = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution")
- execution.setVariable("sharedTnNssiSolution", sharedNSISolution)
- logger.debug("sharedTnNssiSolution from OOF " + sharedNSISolution)
- String tnServiceInstanceId = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution.NSIId")
- execution.setVariable("tnServiceInstanceId", tnServiceInstanceId)
- org.onap.so.bpmn.core.domain.ServiceInstance serviceInstance = new org.onap.so.bpmn.core.domain.ServiceInstance();
- serviceInstance.setInstanceId(tnServiceInstanceId);
- ServiceDecomposition serviceDecomposition = execution.getVariable("tnNsstServiceDecomposition")
- serviceDecomposition.setServiceInstance(serviceInstance);
- execution.setVariable("tnNsstServiceDecomposition", serviceDecomposition)
+ String solutions = jsonUtil.getJsonValue(oofResponse, "solutions")
+ JsonParser parser = new JsonParser()
+ JsonArray solution = parser.parse(solutions) as JsonArray
+ if (solution.size() >= 1) {
+ JsonObject sol = solution.get(0) as JsonObject
+ String tnNfNssiId = sol.get("NSSIId").getAsString()
+ String invariantUuid = sol.get("invariantUUID").getAsString()
+ String uuid = sol.get("UUID").getAsString()
+ String nssiName = sol.get("NSSIName").getAsString()
+ execution.setVariable("TnServiceInstanceId", tnNfNssiId)
+ execution.setVariable("TNNFInvariantUUID", invariantUuid)
+ execution.setVariable("TNNFUUID", uuid)
+ execution.setVariable("servicename", nssiName)
+ logger.debug("TnServiceInstanceId from OOF " + tnNfNssiId)
execution.setVariable("isOofTnNssiSelected", true)
- } else {
- def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles")
- execution.setVariable("tnConstituentSliceProfiles", sliceProfiles)
+ }
+ else {
+ logger.debug("No solutions returned from OOF .. Create new TN NF NSSI")
execution.setVariable("isOofTnNssiSelected", false)
- logger.debug("tnConstituentSliceProfiles list from OOF " + sliceProfiles)
}
- } else {
+ }
+ else {
String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
logger.error("received failed status from oof " + statusMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a failed Async Response from OOF : " + statusMessage)
@@ -297,6 +281,77 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor {
logger.debug(Prefix + "processOofSelection method finished")
}
+ void prepareModifyTnNssiInputs(DelegateExecution execution) {
+ logger.debug(Prefix + "prepareModifyTnNssiInputs method start")
+ String jobId = UUID.randomUUID().toString()
+ execution.setVariable("modifyTnNssiJobId", jobId)
+ String additionalPropJsonStr = execution.getVariable("sliceParams")
+ String sliceProfile = execution.getVariable("sliceProfile")
+ String snssaiList = jsonUtil.getJsonValue(sliceProfile, "snssaiList")
+ String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId")
+ String nsiInfo = jsonUtil.getJsonValue(additionalPropJsonStr, "nsiInfo")
+ String scriptName = jsonUtil.getJsonValue(additionalPropJsonStr, "scriptName")
+ String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
+ String modelUuid = execution.getVariable("modelUuid")
+ String serviceInstanceID = execution.getVariable("TnServiceInstanceId")
+ String servicename = execution.getVariable("servicename")
+ String transportSliceNetworks = jsonUtil.getJsonValue(additionalPropJsonStr, "transportSliceNetworks")
+
+ JsonObject modifySliceParams = new JsonObject()
+ modifySliceParams.addProperty("nsiInfo", nsiInfo)
+ modifySliceParams.addProperty("serviceInstanceID", serviceInstanceID)
+ modifySliceParams.addProperty("servicename", servicename)
+ modifySliceParams.addProperty("sliceProfile", sliceProfile)
+ modifySliceParams.addProperty("sliceProfileId", sliceProfileId)
+ modifySliceParams.addProperty("modelInvariantUuid", modelInvariantUuid)
+ modifySliceParams.addProperty("modelUuid", modelUuid)
+ modifySliceParams.addProperty("scriptName", scriptName)
+ modifySliceParams.addProperty("snssaiList", snssaiList)
+ modifySliceParams.addProperty("transportSliceNetworks", transportSliceNetworks)
+
+ execution.setVariable("modifySliceParams", modifySliceParams.toString())
+
+ logger.debug(Prefix + "prepareModifyTnNssiInputs method finished")
+ }
+
+ def createModifyNssiQueryJobStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "createModifyNssiQueryJobStatus method start")
+ JsonObject esrInfo = new JsonObject()
+ esrInfo.addProperty("networkType", "tn")
+ esrInfo.addProperty("vendor", "ONAP_internal")
+
+ execution.setVariable("esrInfo", esrInfo.toString())
+
+ JsonObject serviceInfo = new JsonObject()
+ serviceInfo.addProperty("nssiId", execution.getVariable("TnServiceInstanceId") as String)
+ serviceInfo.addProperty("nsiId", execution.getVariable("nsiId") as String)
+ serviceInfo.addProperty("nssiName", execution.getVariable("servicename") as String)
+ serviceInfo.addProperty("sST", execution.getVariable("sst") as String)
+ serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
+ serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId") as String)
+ serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType") as String)
+ serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid") as String)
+ serviceInfo.addProperty("serviceUuid", execution.getVariable("modelUuid") as String)
+ execution.setVariable("serviceInfo", serviceInfo.toString())
+ execution.setVariable("responseId", "")
+ }
+
+ def processModifyJobStatusRsp = { DelegateExecution execution ->
+ logger.debug(Prefix + "processJobStatusRsp method start")
+ String jobResponse = execution.getVariable("jobResponse")
+ logger.debug("Job status response " + jobResponse)
+ String status = jsonUtil.getJsonValue(jobResponse, "status")
+ String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
+ if (status.equalsIgnoreCase("finished")) {
+ logger.debug("Job successfully completed ... proceeding with flow for nssi : " + nssi)
+ }
+ else {
+ String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
+ logger.error("received failed status from job status query for nssi : " + nssi + " with status description : " + statusDescription)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "received failed status from job status query for nssi : " + nssi + " with status description : " + statusDescription)
+ }
+ }
+
void updateAAIOrchStatus(DelegateExecution execution) {
logger.debug("Start updateAAIOrchStatus")
String sliceServiceInstanceId = execution.getVariable("sliceServiceInstanceId")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
index d6e94efea1..d1e2b11676 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy
@@ -382,6 +382,18 @@ class TnNssmfUtils {
execution.setVariable("enableSdnc", enableSdnc)
}
+ void setEnableOofConfig(DelegateExecution execution) {
+ String enableOof = UrnPropertiesReader.getVariable(
+ "mso.workflow.TnNssmf.enableOOFNetworkConfig")
+ if (isBlank(enableOof)) {
+ logger.debug("mso.workflow.TnNssmf.enableOOFNetworkConfig is undefined, so use default value (true)")
+ enableOof = "true"
+ }
+ logger.debug("setEnableOofConfig: enableOof=" + enableOof)
+
+ execution.setVariable("enableOof", enableOof)
+ }
+
String setExecVarFromJsonIfExists(DelegateExecution execution,
String jsonStr, String jsonKey, String varName) {
return setExecVarFromJsonStr(execution, jsonStr, jsonKey, varName, false)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy
index 6ea2be8e55..b7cddd2d5a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy
@@ -31,9 +31,12 @@ 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.beans.nsmf.oof.TemplateInfo
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.common.scripts.OofUtils
import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertEquals
import static org.mockito.ArgumentMatchers.eq
import static org.mockito.Mockito.*
@@ -166,4 +169,55 @@ class DoAllocateTnNssiTest extends MsoGroovyTest {
}"""
return expect.replaceAll("\\\\s+", "")
}
+
+ @Test
+ void testPrepareOofSelection() {
+ when(mockExecution.getVariable("msoRequestId")).thenReturn("10dad82d-4bd9-467a-b113-5f8ea7eaae3c")
+ when(mockExecution.getVariable("modelUuid")).thenReturn("e2eb2fe3-92a7-447b-8582-077db5cd0862")
+ when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("22e6ce80-a55f-4171-a457-a7ecb1865669")
+ when(mockExecution.getVariable("tnModelName")).thenReturn("Tn_ONAP_internal_BH")
+ when(mockExecution.getVariable("mso.adapters.oof.timeout")).thenReturn("")
+ TnAllocateNssi obj = spy(TnAllocateNssi.class)
+ OofUtils oofUtils = spy(OofUtils.class)
+ String requestId = "10dad82d-4bd9-467a-b113-5f8ea7eaae3c"
+ String nsstInfo = "\"{\"UUID\":\"e2eb2fe3-92a7-447b-8582-077db5cd0862\",\"invariantUUID\":\"22e6ce80-a55f-4171-a457-a7ecb1865669\",\"name\":\"Tn_ONAP_internal_BH\"}"
+ String messageType = "NSSISelectionResponse"
+ String sliceProfile = "{\"maxBandwidth\":3000,\"sliceProfileId\":\"ab9af40f13f721b5f13539d87484098\",\"latency\":10,\"snssaiList\":[\"001-100001\"],\"pLMNIdList\":[\"460-00\",\"460-01\"],\"perfReq\":{},\"coverageAreaTAList\":[],\"resourceSharingLevel\":\"shared\"}}"
+ Integer timeout = 600
+
+ when(oofUtils.buildSelectNSSIRequest(requestId, nsstInfo as TemplateInfo, messageType, sliceProfile, timeout)).thenReturn("""
+ {
+ "apiPath": "/api/oof/selection/nssi/v1",
+ "requestDetails": "{\\"requestInfo\\":{\\"transactionId\\":\\"10dad82d-4bd9-467a-b113-5f8ea7eaae3c\\",\\"requestId\\":\\"10dad82d-4bd9-467a-b113-5f8ea7eaae3c\\",\\"callbackUrl\\":\\"http://so-oof-adapter.onap:8090/so/adapters/oof/callback/v1/NSSISelectionResponse/10dad82d-4bd9-467a-b113-5f8ea7eaae3c\\",\\"sourceId\\":\\"SO\\",\\"timeout\\":600,\\"numSolutions\\":1},\\"NSSTInfo\\":{\\"UUID\\":\\"e2eb2fe3-92a7-447b-8582-077db5cd0862\\",\\"invariantUUID\\":\\"22e6ce80-a55f-4171-a457-a7ecb1865669\\",\\"name\\":\\"Tn_ONAP_internal_BH\\"},\\"sliceProfile\\":{\\"maxBandwidth\\":3000,\\"sliceProfileId\\":\\"ab9af40f13f721b5f13539d87484098\\",\\"latency\\":10,\\"snssaiList\\":[\\"001-100001\\"],\\"pLMNIdList\\":[\\"460-00\\",\\"460-01\\"],\\"perfReq\\":{},\\"coverageAreaTAList\\":[],\\"resourceSharingLevel\\":\\"shared\\"}}"
+ }""".replaceAll("\\\\s+", ""))
+ obj.prepareOofSelection(mockExecution)
+ verify(mockExecution, times(1)).setVariable(eq("nssiSelection_oofRequest"), captor.capture())
+ String nssiSelection_oofRequest = captor.getValue()
+ assertNotNull(nssiSelection_oofRequest)
+ }
+
+ @Test
+ void testprocessOofSelection() {
+ when(mockExecution.getVariable("nssiSelection_oofRequest")).thenReturn("""
+ {
+ "requestId": "a727643a-bf89-4fd9-b33c-b7bdda18c2b7",
+ "transactionId": "a727643a-bf89-4fd9-b33c-b7bdda18c2b7",
+ "requestStatus": "completed",
+ "statusMessage": "",
+ "solutions": [
+ {
+ "UUID": "e2eb2fe3-92a7-447b-8582-077db5cd0862",
+ "invariantUUID": "22e6ce80-a55f-4171-a457-a7ecb1865669",
+ "NSSIName": "nssi_tnservice12",
+ "NSSIId": "fe26a924-3845-4001-b84e-a439a27a88c0"
+ }
+ ]
+ }""".replaceAll("\\\\s+", ""))
+ TnAllocateNssi obj = spy(TnAllocateNssi.class)
+ ArrayList<String> solution = new ArrayList<>()
+ assertEquals(1, solution.size())
+ verify(mockExecution, times(1)).setVariable(eq("isOofTnNssiSelected"), captor.capture())
+ String isOofTnNssiSelected = captor.getValue()
+ assertEquals("true", isOofTnNssiSelected)
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy
index 31bd3b56f5..2bb2270928 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy
@@ -32,8 +32,10 @@ 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.MsoGroovyTest
+import org.onap.so.bpmn.common.scripts.OofUtils
import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertTrue
import static org.mockito.ArgumentMatchers.eq
import static org.mockito.Mockito.*
@@ -135,4 +137,41 @@ class DoDeallocateTnNssiTest extends MsoGroovyTest {
obj.deleteServiceInstance(mockExecution)
Mockito.verify(client, times(1)).delete(serviceInstanceUri)
}
+
+ @Test
+ void testPrepareOOFNssiTerminationRequest() {
+ when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82")
+ when(mockExecution.getVariable("sliceServiceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("nsiId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56")
+ when(mockExecution.getVariable("mso.adapters.oof.timeout")).thenReturn("")
+ DoDeallocateTnNssi obj = spy(DoDeallocateTnNssi.class)
+ OofUtils oofUtils = spy(OofUtils.class)
+ when(oofUtils.buildTerminateNxiRequest()).thenReturn("""
+ {
+ "apiPath": "/api/oof/terminate/nxi/v1",
+ "requestDetails": "{\"type\":\"NSSI\",\"NxIId\":\"f78c1531-55a7-4dfa-8a12-1e2544c9b248\",\"requestInfo\":{\"transactionId\":\"863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"requestId\":\"863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"callbackUrl\":\"http://so-oof-adapter.onap:8090/so/adapters/oof/callback/v1/TN_NSSITermination/863fb189-33d8-455f-9d3f-bf3f6a2e4509\",\"sourceId\":\"SO\",\"timeout\":600,\"addtnlArgs\":{\"serviceInstanceId\":\"fe6f0901-292d-4493-bcad-485793605781\"}}}"
+ }""".replaceAll("\\\\s+", ""))
+ obj.prepareOOFNssiTerminationRequest(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("oofTnNssiPayload"), captor.capture())
+ String oofTnNssiPayload = captor.getValue()
+ assertNotNull(oofTnNssiPayload)
+ }
+
+ @Test
+ void testPerformOofNSSITerminationCall() {
+ when(mockExecution.getVariable("oofTnNssiPayload")).thenReturn("""
+ {
+ "reason": "",
+ "requestId": "e0a026a9-dd6d-4800-ab27-0fdd8f5f64f5",
+ "requestStatus": "success",
+ "terminateResponse": true,
+ "transactionId": "e0a026a9-dd6d-4800-ab27-0fdd8f5f64f5"
+ }""".replaceAll("\\\\s+", ""))
+ DoDeallocateTnNssi obj = spy(DoDeallocateTnNssi.class)
+ when(obj.callOofAdapter()).thenReturn(true)
+ obj.performOofNSSITerminationCall(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("terminateTnNSSI"), captor.capture())
+ String terminateTnNSSI = captor.getValue()
+ assertTrue(terminateTnNSSI)
+ }
}