summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
authorByung-Woo Jun <byung-woo.jun@est.tech>2020-09-29 16:07:40 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-29 16:07:40 +0000
commit90503c475233a7578f925199b5dccf251396db66 (patch)
tree1b03bc20b2e480cf6f2413c2b3f349d2ed7d3869 /bpmn/so-bpmn-infrastructure-common/src
parentaecdc1520d4afaacac8dde1fce0d66e2b5aeea22 (diff)
parent47397faa188acd9fa3c07e79018e0919c0055f3a (diff)
Merge "Enrich Deallocate and Modify Core NSSI sub-processes"
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.groovy289
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy92
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy106
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy204
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy64
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy45
6 files changed, 552 insertions, 248 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 e225c360ed..567725246e 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
@@ -22,15 +22,9 @@ 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.CloudRegion
-import org.onap.aai.domain.yang.GenericVnf
-import org.onap.aai.domain.yang.ModelVer
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.ServiceSubscription
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aai.domain.yang.Tenant
-import org.onap.aai.domain.yang.VfModule
-import org.onap.aaiclient.client.aai.AAIObjectType
+import org.json.JSONArray
+import org.json.JSONObject
+import org.onap.aai.domain.yang.v19.*
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
import org.onap.aaiclient.client.aai.entities.Relationships
@@ -39,35 +33,20 @@ 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.AbstractServiceTaskProcessor
-import org.onap.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.common.scripts.*
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
-import org.onap.so.db.request.beans.OperationStatus
-import org.onap.so.requestsdb.RequestsDbConstant
-import org.onap.so.serviceinstancebeans.CloudConfiguration
-import org.onap.so.serviceinstancebeans.LineOfBusiness
-import org.onap.so.serviceinstancebeans.ModelInfo
-import org.onap.so.serviceinstancebeans.ModelType
-import org.onap.so.serviceinstancebeans.OwningEntity
-import org.onap.so.serviceinstancebeans.Project
-import org.onap.so.serviceinstancebeans.RequestDetails
-import org.onap.so.serviceinstancebeans.RequestInfo
-import org.onap.so.serviceinstancebeans.RequestParameters
-import org.onap.so.serviceinstancebeans.Resources
-import org.onap.so.serviceinstancebeans.Service
-import org.onap.so.serviceinstancebeans.SubscriberInfo
-import org.onap.so.serviceinstancebeans.VfModules
-import org.onap.so.serviceinstancebeans.Vnfs
+import org.onap.so.db.request.beans.ResourceOperationStatus
+import org.onap.so.serviceinstancebeans.*
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import javax.ws.rs.core.Response
+import static org.apache.commons.lang3.StringUtils.isBlank
- class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
+class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
private final String PREFIX ="DoCommonCoreNSSI"
@@ -83,10 +62,54 @@ import javax.ws.rs.core.Response
def currentNSSI = execution.getVariable("currentNSSI")
if (!currentNSSI) {
- String msg = "currentNSSI is null"
+ currentNSSI = [:]
+ }
+
+ // NSSI ID
+ String nssiId = execution.getVariable("serviceInstanceID")
+ if (isBlank(nssiId)) {
+ String msg = "NSSI service instance id is null"
LOGGER.error(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
+ else {
+ currentNSSI['nssiId'] = nssiId
+ }
+
+ // NSI ID
+ String nsiId = execution.getVariable("nsiId")
+ if (isBlank(nsiId)) {
+ String msg = "nsiId is null"
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ else {
+ currentNSSI['nsiId'] = nsiId
+ }
+
+
+ // Slice Profile
+ String sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile")
+ if (isBlank(sliceProfile)) {
+ String msg = "Slice Profile is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ currentNSSI['sliceProfile'] = sliceProfile
+ }
+
+ // S-NSSAI
+ def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList"))
+
+ String sNssai = snssaiList.get(0)
+ currentNSSI['S-NSSAI'] = sNssai
+
+
+ // Slice Profile id
+ String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId")
+ currentNSSI['sliceProfileId'] = sliceProfileId
+
+ execution.setVariable("currentNSSI", currentNSSI)
+
LOGGER.trace("***** ${getPrefix()} Exit preProcessRequest")
}
@@ -257,7 +280,7 @@ import javax.ws.rs.core.Response
List<String> snssais = new ArrayList<>()
- String isCreateSliceProfileInstanceVar = execution.getVariable("isCreateSliceProfileInstance" )
+ String isCreateSliceProfileInstanceVar = execution.getVariable("isCreateSliceProfileInstance" ) // Not exist in case of Deallocate
boolean isCreateSliceProfileInstance = Boolean.parseBoolean(isCreateSliceProfileInstanceVar)
@@ -294,14 +317,14 @@ import javax.ws.rs.core.Response
def currentNSSI = execution.getVariable("currentNSSI")
try {
- //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfId}"
- def nsmfЕndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ???
+ //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}"
+ def nsmfЕndPoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ???
ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance']
- GenericVnf constituteVnf = (GenericVnf)currentNSSI['constituteVnf']
+ String url = String.format("${nsmfЕndPoint}/serviceInstantiation/v7/serviceInstances/%s", networkServiceInstance.getServiceInstanceId())
- String url = String.format("${nsmfЕndpoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId())
+ currentNSSI['putServiceInstanceURL'] = url
String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
@@ -332,7 +355,7 @@ import javax.ws.rs.core.Response
String putServiceInstanceResponse = ""
if(errorCode == null || errorCode.isEmpty()) { // No error
- putServiceInstanceResponse = callPUTServiceInstanceResponse // check the response ???
+ putServiceInstanceResponse = callPUTServiceInstanceResponse
}
else {
LOGGER.error(jsonUtil.getJsonValue(callPUTServiceInstanceResponse, "errorMessage"))
@@ -430,9 +453,9 @@ import javax.ws.rs.core.Response
SubscriberInfo prepareSubscriberInfo(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
- String globalSubscriberId = currentNSSI['globalSubscriberId']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriberName = currentNSSI['subscriberName']
+ String subscriberName = execution.getVariable("subscriberName")
SubscriberInfo subscriberInfo = new SubscriberInfo()
subscriberInfo.setGlobalSubscriberId(globalSubscriberId)
@@ -484,13 +507,13 @@ import javax.ws.rs.core.Response
RequestInfo prepareRequestInfo(DelegateExecution execution, ServiceInstance networkServiceInstance) {
def currentNSSI = execution.getVariable("currentNSSI")
- String serviceId = currentNSSI['serviceId']
+ String productFamilyId = execution.getVariable("productFamilyId")
RequestInfo requestInfo = new RequestInfo()
requestInfo.setInstanceName(networkServiceInstance.getServiceInstanceName())
requestInfo.setSource("VID")
- requestInfo.setProductFamilyId(serviceId)
+ requestInfo.setProductFamilyId(productFamilyId)
requestInfo.setRequestorId("NBI")
return requestInfo
@@ -961,15 +984,15 @@ import javax.ws.rs.core.Response
SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI['sliceProfileS-NSSAI']
- String globalSubscriberId = currentNSSI['globalSubscriberId']
- String serviceType = currentNSSI['serviceType']
+ 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(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId()))
+ AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId()))
try {
- getAAIClient().delete(sliceProfileUri)
+ client.delete(sliceProfileUri)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
}
@@ -979,27 +1002,180 @@ import javax.ws.rs.core.Response
/**
- * Updates operation status
+ * Prepares update resource operation status
* @param execution
*/
- void updateServiceOperationStatus(DelegateExecution execution) {
+ void prepareUpdateResourceOperationStatus(DelegateExecution execution) {
LOGGER.trace("${getPrefix()} Start updateServiceOperationStatus")
def currentNSSI = execution.getVariable("currentNSSI")
- OperationStatus operationStatus = new OperationStatus()
- operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String)
- operationStatus.setOperationId(currentNSSI['operationId'] as String)
- operationStatus.setOperation(currentNSSI['operationType'] as String)
- operationStatus.setResult(RequestsDbConstant.Status.FINISHED)
+ //Prepare Update Status for PUT failure and success
+ String isTimeOutVar = execution.getVariable("isTimeOut")
+ if(!isBlank(isTimeOutVar) && isTimeOutVar.equals("YES")) {
+ LOGGER.error("TIMEOUT - SO PUT Failure")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure")
+ } else {
+ execution.setVariable("progress", "100")
+ execution.setVariable("status", "finished")
+ execution.setVariable("operationContent", "${getAction()} Core NSSI successful.")
+ }
- requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus)
+ setResourceOperationStatus(execution, "finished", "100", "Core NSSI ${getAction()} successful")
LOGGER.trace("${getPrefix()} Exit updateServiceOperationStatus")
}
/**
+ * Prepares ResourceOperation status
+ * @param execution
+ * @param operationType
+ */
+ void setResourceOperationStatus(DelegateExecution execution, String status, String progress, String statusDesc) {
+ LOGGER.trace("${getPrefix()} Start setResourceOperationStatus")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String serviceId = currentNSSI['nssiId']
+ String jobId = execution.getVariable("jobId")
+ String nsiId = currentNSSI['nsiId']
+ String operationType = execution.getVariable("operationType")
+
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
+ resourceOperationStatus.setServiceId(serviceId)
+ resourceOperationStatus.setOperationId(jobId)
+ resourceOperationStatus.setResourceTemplateUUID(nsiId)
+ resourceOperationStatus.setOperType(operationType)
+ resourceOperationStatus.setStatus(status)
+ resourceOperationStatus.setProgress(progress)
+ resourceOperationStatus.setStatusDescription(statusDesc)
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
+
+ LOGGER.trace("${getPrefix()} Exit setResourceOperationStatus")
+ }
+
+
+ /**
+ * Prepares failed operation status update
+ * @param execution
+ */
+ void prepareFailedOperationStatusUpdate(DelegateExecution execution) {
+ LOGGER.trace("${getPrefix()} Start prepareFailedOperationStatusUpdate")
+
+ setResourceOperationStatus(execution, "failed", "0", "Core NSSI ${getAction()} Failed")
+
+ LOGGER.trace("${getPrefix()} Exit prepareFailedOperationStatusUpdate")
+ }
+
+
+ /**
+ * Gets progress status of ServiceInstance PUT operation
+ * @param execution
+ */
+ public void getPUTServiceInstanceProgress(DelegateExecution execution) {
+ LOGGER.trace("${getPrefix()} Start getPUTServiceInstanceProgress")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String url = currentNSSI['putServiceInstanceURL']
+
+ getProgress(execution, url, "putStatus")
+
+ LOGGER.trace("${getPrefix()} Exit getPUTServiceInstanceProgress")
+ }
+
+
+ void getProgress(DelegateExecution execution, String url, String statusVariableName) {
+ String msg=""
+ try {
+
+ ExternalAPIUtil externalAPIUtil = getExternalAPIUtilFactory().create()
+ Response response = externalAPIUtil.executeExternalAPIGetCall(execution, url)
+ int responseCode = response.getStatus()
+ execution.setVariable("GetServiceOrderResponseCode", responseCode)
+ LOGGER.debug("Get ServiceOrder response code is: " + responseCode)
+
+ String extApiResponse = response.readEntity(String.class)
+ JSONObject responseObj = new JSONObject(extApiResponse)
+ execution.setVariable("GetServiceOrderResponse", extApiResponse)
+ LOGGER.debug("Create response body is: " + extApiResponse)
+ //Process Response //200 OK 201 CREATED 202 ACCEPTED
+ if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
+ {
+ LOGGER.debug("Get Create ServiceOrder Received a Good Response")
+ String orderState = responseObj.get("state")
+ if("REJECTED".equalsIgnoreCase(orderState)) {
+ prepareFailedOperationStatusUpdate(execution)
+ return
+ }
+
+ JSONArray items = responseObj.getJSONArray("orderItem")
+ JSONObject item = items.get(0)
+ JSONObject service = item.get("service")
+ String networkServiceId = service.get("id")
+ if (networkServiceId == null || networkServiceId.equals("null")) {
+ prepareFailedOperationStatusUpdate(execution)
+ return
+ }
+
+ execution.setVariable("networkServiceId", networkServiceId)
+ String serviceOrderState = item.get("state")
+ execution.setVariable("ServiceOrderState", serviceOrderState)
+ // Get serviceOrder State and process progress
+ if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable(statusVariableName, "processing")
+ }
+ else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable(statusVariableName, "processing")
+ }
+ else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable(statusVariableName, "completed")
+ }
+ else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
+ msg = "ServiceOrder failed"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ else {
+ msg = "ServiceOrder failed"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+ else{
+ msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode
+ prepareFailedOperationStatusUpdate(execution)
+ }
+
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage())
+ }
+
+ }
+
+
+
+ /**
+ * Delays 5 sec
+ * @param execution
+ */
+ void timeDelay(DelegateExecution execution) {
+ LOGGER.trace("${getPrefix()} Start timeDelay")
+
+ try {
+ LOGGER.debug("${getPrefix()} timeDelay going to sleep for 5 sec")
+
+ Thread.sleep(5000)
+
+ LOGGER.debug("${getPrefix()} ::: timeDelay wakeup after 5 sec")
+ } catch(InterruptedException e) {
+ LOGGER.error("${getPrefix()} ::: timeDelay exception" + e)
+ }
+
+ LOGGER.trace("${getPrefix()} Exit timeDelay")
+ }
+
+
+ /**
* Returns AAI client
* @return AAI client
*/
@@ -1008,7 +1184,16 @@ import javax.ws.rs.core.Response
}
+ ExternalAPIUtilFactory getExternalAPIUtilFactory() {
+ return new ExternalAPIUtilFactory()
+ }
+
+
String getPrefix() {
return PREFIX
}
+
+ String getAction() {
+ return ""
+ }
}
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 c94e2dd67d..055cbfc9cc 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
@@ -20,28 +20,14 @@
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.CloudRegion
-import org.onap.aai.domain.yang.Customer
-import org.onap.aai.domain.yang.ModelVer
-import org.onap.aai.domain.yang.OwningEntities
-import org.onap.aai.domain.yang.ServiceSubscription
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aai.domain.yang.GenericVnf
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.Tenant
-import org.onap.aai.domain.yang.VfModule
-import org.onap.aaiclient.client.aai.AAIClient
+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.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.RequestDBUtil
@@ -49,22 +35,6 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
-import org.onap.so.db.request.beans.OperationStatus
-import org.onap.so.requestsdb.RequestsDbConstant
-import org.onap.so.serviceinstancebeans.CloudConfiguration
-import org.onap.so.serviceinstancebeans.LineOfBusiness
-import org.onap.so.serviceinstancebeans.ModelInfo
-import org.onap.so.serviceinstancebeans.ModelType
-import org.onap.so.serviceinstancebeans.OwningEntity
-import org.onap.so.serviceinstancebeans.Project
-import org.onap.so.serviceinstancebeans.RequestDetails
-import org.onap.so.serviceinstancebeans.RequestInfo
-import org.onap.so.serviceinstancebeans.RequestParameters
-import org.onap.so.serviceinstancebeans.Resources
-import org.onap.so.serviceinstancebeans.Service
-import org.onap.so.serviceinstancebeans.SubscriberInfo
-import org.onap.so.serviceinstancebeans.VfModules
-import org.onap.so.serviceinstancebeans.Vnfs
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -72,6 +42,7 @@ import javax.ws.rs.core.Response
class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
private final String PREFIX ="DoDeallocateCoreNSSI"
+ private final String ACTION = "Deallocate"
private ExceptionUtil exceptionUtil = new ExceptionUtil()
private RequestDBUtil requestDBUtil = new RequestDBUtil()
@@ -80,7 +51,7 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateCoreNSSI.class)
-/**
+ /**
* Queries OOF for NSSI termination
* @param execution
*/
@@ -191,36 +162,6 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
}
- String encryptBasicAuth(String basicAuth, String msoKey) {
- return utils.encrypt(basicAuth, msoKey)
- }
-
-
- String getAuthHeader(DelegateExecution execution, String basicAuthValue, String msokey) {
- String response = ""
- String errorCode = ""
- String errorMessage = ""
-
- LOGGER.debug("Obtained BasicAuth username and password for OOF: " + basicAuthValue)
- try {
- response = utils.getBasicAuth(basicAuthValue, msokey)
- } catch (Exception ex) {
- LOGGER.error("Unable to encode username and password string: ", ex)
-
- errorCode = "401"
- errorMessage = "Internal Error - Unable to encode username and password string"
-
- response = "{\n" +
- " \"errorCode\": \"${errorCode}\",\n" +
- " \"errorMessage\": \"${errorMessage}\"\n" +
- "}"
- }
-
- return response
- }
-
-
-
/**
* Builds OOF request
* @param execution
@@ -263,7 +204,9 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
ServiceInstance networkServiceInstance = (ServiceInstance)currentNSSI['networkServiceInstance']
- String url = String.format("${nbiEndpointUrl}/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId()) // Service Order ID = Network Service Instance ID
+ String url = String.format("${nbiEndpointUrl}/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId())
+
+ currentNSSI['deleteServiceOrderURL'] = url
String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
@@ -387,17 +330,36 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
try {
getAAIClient().delete(nssiUri)
}catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI Service Instance delete call: " + e.getMessage())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while NSSI Service Instance delete call: " + e.getMessage())
}
LOGGER.trace("${PREFIX} Exit deleteNSSIServiceInstance")
}
+ /**
+ * Gets Delete Service Order progress
+ * @param execution
+ */
+ void getDeleteServiceOrderProgress(DelegateExecution execution) {
+ LOGGER.trace("${getPrefix()} Start getDeleteServiceOrderProgress")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String url = currentNSSI['deleteServiceOrderURL']
+
+ getProgress(execution, url, "deleteStatus")
+
+ }
+
@Override
String getPrefix() {
return PREFIX
}
+ @Override
+ String getAction() {
+ return ACTION
+ }
}
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 ebeab3eb7d..4ccea61ed4 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
@@ -21,57 +21,28 @@
package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
-import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.CloudRegion
-import org.onap.aai.domain.yang.Customer
-import org.onap.aai.domain.yang.GenericVnf
-import org.onap.aai.domain.yang.ModelVer
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.ServiceSubscription
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aai.domain.yang.Tenant
-import org.onap.aai.domain.yang.VfModule
-import org.onap.aaiclient.client.aai.AAIObjectType
+import org.onap.aai.domain.yang.v19.ServiceInstance
+import org.onap.aai.domain.yang.v19.SliceProfile
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
-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.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.RequestDBUtil
-import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
-import org.onap.so.db.request.beans.OperationStatus
-import org.onap.so.requestsdb.RequestsDbConstant
-import org.onap.so.serviceinstancebeans.CloudConfiguration
-import org.onap.so.serviceinstancebeans.ModelInfo
-import org.onap.so.serviceinstancebeans.ModelType
-import org.onap.so.serviceinstancebeans.OwningEntity
-import org.onap.so.serviceinstancebeans.Project
-import org.onap.so.serviceinstancebeans.RequestDetails
-import org.onap.so.serviceinstancebeans.RequestInfo
-import org.onap.so.serviceinstancebeans.RequestParameters
-import org.onap.so.serviceinstancebeans.Resources
-import org.onap.so.serviceinstancebeans.Service
-import org.onap.so.serviceinstancebeans.SubscriberInfo
-import org.onap.so.serviceinstancebeans.VfModules
-import org.onap.so.serviceinstancebeans.Vnfs
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import javax.ws.rs.core.Response
+import static org.apache.commons.lang3.StringUtils.isBlank
class DoModifyCoreNSSI extends DoCommonCoreNSSI {
private final String PREFIX ="DoModifyCoreNSSI"
+ private final String ACTION = "Modify"
private ExceptionUtil exceptionUtil = new ExceptionUtil()
private RequestDBUtil requestDBUtil = new RequestDBUtil()
@@ -89,12 +60,11 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
def currentNSSI = execution.getVariable("currentNSSI")
- String sliceProfileID = execution.getVariable("sliceProfileID")
- Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
- Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
+ String sliceProfileID = currentNSSI['sliceProfileId']
+ Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class)
- String globalSubscriberId = currentNSSI['globalSubscriberId']
- String serviceType = currentNSSI['serviceType']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
String nssiId = currentNSSI['nssiId']
SliceProfile sliceProfile = new SliceProfile()
@@ -105,21 +75,46 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
sliceProfile.setExpDataRate(0)
sliceProfile.setTrafficDensity(0)
sliceProfile.setConnDensity(0)
- sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString())
- sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
- sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
- sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
- sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString())
- sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
- sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
- sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
- sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
+ sliceProfile.setSNssai(currentNSSI['S-NSSAI'])
+
+ if(!isBlank(sliceProfileMap.get("expDataRateUL"))) {
+ sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
+ }
+
+ if(!isBlank(sliceProfileMap.get("expDataRateDL"))) {
+ sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
+ }
+
+ if(!isBlank(sliceProfileMap.get("activityFactor"))) {
+ sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
+ }
+
+ if(!isBlank(sliceProfileMap.get("resourceSharingLevel"))) {
+ sliceProfile.setResourceSharingLevel(sliceProfileMap.get("resourceSharingLevel").toString())
+ }
+
+ if(!isBlank(sliceProfileMap.get("uEMobilityLevel"))) {
+ sliceProfile.setUeMobilityLevel(sliceProfileMap.get("uEMobilityLevel").toString())
+ }
+
+ if(!isBlank(sliceProfileMap.get("coverageAreaTAList"))) {
+ sliceProfile.setCoverageAreaTAList(sliceProfileMap.get("coverageAreaTAList").toString())
+ }
+
+ if(!isBlank(sliceProfileMap.get("maxNumberofUEs"))) {
+ sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("maxNumberofUEs").toString()))
+ }
+
+ if(!isBlank(sliceProfileMap.get("latency"))) {
+ sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
+ }
+
sliceProfile.setProfileId(sliceProfileID)
sliceProfile.setE2ELatency(0)
try {
AAIResourcesClient client = getAAIClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
client.create(uri, sliceProfile)
currentNSSI['createdSliceProfile'] = sliceProfile
@@ -138,16 +133,16 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
void associateSliceProfileInstanceWithNSSI(DelegateExecution execution) {
LOGGER.trace("${PREFIX} Start associateSliceProfileInstanceWithNSSI")
- String sliceProfileID = execution.getVariable("sliceProfileID")
-
def currentNSSI = execution.getVariable("currentNSSI")
- String globalSubscriberId = currentNSSI['globalSubscriberId']
- String serviceType = currentNSSI['serviceType']
+ 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(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
+ AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
try {
SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
@@ -171,4 +166,9 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
return PREFIX
}
+
+ @Override
+ String getAction() {
+ return ACTION
+ }
}
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 2c943ffc7c..6ca3937d68 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
@@ -24,19 +24,23 @@ import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito
-import org.onap.aai.domain.yang.*
-import org.onap.aaiclient.client.aai.AAIObjectType
+import org.onap.aai.domain.yang.v19.*
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.AAISimpleUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.aai.entities.uri.ServiceInstanceUri
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
-import org.onap.aaiclient.client.aai.entities.uri.ServiceInstanceUri
+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.serviceinstancebeans.RequestDetails
+import javax.ws.rs.core.Response
+import java.time.Instant
+
import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertTrue
import static org.mockito.Mockito.*
@@ -50,13 +54,32 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
@Test
void testPreProcessRequest() {
- def currentNSSI = [:]
- currentNSSI.put("nssiId","5G-999")
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ String nssiId = "5G-999"
+ when(mockExecution.getVariable("serviceInstanceID")).thenReturn(nssiId)
+
+ String nsiId = "5G-777"
+ when(mockExecution.getVariable("nsiId")).thenReturn(nsiId)
+
+ String snssai = "S-NSSAI"
+ String snssaiList = "[ \"${snssai}\" ]"
+ String sliceProfileId = "slice-profile-id"
+ String sliceParams = "{\n" +
+ "\"sliceProfile\":{\"sliceProfileId\":\"${sliceProfileId}\",\"snssaiList\":${snssaiList}}\n" +
+ "}"
+ when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams)
DoCommonCoreNSSI dcnssi = new DoCommonCoreNSSI()
dcnssi.preProcessRequest(mockExecution)
- Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI")
+
+ def currentNSSI = [:]
+ currentNSSI.put("nssiId", nssiId)
+ currentNSSI.put("nsiId", nsiId)
+ currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"]}")
+ currentNSSI.put("S-NSSAI", snssai)
+ currentNSSI.put("sliceProfileId", sliceProfileId)
+ Mockito.verify(mockExecution,times(1)).setVariable("currentNSSI", currentNSSI)
+
}
@@ -90,13 +113,13 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
Relationships rsMock = mock(Relationships.class)
Optional<Relationships> orsMock = Optional.of(rsMock)
List<AAIResourceUri> arus = new ArrayList<>()
- AAIResourceUri aru = new ServiceInstanceUri(networkServiceInstanceUri)
+ AAIResourceUri aru = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstance.getServiceInstanceId()))
arus.add(aru)
when(client.get(nssiUri)).thenReturn(wrapperMock)
when(wrapperMock.getRelationships()).thenReturn(orsMock)
- when(rsMockgetRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(arus)
+ when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(arus)
when(client.get(ServiceInstance.class, aru)).thenReturn(networkServiceInstaneOpt)
spy.getNetworkServiceInstance(mockExecution)
@@ -145,7 +168,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
when(wrapperMock.getRelationships()).thenReturn(orsMock)
- when(rsMockgetRelatedUris(Types.GENERIC_VNF)).thenReturn(arus)
+ when(rsMock.getRelatedUris(Types.GENERIC_VNF)).thenReturn(arus)
when(client.get(GenericVnf.class, genericVNFUri)).thenReturn(genericVnfOpt)
spy.getConstituteVNFFromNetworkServiceInst(mockExecution)
@@ -190,13 +213,9 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
networkServiceInstance.setServiceInstanceId("NS-777")
networkServiceInstance.setServiceRole("Network Service")
- GenericVnf constituteVnf = new GenericVnf()
- constituteVnf.setVnfId("VNF-1")
-
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
currentNSSI.put("networkServiceInstance", networkServiceInstance)
- currentNSSI.put("constituteVnf", constituteVnf)
when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://mso.onap:8088")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("mso.msoKey")
@@ -211,7 +230,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse)
- String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId())
+ String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s", networkServiceInstance.getServiceInstanceId())
String callPUTServiceInstanceResponse = "put"
@@ -282,11 +301,12 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
String globalSubscriberId = "global-id"
- String serviceType = "service"
+ String subscriptionServiceType = "subscription-service-type"
String nssiId = "5G-999"
- currentNSSI.put("globalSubscriberId", globalSubscriberId)
- currentNSSI.put("serviceType", serviceType)
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
+
currentNSSI.put("nssiId", nssiId)
String theSNSSAI = "theS-NSSAI"
@@ -311,26 +331,6 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
@Test
- void testUpdateServiceOperationStatus() {
- def currentNSSI = [:]
-
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
-
- String nssiId = "5G-999"
-
- currentNSSI.put("nssiId", nssiId)
- currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
- currentNSSI.put("operationId", "operationId")
- currentNSSI.put("operationType", "operationType")
-
- DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
-
- spy.updateServiceOperationStatus(mockExecution)
-
- }
-
-
- @Test
void testPrepareRequestDetails() {
def currentNSSI = [:]
@@ -431,6 +431,124 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
}
+ @Test
+ void testPrepareFailedOperationStatusUpdate() {
+ def currentNSSI = [:]
+
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ when(mockExecution.getVariable("jobId")).thenReturn("job-id")
+ when(mockExecution.getVariable("operationType")).thenReturn("operation-type")
+
+ String nssiId = "5G-999"
+ String nsiId = "5G-777"
+
+ currentNSSI.put("nssiId", nssiId)
+ currentNSSI.put("nsiId", nsiId)
+ currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
+ currentNSSI.put("operationId", "operationId")
+ currentNSSI.put("operationType", "operationType")
+
+ DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
+
+ spy.prepareFailedOperationStatusUpdate(mockExecution)
+ }
+
+
+ @Test
+ void testPrepareUpdateResourceOperationStatus() {
+ def currentNSSI = [:]
+
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ when(mockExecution.getVariable("jobId")).thenReturn("job-id")
+ when(mockExecution.getVariable("operationType")).thenReturn("operation-type")
+
+ String nssiId = "5G-999"
+ String nsiId = "5G-777"
+
+ currentNSSI.put("nssiId", nssiId)
+ currentNSSI.put("nsiId", nsiId)
+ currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
+ currentNSSI.put("operationId", "operationId")
+ currentNSSI.put("operationType", "operationType")
+
+ DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
+
+ spy.prepareUpdateResourceOperationStatus(mockExecution)
+
+ }
+
+
+ @Test
+ void testGetPUTServiceInstanceProgressAcknowledged() {
+
+ executePUTServiceInstanceProgress("ACKNOWLEDGED")
+ Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "processing")
+ }
+
+
+ @Test
+ void testGetPUTServiceInstanceProgressInProgress() {
+
+ executePUTServiceInstanceProgress("INPROGRESS")
+ Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "processing")
+ }
+
+
+ @Test
+ void testGetPUTServiceInstanceProgressCompleted() {
+
+ executePUTServiceInstanceProgress("COMPLETED")
+ Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "completed")
+ }
+
+
+ @Test
+ void testTimeDelay() {
+ DoCommonCoreNSSI obj = spy(DoCommonCoreNSSI.class)
+
+ long before = Instant.now().toEpochMilli()
+ obj.timeDelay(mockExecution)
+
+ long after = Instant.now().toEpochMilli()
+
+ long delay = 5L
+
+ assertTrue(String.format("Didn't wait %d sec", delay), ((after - before) >= delay))
+ }
+
+
+ void executePUTServiceInstanceProgress(String state) {
+
+ def currentNSSI = [:]
+
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ String url = "http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/5G-777"
+
+ currentNSSI.put("putServiceInstanceURL", url)
+
+ DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
+
+ ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class)
+ when(spy.getExternalAPIUtilFactory()).thenReturn(externalAPIUtilFactoryMock)
+
+ ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class)
+
+ when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock)
+
+ Response responseMock = mock(Response.class)
+ when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock)
+
+ when(responseMock.getStatus()).thenReturn(200)
+
+ String entity = "{\"state\":\"ACCEPTED\",\"orderItem\":[{\"service\":{\"id\":\"5G-999\"},\"state\":\"${state}\"}]}"
+ when(responseMock.readEntity(String.class)).thenReturn(entity)
+
+ spy.getPUTServiceInstanceProgress(mockExecution)
+
+ }
+
+
void prepareProject(AAIResourceUri cloudRegionAAIUri) {
Project project = new Project()
project.setProjectName("project-name")
@@ -446,7 +564,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri)
arus.add(aru)
- when(rsMockgetRelatedUris(Types.PROJECT)).thenReturn(arus)
+ when(rsMock.getRelatedUris(Types.PROJECT)).thenReturn(arus)
Optional<Project> projectOpt = Optional.of(project)
@@ -472,7 +590,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
AAIResourceUri aru = new AAISimpleUri(networkServiceInstanceUri)
arus.add(aru)
- when(rsMockgetRelatedUris(Types.OWNING_ENTITY)).thenReturn(arus)
+ when(rsMock.getRelatedUris(Types.OWNING_ENTITY)).thenReturn(arus)
Optional<OwningEntity> owningEntityOpt = Optional.of(owningEntity)
@@ -494,7 +612,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri)
arus.add(aru)
- when(rsMockgetRelatedUris(Types.CLOUD_REGION)).thenReturn(arus)
+ when(rsMock.getRelatedUris(Types.CLOUD_REGION)).thenReturn(arus)
CloudRegion cloudRegion = new CloudRegion()
cloudRegion.setCloudRegionId("cloud-region-id")
@@ -527,7 +645,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
arus.add(serviceSubscriptionUri)
- when(rsMockgetRelatedUris(Types.SERVICE_SUBSCRIPTION)).thenReturn(arus)
+ when(rsMock.getRelatedUris(Types.SERVICE_SUBSCRIPTION)).thenReturn(arus)
ServiceSubscription serviceSubscription = new ServiceSubscription()
serviceSubscription.setServiceType("service-type")
@@ -537,7 +655,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
- when(rsMockgetRelatedUris(Types.CUSTOMER)).thenReturn(arus)
+ when(rsMock.getRelatedUris(Types.CUSTOMER)).thenReturn(arus)
Customer customer = new Customer()
customer.setSubscriberName("subscriber-name")
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 eae788666d..c6e874591f 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
@@ -20,19 +20,19 @@
package org.onap.so.bpmn.infrastructure.scripts
-
import org.junit.Before
import org.junit.Test
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aai.domain.yang.SliceProfiles
-import org.onap.aaiclient.client.aai.AAIObjectType
+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
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import javax.ws.rs.core.Response
+
import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertTrue
import static org.mockito.Mockito.*
@@ -263,4 +263,56 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
}
+ @Test
+ void testDeleteServiceOrderProgressAcknowledged() {
+
+ executeDeleteServiceOrderProgress("ACKNOWLEDGED")
+ Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "processing")
+ }
+
+ @Test
+ void testDeleteServiceOrderProgressInProgress() {
+
+ executeDeleteServiceOrderProgress("INPROGRESS")
+ Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "processing")
+ }
+
+
+ @Test
+ void testDeleteServiceOrderProgressCompleted() {
+
+ executeDeleteServiceOrderProgress("COMPLETED")
+ Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "completed")
+ }
+
+
+ void executeDeleteServiceOrderProgress(String state) {
+ def currentNSSI = [:]
+
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ String url = "http://nbi.onap:8088/api/v4/serviceOrder/NS-777"
+
+ currentNSSI.put("deleteServiceOrderURL", url)
+
+ DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class)
+
+ ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class)
+ when(spy.getExternalAPIUtilFactory()).thenReturn(externalAPIUtilFactoryMock)
+
+ ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class)
+
+ when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock)
+
+ Response responseMock = mock(Response.class)
+ when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock)
+
+ when(responseMock.getStatus()).thenReturn(200)
+
+ String entity = "{\"state\":\"ACCEPTED\",\"orderItem\":[{\"service\":{\"id\":\"5G-999\"},\"state\":\"${state}\"}]}"
+ when(responseMock.readEntity(String.class)).thenReturn(entity)
+
+ spy.getDeleteServiceOrderProgress(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 bbc237f1f9..32c4c1aa57 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
@@ -20,13 +20,12 @@
package org.onap.so.bpmn.infrastructure.scripts
-
+import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.Before
import org.junit.Test
-import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.SliceProfile
-import org.onap.aai.domain.yang.SliceProfiles
-import org.onap.aaiclient.client.aai.AAIObjectType
+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.entities.AAIEdgeLabel
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
@@ -155,34 +154,22 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
String sliceProfileId = "sliceProfileId"
- when(mockExecution.getVariable("sliceProfileID")).thenReturn(sliceProfileId)
-
- Map<String, Object> sliceProfileMap = new HashMap<>()
- sliceProfileMap.put("expDataRateUL", "12")
- sliceProfileMap.put("expDataRateDL", 5)
- sliceProfileMap.put("activityFactor", 2)
- sliceProfileMap.put("latency", 10)
-
- when(mockExecution.getVariable("sliceProfileCn")).thenReturn(sliceProfileMap)
-
-
- Map<String, Object> serviceProfileMap = new HashMap<>()
- when(mockExecution.getVariable("serviceProfile")).thenReturn(serviceProfileMap)
-
+ currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"],\"expDataRateUL\":\"12\"}")
+ currentNSSI.put("sliceProfileId", sliceProfileId)
DoModifyCoreNSSI spy = spy(DoModifyCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
String globalSubscriberId = "globalSubscriberId"
- String serviceType = "serviceType"
+ String subscriptionServiceType = "subscription-service-type"
String nssiId = "nssiId"
- currentNSSI.put("globalSubscriberId", globalSubscriberId)
- currentNSSI.put("serviceType", serviceType)
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
+
currentNSSI.put("nssiId", nssiId)
- currentNSSI.put("sliceProfileId", sliceProfileId)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setProfileId(sliceProfileId)
@@ -213,13 +200,14 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("nssiId", nssiId)
String globalSubscriberId = "globalSubscriberId"
- String serviceType = "serviceType"
+ String subscriptionServiceType = "subscriptionServiceType"
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+ AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
- currentNSSI.put("globalSubscriberId", globalSubscriberId)
- currentNSSI.put("serviceType", serviceType)
currentNSSI.put("sliceProfileId", sliceProfileId)
SliceProfile sliceProfile = new SliceProfile()
@@ -240,5 +228,4 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
assertTrue("Wrong number of associated slice profiles", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBelore + 1))
}
-
}