aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
authorByung-Woo Jun <byung-woo.jun@est.tech>2020-09-17 10:36:47 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-17 10:36:47 +0000
commit0015e69bcb8bc7e1f72b85c5e260513620084026 (patch)
tree646069d28799e13237cb12e2862f4d3556b97527 /bpmn/so-bpmn-infrastructure-common/src
parent903ed1e60d430c2a4b500283d286dbee0d8eefed (diff)
parentc7caf208e96a9f1f7d9fd43bb3c3d2cb1347a399 (diff)
Merge "Implement Allocate Core NSSMF workflow"
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/DoAllocateCoreNSSI.groovy157
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy432
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy658
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy103
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy118
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy646
6 files changed, 2114 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy
new file mode 100644
index 0000000000..64c36e7026
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy
@@ -0,0 +1,157 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+import org.apache.commons.collections.map.HashedMap
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.CatalogDbUtils
+import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceProxy
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.db.request.beans.OperationStatus
+import org.onap.so.db.request.beans.ResourceOperationStatus
+import org.onap.so.serviceinstancebeans.ModelInfo
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import static org.apache.commons.lang3.StringUtils.*;
+import com.fasterxml.jackson.databind.ObjectMapper
+import groovy.json.JsonSlurper
+import javax.ws.rs.core.Response
+import org.onap.so.bpmn.common.scripts.OofUtils
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+
+class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor {
+ String Prefix="DACNSSI_"
+ private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNSSI.class);
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
+ JsonUtils jsonUtil = new JsonUtils()
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+ ObjectMapper mapper = new ObjectMapper()
+ OofUtils oofUtils = new OofUtils()
+ void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: preProcessRequest ****")
+ execution.setVariable("prefix", Prefix)
+ String msg = ""
+ //Get SliceProfile from sliceParams JSON
+ String sliceProfile = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "sliceProfile")
+ if (isBlank(sliceProfile)) {
+ msg = "Slice Profile is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("sliceProfile", sliceProfile)
+ }
+ String coreServiceInstanceId = UUID.randomUUID().toString()
+ execution.setVariable("coreServiceInstanceId", coreServiceInstanceId)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: preProcessRequest ****")
+ }
+ /**
+ * Query NSST name from CatalogDB
+ * @param execution
+ */
+ void getNSSTName(DelegateExecution execution){
+ logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: getNSSTName ****")
+ String nsstModelInvariantUuid = execution.getVariable("modelInvariantUuid")
+ try{
+ String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, nsstModelInvariantUuid)
+ logger.debug("***** JSON Response is: "+json)
+ String nsstName = jsonUtil.getJsonValue(json, "serviceResources.modelInfo.modelName") ?: ""
+ String networkServiceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.serviceProxy.modelInfo") ?: ""
+
+ execution.setVariable("networkServiceModelInfo", networkServiceModelInfo)
+ logger.debug("***** nsstName is: "+ nsstName)
+ execution.setVariable("nsstName",nsstName)
+ }catch(BpmnError e){
+ throw e
+ } catch (Exception ex){
+ String msg = "Exception in preProcessRequest " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: getNSSTName ****")
+ }
+ void prepareOOFRequest(DelegateExecution execution){
+ logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: prepareOOFRequest ****")
+ //API Path
+ String apiPath = "/api/oof/selection/nssi/v1"
+ logger.debug("API path for DoAllocateCoreNSSI: "+apiPath)
+ execution.setVariable("NSSI_apiPath", apiPath)
+ //Setting correlator as requestId
+ String requestId = execution.getVariable("msoRequestId")
+ execution.setVariable("NSSI_correlator", requestId)
+ //Setting messageType for all Core slice as cn
+ String messageType = "cn"
+ execution.setVariable("NSSI_messageType", messageType)
+ //Is there any specific timeout we have to set or else we don't need to send
+ //if blank will be set default value in DoHandleOofRequest
+ String timeout = "PT30M"
+ execution.setVariable("NSSI_timeout", timeout)
+ Map<String, Object> profileInfo = mapper.readValue(execution.getVariable("sliceProfile"), Map.class)
+ String nsstModelUuid = execution.getVariable("modelUuid")
+ String nsstModelInvariantUuid = execution.getVariable("modelInvariantUuid")
+ String nsstName = execution.getVariable("nsstName")
+ String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, nsstModelUuid, nsstModelInvariantUuid, nsstName, profileInfo)
+ logger.debug("**** OOfRequest for Core Slice: "+oofRequest)
+ execution.setVariable("NSSI_oofRequest", oofRequest)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: prepareOOFRequest ****")
+ }
+
+ void processOOFAsyncResponse(DelegateExecution execution) {
+ logger.debug(Prefix+ " **** Enter DoAllocateCoreNSSI ::: processOOFAsyncResponse ****")
+ String OOFResponse = execution.getVariable("NSSI_asyncCallbackResponse")
+ String requestStatus = jsonUtil.getJsonValue(OOFResponse, "requestStatus")
+ logger.debug("NSSI OOFResponse is: " + OOFResponse)
+ execution.setVariable("OOFResponse", OOFResponse)
+ String solutions =""
+ if(requestStatus.equals("completed")) {
+ solutions = jsonUtil.getJsonValue(OOFResponse, "solutions")
+ } 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)
+ }
+ execution.setVariable("solutions", solutions)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: processOOFAsyncResponse ****")
+ }
+
+ void prepareFailedOperationStatusUpdate(DelegateExecution execution){
+ logger.debug(Prefix + " **** Enter DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****")
+ String serviceId = execution.getVariable("nssiId")
+ String jobId = execution.getVariable("jobId")
+ String nsiId = execution.getVariable("nsiId")
+ String operationType = execution.getVariable("operationType")
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
+ resourceOperationStatus.setServiceId(serviceId)
+ resourceOperationStatus.setOperationId(jobId)
+ resourceOperationStatus.setResourceTemplateUUID(nsiId)
+ resourceOperationStatus.setOperType(operationType)
+ resourceOperationStatus.setProgress(0)
+ resourceOperationStatus.setStatus("failed")
+ resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed")
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
+ logger.debug(Prefix + " **** Exit DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****")
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy
new file mode 100644
index 0000000000..2a31997cd5
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy
@@ -0,0 +1,432 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import com.fasterxml.jackson.databind.ObjectMapper
+
+import groovy.json.JsonOutput
+
+import static org.hamcrest.CoreMatchers.instanceOf
+
+import javax.json.JsonArray
+import javax.ws.rs.core.Response
+import org.apache.commons.collections.map.HashedMap
+import org.apache.commons.lang.StringEscapeUtils
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.json.JSONArray
+import org.json.JSONObject
+import org.onap.aaiclient.client.aai.AAIResourcesClient
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.CatalogDbUtils
+import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
+import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.db.request.beans.OperationStatus
+import org.onap.so.db.request.beans.ResourceOperationStatus
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.aai.domain.yang.v19.ServiceInstance
+import org.onap.aaiclient.client.aai.AAIObjectType
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceProxy
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.http.HttpEntity
+
+import javax.ws.rs.NotFoundException
+
+class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
+ String Prefix="DACNSNSSI_"
+ private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNonSharedSlice.class);
+ private CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
+ private RequestDBUtil requestDBUtil = new RequestDBUtil()
+ private ExceptionUtil exceptionUtil = new ExceptionUtil()
+ private JsonUtils jsonUtil = new JsonUtils()
+
+ @Override
+ public void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix+ "**** Enter DoAllocateCoreNonSharedSlice::: preProcessRequest ****")
+ String nssiServiceInstanceId= execution.getVariable("serviceInstanceId")
+ execution.setVariable("nssiServiceInstanceId", nssiServiceInstanceId)
+ //Set orchestration-status as created
+ execution.setVariable("orchestrationStatus", "created")
+ //networkServiceName
+ String networkServiceName = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelName") ?: ""
+ execution.setVariable("networkServiceName", networkServiceName.replaceAll(" Service Proxy", ""))
+ //networkServiceModelUuid
+ String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelUuid") ?: ""
+ execution.setVariable("networkServiceModelUuid", networkServiceModelUuid)
+ logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice::: preProcessRequest ****")
+ }
+
+ void createNSSIinAAI(DelegateExecution execution) {
+ logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****")
+ String msg=""
+ String serviceInstanceId= execution.getVariable("nssiServiceInstanceId")
+ logger.debug("ServiceInstanceId: "+serviceInstanceId)
+ try {
+ String serviceType = execution.getVariable("subscriptionServiceType")
+ String oStatus = execution.getVariable("orchestrationStatus")
+ //Get workload context and environment context from DB
+ String environmentContext = ""
+ String workloadContext =""
+ String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
+ try{
+ String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
+ logger.debug("JSON Response from DB: "+json)
+ environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: ""
+ workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: ""
+ logger.debug("Env Context is: "+ environmentContext)
+ logger.debug("Workload Context is: "+ workloadContext)
+ } catch(BpmnError e){
+ throw e
+ } catch (Exception ex){
+ msg = "Exception in createNSSIinAAI ::: DoAllocateCoreNonSharedSlice " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ String serviceInstanceName = "nssi_"+execution.getVariable("nsstName")
+ ServiceInstance si = new ServiceInstance()
+ si.setServiceInstanceId(execution.getVariable("nssiServiceInstanceId"))
+ si.setServiceInstanceName(serviceInstanceName)
+ si.setServiceType(serviceType)
+ si.setServiceRole("nssi")
+ si.setOrchestrationStatus(oStatus)
+ si.setModelInvariantId(modelInvariantUuid)
+ si.setModelVersionId(execution.getVariable("modelUuid"))
+ si.setEnvironmentContext(environmentContext)
+ si.setWorkloadContext(workloadContext)
+ logger.debug("AAI service Instance Request Payload : "+si.toString())
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), serviceType, serviceInstanceId)
+ Response response = getAAIClient().create(uri, si)
+ if(response.getStatus()!=200) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI instance creation failed")
+ }
+ execution.setVariable("nssiServiceInstance", si)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex) {
+ msg = "Exception in create AAI Instance" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix+ " Exit DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****")
+ }
+
+ public void prepareServiceOrderRequest(DelegateExecution execution) {
+ logger.debug("**** Enter DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest ****")
+ String extAPIPath = UrnPropertiesReader.getVariable("extapi.endpoint", execution) + '/serviceOrder'
+ execution.setVariable("ExternalAPIURL", extAPIPath)
+ ObjectMapper objectMapper = new ObjectMapper();
+ Map<String, Object> serviceOrder = new LinkedHashMap()
+ //ExternalId
+ serviceOrder.put("externalId", "ONAP001")
+ //Requested Start Date
+ String requestedStartDate = utils.generateCurrentTimeInUtc()
+ String requestedCompletionDate = utils.generateCurrentTimeInUtc()
+ serviceOrder.put("requestedStartDate", requestedStartDate)
+ serviceOrder.put("requestedCompletionDate", requestedCompletionDate)
+ //RelatedParty Fields
+ String relatedPartyId = execution.getVariable("globalSubscriberId")
+ String relatedPartyRole = "ONAPcustomer"
+ Map<String, String> relatedParty = new LinkedHashMap()
+ relatedParty.put("id", relatedPartyId)
+ relatedParty.put("role", relatedPartyRole)
+ List<Map<String, String>> relatedPartyList = new ArrayList()
+ relatedPartyList.add(relatedParty)
+ serviceOrder.put("relatedParty", relatedPartyList)
+ Map<String, Object> orderItem = new LinkedHashMap()
+ //orderItem id
+ String orderItemId = "1"
+ orderItem.put("id", orderItemId)
+ //order item action will always be add as we are triggering request for instantiation
+ String orderItemAction = "add"
+ orderItem.put("action", orderItemAction)
+ // service Details
+ Map<String, Object> service = new LinkedHashMap()
+ //ServiceName
+ String serviceName= "nsi_"+execution.getVariable("networkServiceName")
+ service.put("name", serviceName)
+ // Service Type
+ service.put("serviceType", execution.getVariable("serviceType"))
+ //Service State
+ service.put("serviceState", "active")
+ Map<String, String> serviceSpecification = new LinkedHashMap()
+ serviceSpecification.put("id", execution.getVariable("networkServiceModelUuid"))
+ service.put("serviceSpecification", serviceSpecification)
+ //serviceCharacteristic List
+ List serviceCharacteristicList = new ArrayList()
+ Map<String, Object> serviceCharacteristic = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class);
+ List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic)
+ logger.debug("serviceCharacteristicListMap "+serviceCharacteristicListMap)
+ serviceCharacteristicList.add(serviceCharacteristic)
+ //service.put("serviceCharacteristic", serviceCharacteristicList)
+ service.put("serviceCharacteristic", serviceCharacteristicListMap)
+ orderItem.put("service", service)
+ List<Map<String, String>> orderItemList = new ArrayList()
+ orderItemList.add(orderItem)
+ serviceOrder.put("orderItem", orderItemList)
+ String jsonServiceOrder = objectMapper.writeValueAsString(serviceOrder);
+ logger.debug("******* ServiceOrder :: "+jsonServiceOrder)
+ execution.setVariable("serviceOrderRequest", jsonServiceOrder)
+ logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest****")
+ }
+
+ private List retrieveServiceCharacteristicsAsKeyValue(Map serviceCharacteristics) {
+ logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****")
+ List serviceCharacteristicsList = new ArrayList()
+ ObjectMapper mapperObj = new ObjectMapper();
+ Map<String, Object> serviceCharacteristicsObject = new LinkedHashMap()
+ for (Map.Entry<String, Integer> entry : serviceCharacteristics.entrySet()) {
+ Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>()
+ System.out.println(entry.getKey() + ":" + entry.getValue());
+ //For G Release we are sending single value from snssaiList
+ if(entry.getKey().equals("snssaiList")) {
+ List sNssaiValue = entry.getValue()
+ serviceCharacteristicsObject.put("name", "snssai")
+ ServiceCharacteristicValueObject.put("serviceCharacteristicValue", sNssaiValue.get(0))
+ serviceCharacteristicsObject.put("value", ServiceCharacteristicValueObject)
+ }
+ }
+ serviceCharacteristicsList.add(serviceCharacteristicsObject)
+ logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****")
+ return serviceCharacteristicsList
+ }
+
+ public void postNBIServiceOrder(DelegateExecution execution) {
+ logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****")
+ String msg=""
+ try {
+ String extAPIPath = execution.getVariable("ExternalAPIURL")
+ String payload = execution.getVariable("serviceOrderRequest")
+ logger.debug("externalAPIURL is: " + extAPIPath)
+ logger.debug("ServiceOrder payload is: " + payload)
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
+ execution.setVariable("ServiceOrderId", "")
+ Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
+ int responseCode = response.getStatus()
+ execution.setVariable("PostServiceOrderResponseCode", responseCode)
+ logger.debug("Post ServiceOrder response code is: " + responseCode)
+ String extApiResponse = response.readEntity(String.class)
+ JSONObject responseObj = new JSONObject(extApiResponse)
+ execution.setVariable("PostServiceOrderResponse", extApiResponse)
+ logger.debug("ServiceOrder response body is: " + extApiResponse)
+ //Process Response
+ if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
+ //200 OK 201 CREATED 202 ACCEPTED
+ {
+ logger.debug("Post ServiceOrder Received a Good Response")
+ String serviceOrderId = responseObj.get("id")
+ execution.setVariable("ServiceOrderId", serviceOrderId)
+ logger.info("Post ServiceOrderid is: " + serviceOrderId)
+ }
+ else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Post ServiceOrder Received a bad response from extAPI serviceOrder API")
+ }
+ }catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex) {
+ msg = "Exception in ServiceOrder ExtAPI" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug("**** Exit DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****")
+ }
+
+ public void getNBIServiceOrderProgress(DelegateExecution execution) {
+ logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****")
+ String msg=""
+ try {
+ String extAPIPath = execution.getVariable("ExternalAPIURL")
+ extAPIPath += "/" + execution.getVariable("ServiceOrderId")
+ logger.debug("getNBIServiceOrderProgress externalAPIURL is: " + extAPIPath)
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
+ Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
+ 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("status", "processing")
+ }
+ else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable("status", "processing")
+ }
+ else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable("status", "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())
+ }
+ logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****")
+ }
+
+ /**
+ * delay 5 sec
+ */
+ public void timeDelay(DelegateExecution execution) {
+ try {
+ logger.debug(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay going to sleep for 5 sec")
+ Thread.sleep(5000)
+ logger.debug("**** DoAllocateCoreNonSharedSlice ::: timeDelay wakeup after 5 sec")
+ } catch(InterruptedException e) {
+ logger.error(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay exception" + e)
+ }
+ }
+
+
+ void updateRelationship(DelegateExecution execution) {
+ logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: updateRelationship ****")
+
+ String networkServiceInstanceId = execution.getVariable("networkServiceId")
+ String nssiId = execution.getVariable("nssiServiceInstanceId")
+ String globalCustId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("serviceType")
+ try{
+ //Update NSSI orchestration status nssiServiceInstance
+ ServiceInstance si = execution.getVariable("nssiServiceInstance")
+ si.setOrchestrationStatus("activated")
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalCustId, serviceType, networkServiceInstanceId)
+ try {
+ getAAIClient().update(uri, si)
+ } catch (Exception e) {
+ logger.info("Update OrchestrationStatus in AAI failed")
+ String msg = "Update OrchestrationStatus in AAI failed, " + e.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ //URI for NSSI
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId);
+
+ //URI for Network Service Instance
+ AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkServiceInstanceId)
+
+ // Update Relationship in AAI
+ Response response = getAAIClient().connect(nssiUri, networkServiceInstanceUri, AAIEdgeLabel.COMPOSED_OF);
+
+ if(response.getStatus()!=200 || response.getStatus()!=201 || response.getStatus()!=202) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "Set association of NSSI and Network service instance has failed in AAI")
+ } else {
+ execution.setVariable("progress", 100)
+ execution.setVariable("status", "finished")
+ execution.setVariable("statusDescription", "DoAllocateCoreNonSharedNSSI success")
+ setResourceOperationStatus(execution)
+ }
+ }catch(Exception ex) {
+ String msg = "Exception while creating relationship " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: updateRelationship ****")
+ }
+
+ /**
+ * prepare ResourceOperation status
+ * @param execution
+ * @param operationType
+ */
+ private void setResourceOperationStatus(DelegateExecution execution) {
+ logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****")
+ String serviceId = execution.getVariable("nssiId")
+ String jobId = execution.getVariable("jobId")
+ String nsiId = execution.getVariable("nsiId")
+ String operationType = execution.getVariable("operationType")
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
+ resourceOperationStatus.setServiceId(serviceId)
+ resourceOperationStatus.setOperationId(jobId)
+ resourceOperationStatus.setResourceTemplateUUID(nsiId)
+ resourceOperationStatus.setOperType(operationType)
+ resourceOperationStatus.setStatus(execution.getVariable("status"))
+ resourceOperationStatus.setProgress(execution.getVariable("progress"))
+ resourceOperationStatus.setStatusDescription(execution.getVariable("statusDescription"))
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
+ logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****")
+ }
+
+ void prepareFailedOperationStatusUpdate(DelegateExecution execution){
+ logger.debug(Prefix + " **** Enter DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****")
+ String serviceId = execution.getVariable("nssiId")
+ String jobId = execution.getVariable("jobId")
+ String nsiId = execution.getVariable("nsiId")
+ String operationType = execution.getVariable("operationType")
+
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
+ resourceOperationStatus.setServiceId(serviceId)
+ resourceOperationStatus.setOperationId(jobId)
+ resourceOperationStatus.setResourceTemplateUUID(nsiId)
+ resourceOperationStatus.setOperType(operationType)
+ resourceOperationStatus.setProgress(0)
+ resourceOperationStatus.setStatus("failed")
+ resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed")
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
+ logger.debug(Prefix + " **** Exit DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****")
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy
new file mode 100644
index 0000000000..6367341228
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy
@@ -0,0 +1,658 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.json.JSONObject
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.CatalogDbUtils
+import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+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.Platform
+import org.onap.so.serviceinstancebeans.Project
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.rest.catalog.beans.Vnf
+import org.onap.so.serviceinstancebeans.RequestDetails
+import org.onap.so.serviceinstancebeans.RequestInfo
+import org.onap.so.serviceinstancebeans.RequestParameters
+import org.onap.so.serviceinstancebeans.SubscriberInfo
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.RelatedToProperty
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipData
+import org.onap.aai.domain.yang.RelationshipList
+import org.onap.aai.domain.yang.ServiceInstance
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.db.request.beans.OperationStatus
+import org.onap.so.db.request.beans.ResourceOperationStatus
+import org.onap.aaiclient.client.aai.AAIObjectType
+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 com.fasterxml.jackson.databind.ObjectMapper
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.Response
+
+class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
+
+ String Prefix="DACSNSSI_"
+ private static final Logger logger = LoggerFactory.getLogger(DoAllocateCoreSharedSlice.class);
+ private CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
+ private RequestDBUtil requestDBUtil = new RequestDBUtil()
+ private ExceptionUtil exceptionUtil = new ExceptionUtil()
+ private JsonUtils jsonUtil = new JsonUtils()
+ ObjectMapper mapper = new ObjectMapper();
+
+ private final Long TIMEOUT = 60 * 60 * 1000
+
+ @Override
+ public void preProcessRequest(DelegateExecution execution) {
+
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: preProcessRequest ****")
+ //Get NSSI Solutions
+ String nssisolutions = execution.getVariable("solutions")
+
+ //Get First Object
+ List<String> nssiSolutionList = jsonUtil.StringArrayToList(nssisolutions)
+
+ logger.debug("nssiSolutionList : "+nssiSolutionList)
+
+ String nssiId = jsonUtil.getJsonValue(nssiSolutionList.get(0), "NSSIId")
+ logger.debug("NSSIId : "+nssiId)
+
+ if (isBlank(nssiId)) {
+ String msg = "solution nssiId is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("nssiId", nssiId)
+ }
+
+ String sNssaiListAsString = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "snssaiList")
+ logger.debug("sNssaiListAsString "+sNssaiListAsString)
+ List<String> sNssaiList = jsonUtil.StringArrayToList(sNssaiListAsString)
+ logger.debug("sNssaiList "+sNssaiList)
+ String sNssai = sNssaiList.get(0)
+ execution.setVariable("sNssai", sNssai)
+ logger.debug("sNssai: "+sNssai)
+
+ String serviceType = execution.getVariable("subscriptionServiceType")
+ execution.setVariable("serviceType", serviceType)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: preProcessRequest ****")
+ }
+
+ public void getNetworkInstanceAssociatedWithNssiId(DelegateExecution execution) {
+
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****")
+
+ //NSSI Id as service Instance Id to get from Request
+ String serviceInstanceId = execution.getVariable("serviceInstanceID")
+
+ String errorMsg = "query Network Service Instance from AAI failed"
+ AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg)
+ Optional<ServiceInstance> nsi = wrapper.asBean(ServiceInstance.class)
+
+ String networkServiceInstanceName = ""
+ String networkServiceInstanceId =""
+ if(nsi.isPresent()) {
+ List<Relationship> relationshipList = nsi.get().getRelationshipList()?.getRelationship()
+ List spiWithsNssaiAndOrchStatusList = new ArrayList<>()
+
+ for (Relationship relationship : relationshipList) {
+ String relatedTo = relationship.getRelatedTo()
+ if (relatedTo == "service-instance") {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") {
+ logger.debug("**** service-instance.service-instance-id 1 :: getServiceInstanceRelationships :: "+ relationshipData.getRelationshipValue())
+ execution.setVariable("networkServiceInstanceId", relationshipData.getRelationshipValue())
+ }
+ }
+ for (RelatedToProperty relatedToProperty : relatedToPropertyList) {
+ if (relatedToProperty.getPropertyKey() == "service-instance.service-instance-name") {
+ execution.setVariable("networkServiceInstanceName", relatedToProperty.getPropertyValue())
+ }
+ }
+ }
+ //If related to is allotted-Resource
+ if (relatedTo == "allotted-resource") {
+ //get slice Profile Instance Id from allotted resource in list by nssi
+ List<String> sliceProfileInstanceIdList = new ArrayList<>()
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") {
+ sliceProfileInstanceIdList.add(relationshipData.getRelationshipValue())
+ }
+ }
+ for (String sliceProfileServiceInstanceId : sliceProfileInstanceIdList) {
+ String errorSliceProfileMsg = "Slice Profile Service Instance was not found in aai"
+
+ //Query Slice Profile Service Instance From AAI by sliceProfileServiceInstanceId
+ AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg)
+ Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class)
+ if (sliceProfileServiceInstance.isPresent()) {
+ String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus()
+ String sNssai = sliceProfileServiceInstance.get().getSliceProfiles().getSliceProfile().get(0).getSNssai()
+ if(sNssai.equals(execution.getVariable("sNssai"))) {
+ orchestrationStatus = execution.getVariable("oStatus")
+ //Slice Profile Service Instance to be updated in AAI
+ execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance)
+ }
+
+ Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>()
+ spiWithsNssaiAndOrchStatus.put("snssai", sNssai)
+ spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus)
+ spiWithsNssaiAndOrchStatusList.add(spiWithsNssaiAndOrchStatus)
+ logger.debug("service Profile's NSSAI And Orchestration Status: "+spiWithsNssaiAndOrchStatus)
+ }
+ }
+ }
+ }
+ execution.setVariable("snssaiAndOrchStatusList", spiWithsNssaiAndOrchStatusList)
+ }
+
+ logger.debug("NSSI Id: ${serviceInstanceId}, network Service Instance Id: ${networkServiceInstanceId}, serviceName: ${networkServiceInstanceName}")
+
+ //Get ServiceInstance Relationships
+ getServiceInstanceRelationships(execution)
+
+ //Get Vnf Relationships
+ getVnfRelationships(execution)
+
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****")
+ }
+
+ private void getServiceInstanceRelationships(DelegateExecution execution) {
+
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****")
+
+ String serviceInstanceId = execution.getVariable("networkServiceInstanceId")
+
+ String errorMsg = "query Network Service Instance from AAI failed"
+ AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+
+ String networkServiceModelInvariantUuid = si.get().getModelInvariantId()
+ execution.setVariable("networkServiceModelInvariantUuid", networkServiceModelInvariantUuid)
+ if(si.isPresent()) {
+ List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship()
+ for (Relationship relationship : relationshipList) {
+ String relatedTo = relationship.getRelatedTo()
+ if (relatedTo == "owning-entity") {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "owning-entity.owning-entity-id") {
+ execution.setVariable("owningEntityId", relationshipData.getRelationshipValue())
+ }
+ }
+ } else if (relatedTo == "generic-vnf") {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty()
+
+ //Get VnfId
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "generic-vnf.vnf-id") {
+ execution.setVariable("vnfId", relationshipData.getRelationshipValue())
+ }
+ }
+
+ //Get Vnf Name Check If necessary
+ for (RelatedToProperty relatedToProperty : relatedToPropertyList) {
+ if (relatedToProperty.getPropertyKey() == "generic-vnf.vnf-name") {
+ execution.setVariable("vnfName", relatedToProperty.getPropertyValue())
+ }
+ }
+ } else if (relatedTo == "project") {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "project.project-name") {
+ execution.setVariable("projectName", relationshipData.getRelationshipValue())
+ }
+ }
+ }
+ }
+
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getServiceInstanceRelationships ****")
+ }
+ }
+
+ private void getVnfRelationships(DelegateExecution execution) {
+
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getVnfRelationships ****")
+ String msg = "query Generic Vnf from AAI failed"
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId'))
+ if (!getAAIClient().exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
+ }
+ AAIResultWrapper wrapper = getAAIClient().get(uri, NotFoundException.class)
+ Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class)
+ if(vnf.isPresent()) {
+ List<Relationship> relationshipList = vnf.get().getRelationshipList()?.getRelationship()
+ for (Relationship relationship : relationshipList) {
+ String relatedTo = relationship.getRelatedTo()
+ if (relatedTo == "tenant") {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "tenant.tenant-id") {
+ execution.setVariable("tenantId", relationshipData.getRelationshipValue())
+ }
+ }
+ } else if (relatedTo == "cloud-region") {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "cloud-region.cloud-owner") {
+ execution.setVariable("cloudOwner", relationshipData.getRelationshipValue())
+ } else if (relationshipData.getRelationshipKey() == "cloud-region.cloud-region-id") {
+ execution.setVariable("lcpCloudRegionId", relationshipData.getRelationshipValue())
+ }
+ }
+ } else if (relatedTo == "platform") {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "platform.platform-name") {
+ execution.setVariable("platformName", relationshipData.getRelationshipValue())
+ }
+ }
+ } else if (relatedTo == "line-of-business") {
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "line-of-business.line-of-business-name") {
+ execution.setVariable("lineOfBusinessName", relationshipData.getRelationshipValue())
+ }
+ }
+ }
+ }
+ }
+ } catch(BpmnError e){
+ throw e
+ } catch (Exception ex){
+ msg = "Exception in getVnfRelationships " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getVnfRelationships ****")
+ }
+
+
+ /**
+ * query AAI
+ * @param execution
+ * @param aaiObjectType
+ * @param instanceId
+ * @return AAIResultWrapper
+ */
+ private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) {
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: queryAAI ****")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("serviceType")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId)
+ if (!getAAIClient().exists(resourceUri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg)
+ }
+ AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: queryAAI ****")
+ return wrapper
+ }
+
+ public void getServiceVNFAndVFsFromCatalogDB(DelegateExecution execution) {
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getServiceVNFAndVFsFromCatalogDB ****")
+ String serviceVnfs="";
+ String msg=""
+ String modelInvariantUuid = execution.getVariable("networkServiceModelInvariantUuid")
+ try{
+ CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
+ String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution, modelInvariantUuid)
+ logger.debug("***** JSON IS: "+json)
+ serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: ""
+ String serviceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.modelInfo") ?: ""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ execution.setVariable("serviceVnfs",serviceVnfs)
+ logger.debug("***** serviceVnfs is: "+ serviceVnfs)
+ }catch(BpmnError e){
+ throw e
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getServiceVNFAndVFsFromCatalogDB ****")
+ }
+
+ public void prepareSOMacroRequestPayload(DelegateExecution execution) {
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareSOMacroRequestPayLoad ****")
+ String json = execution.getVariable("serviceVnfs")
+ logger.debug(">>>> json "+json)
+ List<Object> vnfList = mapper.readValue(json, List.class);
+ logger.debug("vnfList: "+vnfList)
+ Map<String,Object> serviceMap = mapper.readValue(execution.getVariable("serviceModelInfo"), Map.class);
+ ModelInfo serviceModelInfo = new ModelInfo()
+ serviceModelInfo.setModelType(ModelType.service)
+ serviceModelInfo.setModelInvariantId(serviceMap.get("modelInvariantUuid"))
+ serviceModelInfo.setModelVersionId(serviceMap.get("modelUuid"))
+ serviceModelInfo.setModelName(serviceMap.get("modelName"))
+ serviceModelInfo.setModelVersion(serviceMap.get("modelVersion"))
+ logger.debug("serviceModelInfo: "+serviceModelInfo)
+ //List of Vnfs
+ List<Object> vnfModelInfoList = new ArrayList<>()
+
+ Map vnfMap = vnfList.get(0)
+ ModelInfo vnfModelInfo = vnfMap.get("modelInfo")
+ logger.debug("vnfModelInfo "+vnfModelInfo)
+
+ //List of VFModules
+ List<Map<String, Object>> vfModuleList = vnfMap.get("vfModules")
+ logger.debug("vfModuleList "+vfModuleList)
+
+ //List of VfModules
+ List<ModelInfo> vfModelInfoList = new ArrayList<>()
+
+ //Traverse VFModules List and add in vfModelInfoList
+ for (vfModule in vfModuleList) {
+ ModelInfo vfModelInfo = vfModule.get("modelInfo")
+ logger.debug("vfModelInfo "+vfModelInfo)
+ vfModelInfoList.add(vfModelInfo)
+ }
+ //RequestInfo
+ RequestInfo requestInfo = new RequestInfo()
+
+ //Dummy Product FamilyId
+ requestInfo.setProductFamilyId("test1234")
+ requestInfo.setSource("VID")
+ requestInfo.setInstanceName(execution.getVariable("networkServiceInstanceName"))
+ requestInfo.setSuppressRollback(false)
+ requestInfo.setRequestorId("NBI")
+
+ //Service Level InstanceParams
+ List<Map<String, Object>> serviceParams = new ArrayList<>()
+ Map<String, Object> serviceParamsValues = new LinkedHashMap<>()
+ serviceParams.add(serviceParamsValues)
+
+ //Cloud Configuration
+ CloudConfiguration cloudConfiguration = new CloudConfiguration()
+ cloudConfiguration.setLcpCloudRegionId(execution.getVariable("lcpCloudRegionId"))
+ cloudConfiguration.setTenantId(execution.getVariable("tenantId"))
+ cloudConfiguration.setCloudOwner(execution.getVariable("cloudOwner"))
+
+ //VFModules List
+ List<Map<String, Object>> vfModules = new ArrayList<>()
+ for (ModelInfo vfModuleModelInfo : vfModelInfoList) {
+ //Individual VFModule List
+ Map<String, Object> vfModuleValues = new LinkedHashMap<>()
+ vfModuleValues.put("modelInfo", vfModuleModelInfo)
+ vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName())
+
+ //VFModule InstanceParams should be empty or this field should not be there?
+ List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>()
+ vfModuleValues.put("instanceParams", vfModuleInstanceParams)
+ }
+
+ //Vnf intsanceParams
+ Map<String, Object> sliceProfile = mapper.readValue(execution.getVariable("sliceProfile"), Map.class);
+
+ List vnfInstanceParamsList = new ArrayList<>()
+ String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution)
+ vnfInstanceParamsList.add(supportedsNssaiJson)
+
+ Platform platform = new Platform()
+ platform.setPlatformName(execution.getVariable("platform"))
+
+ LineOfBusiness lineOfbusiness = new LineOfBusiness()
+ lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness"))
+
+ //Vnf Values
+ Map<String, Object> vnfValues = new LinkedHashMap<>()
+ vnfValues.put("lineOfBusiness", lineOfbusiness)
+ vnfValues.put("platform", platform)
+ vnfValues.put("productFamilyId", "test1234")
+ vnfValues.put("cloudConfiguration", cloudConfiguration)
+ vnfValues.put("vfModules", vfModules)
+ vnfValues.put("modelInfo", vnfModelInfo)
+ vnfValues.put("instanceName", execution.getVariable("vnfInstanceName"))
+ vnfValues.put("instanceParams",vnfInstanceParamsList)
+
+ vnfModelInfoList.add(vnfValues)
+ //Service Level Resources
+ Map<String, Object> serviceResources = new LinkedHashMap<>()
+ serviceResources.put("vnfs", vnfModelInfoList)
+
+ //Service Values
+ Map<String, Object> serviceValues = new LinkedHashMap<>()
+ serviceValues.put("modelInfo", serviceModelInfo)
+ serviceValues.put("instanceName", execution.getVariable("networkServiceInstanceName"))
+ serviceValues.put("resources", serviceResources)
+ serviceValues.put("instanceParams", serviceParams)
+
+ //UserParams Values
+ Map<String, Object> userParamsValues = new LinkedHashMap<>()
+
+ Map<String, Object> homingSolution = new LinkedHashMap<>()
+ homingSolution.put("Homing_Solution", "none")
+
+ userParamsValues.put("service", serviceValues)
+
+ //UserParams
+ List<Map<String, Object>> userParams = new ArrayList<>()
+ userParams.add(homingSolution)
+ userParams.add(userParamsValues)
+
+ //Request Parameters
+ RequestParameters requestParameters = new RequestParameters()
+ requestParameters.setaLaCarte(false)
+ requestParameters.setSubscriptionServiceType(execution.getVariable("serviceType"))
+ requestParameters.setUserParams(userParams)
+
+ //SubscriberInfo
+ SubscriberInfo subscriberInfo = new SubscriberInfo()
+ subscriberInfo.setGlobalSubscriberId(execution.getVariable("globalSubscriberId"))
+
+ //Owning Entity
+ OwningEntity owningEntity = new OwningEntity()
+ owningEntity.setOwningEntityId(execution.getVariable("owningEntityId"))
+
+ //Project
+ Project project = new Project()
+ project.setProjectName(execution.getVariable("projectName"))
+
+ RequestDetails requestDetails = new RequestDetails()
+ requestDetails.setModelInfo(serviceModelInfo)
+ requestDetails.setSubscriberInfo(subscriberInfo)
+ requestDetails.setRequestInfo(requestInfo)
+ requestDetails.setRequestParameters(requestParameters)
+ requestDetails.setCloudConfiguration(cloudConfiguration)
+ requestDetails.setOwningEntity(owningEntity)
+ requestDetails.setProject(project)
+
+ Map<String, Object> requestDetailsMap = new LinkedHashMap<>()
+ requestDetailsMap.put("requestDetails", requestDetails)
+ String requestPayload = mapper.writeValueAsString(requestDetailsMap)
+
+ logger.debug("requestDetails "+requestPayload)
+ execution.setVariable("requestPayload", requestPayload)
+
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareSOMacroRequestPayLoad ****")
+ }
+
+ private String prepareVnfInstanceParamsJson(DelegateExecution execution) {
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****")
+ List instanceParamsvalues = execution.getVariable("snssaiAndOrchStatusList")
+ Map<String, Object> nSsai= new LinkedHashMap<>()
+ nSsai.put("sNssai", instanceParamsvalues)
+
+ String supportedsNssaiJson = mapper.writeValueAsString(nSsai)
+ //SupportedNssai
+ Map<String, Object> supportedNssai= new LinkedHashMap<>()
+ supportedNssai.put("supportedNssai", supportedsNssaiJson)
+ logger.debug("**** supportedsNssaiJson**** "+supportedNssai)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****")
+ return supportedNssai
+ }
+
+ public void sendPutRequestToSOMacro(DelegateExecution execution) {
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: sendPutRequestToSOMacro ****")
+ try {
+ String msoEndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution)
+ String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+execution.getVariable("networkServiceInstanceId")+"/vnfs/"+execution.getVariable("vnfId")
+
+ String requestBody = execution.getVariable("requestPayload")
+
+ String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
+ String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
+ String basicAuthValue = utils.encrypt(basicAuth, msoKey)
+ String encodeString = utils.getBasicAuth(basicAuthValue, msoKey)
+
+ HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
+ httpClient.addAdditionalHeader("Authorization", encodeString)
+ httpClient.addAdditionalHeader("Accept", "application/json")
+ Response httpResponse = httpClient.put(requestBody)
+ handleSOResponse(httpResponse, execution)
+ } catch (BpmnError e) {
+ throw e
+ } catch (any) {
+ String msg = Prefix+" Exception in DoAllocateCoreSharedSlice " + any.getCause()
+ logger.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: sendPostRequestToSOMacro ****")
+ }
+
+ /**
+ * Handle SO Response for PUT and prepare update operation status
+ * @param execution
+ */
+ private void handleSOResponse(Response httpResponse, DelegateExecution execution){
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: handleSOResponse ****")
+
+ int soResponseCode = httpResponse.getStatus()
+ logger.debug("soResponseCode : "+soResponseCode)
+
+ if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) {
+ String soResponse = httpResponse.readEntity(String.class)
+ String operationId = execution.getVariable("operationId")
+ def macroOperationId = jsonUtil.getJsonValue(soResponse, "operationId")
+ execution.setVariable("macroOperationId", macroOperationId)
+ execution.setVariable("isSOTimeOut", "no")
+ execution.setVariable("isSOResponseSucceed","yes")
+ }
+ else {
+ String serviceName = execution.getVariable("serviceInstanceName")
+ execution.setVariable("isSOResponseSucceed","no")
+ prepareFailedOperationStatusUpdate(execution)
+ }
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: handleSOResponse ****")
+ }
+
+ /**
+ * prepare to call sub process CheckProcessStatus
+ * @param execution
+ */
+ void prepareCallCheckProcessStatus(DelegateExecution execution){
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareCallCheckProcessStatus ****")
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ execution.setVariable("successConditions", successConditions)
+ def errorConditions = new ArrayList<>()
+ errorConditions.add("error")
+ execution.setVariable("errorConditions", errorConditions)
+ execution.setVariable("processServiceType", "Network service")
+ execution.setVariable("subOperationType", "PUT")
+ execution.setVariable("initProgress", 20)
+ execution.setVariable("endProgress",90)
+ execution.setVariable("timeOut", TIMEOUT)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareCallCheckProcessStatus ****")
+ }
+
+ void prepareUpdateResourceOperationStatus(DelegateExecution execution) {
+
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: prepareUpdateResourceOperationStatus ****")
+ //Prepare Update Status for PUT failure and success
+ if(execution.getVariable("isTimeOut").equals("YES")) {
+ logger.debug("TIMEOUT - SO PUT Failure")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure")
+ } else {
+ execution.setVariable("progress", "100")
+ execution.setVariable("status", "finished")
+ execution.setVariable("operationContent", "AllocteCoreNSSI successful.")
+ logger.debug("prepareFailureStatus,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}")
+ }
+ setResourceOperationStatus(execution)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareUpdateResourceOperationStatus ****")
+ }
+
+ /**
+ * prepare ResourceOperation status
+ * @param execution
+ * @param operationType
+ */
+ private void setResourceOperationStatus(DelegateExecution execution) {
+ logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: setResourceOperationStatus ****")
+ String serviceId = execution.getVariable("nssiId")
+ String jobId = execution.getVariable("jobId")
+ String nsiId = execution.getVariable("nsiId")
+ String operationType = execution.getVariable("operationType")
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
+ resourceOperationStatus.setServiceId(serviceId)
+ resourceOperationStatus.setOperationId(jobId)
+ resourceOperationStatus.setResourceTemplateUUID(nsiId)
+ resourceOperationStatus.setOperType(operationType)
+ resourceOperationStatus.setStatus("finished")
+ resourceOperationStatus.setProgress("100")
+ resourceOperationStatus.setStatusDescription("Core Allocate successful")
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
+ logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: setResourceOperationStatus ****")
+ }
+
+ void prepareFailedOperationStatusUpdate(DelegateExecution execution){
+ logger.debug(Prefix + " **** Enter DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****")
+ String serviceId = execution.getVariable("nssiId")
+ String jobId = execution.getVariable("jobId")
+ String nsiId = execution.getVariable("nsiId")
+ String operationType = execution.getVariable("operationType")
+
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
+ resourceOperationStatus.setServiceId(serviceId)
+ resourceOperationStatus.setOperationId(jobId)
+ resourceOperationStatus.setResourceTemplateUUID(nsiId)
+ resourceOperationStatus.setOperType(operationType)
+ resourceOperationStatus.setProgress(0)
+ resourceOperationStatus.setStatus("failed")
+ resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed")
+ requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
+ logger.debug(Prefix + " **** Exit DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****")
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy
new file mode 100644
index 0000000000..dc7a429c2c
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSITest.groovy
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import static org.junit.Assert.*
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.times
+import static org.mockito.ArgumentMatchers.eq
+
+class DoAllocateCoreNSSITest extends MsoGroovyTest {
+
+ @Before
+ void init() throws IOException {
+ super.init("DoAllocateCoreNSSI")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ public void testPreProcessRequest() {
+
+ String sliceParams="""{
+ "sliceProfile": {
+ "snssaiList": [
+ "001-100001"
+ ],
+ "sliceProfileId": "ab9af40f13f721b5f13539d87484098",
+ "plmnIdList": [
+ "460-00",
+ "460-01"
+ ],
+ "perfReq": {
+ "perfReqEmbbList ": [{
+ "activityFactor": 50
+ }]
+ },
+ "maxNumberofUEs": 200,
+ "coverageAreaTAList": [
+ "1",
+ "2",
+ "3",
+ "4"
+ ],
+ "latency": 2,
+ "resourceSharingLevel": "non-shared"
+ },
+ "endPoints": [{
+ "nodeId": "",
+ "additionalInfo": {
+ "xxx": "xxx"
+ }
+ },
+ {
+ "nodeId": "",
+ "additionalInfo": {
+ "xxx": "xxx"
+ }
+ }
+ ],
+ "nsiInfo": {
+ "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX",
+ "nsiName": "eMBB-001"
+ },
+ "scriptName": "AN1"
+}"""
+ String expected = """{"plmnIdList":["460-00","460-01"],"sliceProfileId":"ab9af40f13f721b5f13539d87484098","maxNumberofUEs":200,"latency":2,"snssaiList":["001-100001"],"perfReq":{"perfReqEmbbList ":[{"activityFactor":50}]},"coverageAreaTAList":["1","2","3","4"],"resourceSharingLevel":"non-shared"}"""
+ when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams)
+ DoAllocateCoreNSSI allocateNssi = new DoAllocateCoreNSSI()
+ allocateNssi.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("sliceProfile"), captor.capture())
+ def sliceProfile = captor.getValue()
+ assertEquals(expected, sliceProfile)
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture() as String, captor.capture())
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy
new file mode 100644
index 0000000000..1eddf66b86
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import static org.junit.Assert.*
+
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import com.fasterxml.jackson.databind.ObjectMapper
+
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.eq
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+
+class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest {
+
+ @Before
+ void init() throws IOException {
+ super.init("DoAllocateCoreNonSharedSlice")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ public void testPreProcessRequest() {
+
+ String networkServiceModelInfo=""" {
+ "modelName" : "5GC-eMBB Service Proxy",
+ "modelUuid" : "b666119e-4400-47c6-a0c1-bbe050a33b47",
+ "modelInvariantUuid" : "a26327e1-4a9b-4883-b7a5-5f37dcb7405a",
+ "modelVersion" : "1.0",
+ "modelCustomizationUuid" : "cbc12c2a-67e6-4336-9236-eaf51eacdc75",
+ "modelInstanceName" : "5gcembb_proxy 0"
+ }"""
+
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("123456")
+ when(mockExecution.getVariable("networkServiceModelInfo")).thenReturn(networkServiceModelInfo)
+
+ DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice()
+ allocateNssi.preProcessRequest(mockExecution)
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelUuid"), captor.capture())
+ captor.getValue()
+ assertEquals("b666119e-4400-47c6-a0c1-bbe050a33b47", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceName"), captor.capture())
+ assertEquals("5GC-eMBB", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("orchestrationStatus"), captor.capture())
+ assertEquals("created", captor.getValue())
+ Mockito.verify(mockExecution, times(4)).setVariable(captor.capture() as String, captor.capture())
+ }
+
+ @Test
+ void testPrepareServiceOrderRequest() {
+
+ String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }"
+ when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile)
+ when(mockExecution.getVariable("serviceType")).thenReturn("5g")
+ when(mockExecution.getVariable("networkServiceName")).thenReturn("5g_embb")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("networkServiceModelUuid")).thenReturn("12345")
+
+ DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice()
+ allocateNssi.prepareServiceOrderRequest(mockExecution)
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("serviceOrderRequest"), captor.capture())
+ String value = captor.getValue()
+ assertNotNull(value)
+ }
+
+ @Test
+ void testRetrieveServiceCharacteristicsAsKeyValue() {
+
+ String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }"
+ Map<String, Object> ServiceCharacteristicValue = new LinkedHashMap<>()
+ Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>()
+ ServiceCharacteristicValueObject.put("serviceCharacteristicValue","001-100001")
+ ServiceCharacteristicValue.put("name", "snssai")
+ ServiceCharacteristicValue.put("value", ServiceCharacteristicValueObject)
+
+ List expectedList= new ArrayList()
+ expectedList.add(ServiceCharacteristicValue)
+
+ ObjectMapper objectMapper = new ObjectMapper()
+ Map<String, Object> serviceCharacteristic = objectMapper.readValue(sliceProfile, Map.class);
+
+ DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice()
+ List characteristicList=allocateNssi.retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic)
+
+ assertEquals(expectedList, characteristicList)
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy
new file mode 100644
index 0000000000..e5799eca66
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy
@@ -0,0 +1,646 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import static org.junit.Assert.*
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.mockito.Mockito
+import org.onap.aaiclient.client.aai.AAIObjectType
+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 static org.mockito.Mockito.spy
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.verify
+import static org.mockito.Mockito.when
+import static org.mockito.ArgumentMatchers.eq
+
+import javax.ws.rs.NotFoundException
+
+class DoAllocateCoreSharedSliceTest extends MsoGroovyTest {
+
+ DoAllocateCoreSharedSlice allocate = new DoAllocateCoreSharedSlice()
+
+ @Before
+ void init() throws IOException {
+ super.init("DoAllocateCoreSharedSlice")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ void testPreProcessRequest(){
+
+ String solutions = """ [
+ {
+ "invariantUUID": "y7685f64-5717-4562-b3fc-2c963f66afa6",
+ "UUID": "8u785f64-5717-4562-b3fc-2c963f66afa6",
+ "NSSIName": "embb-core-ser",
+ "NSSIId": "f4485f64-5717-4562-b3fc-2c963f66afa6",
+ "matchLevel": {
+ "blob":"content"
+ }
+ }
+ ]"""
+ String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }"
+
+ setUpBaseMockData()
+
+ when(mockExecution.getVariable("solutions")).thenReturn(solutions)
+ when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile)
+
+ allocate.preProcessRequest(mockExecution)
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("nssiId"), captor.capture())
+ def nssiId = captor.getValue()
+ assertEquals("f4485f64-5717-4562-b3fc-2c963f66afa6", nssiId)
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("sNssai"), captor.capture())
+ def sNssai = captor.getValue()
+ assertEquals("001-100001", sNssai)
+
+ Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture())
+ List<ExecutionEntity> values = captor.getAllValues()
+ assertNotNull(values)
+ }
+
+ @Test
+ public void tesPrepareSOMacroRequestPayload() {
+
+ String json ="{ \"serviceResources\" : {\r\n\t\"modelInfo\" : {\r\n\t\t\"modelName\" : \"MSOTADevInfra_vSAMP10a_Service\",\r\n\t\t\"modelUuid\" : \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\t\t\"modelInvariantUuid\" : \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\t\t\"modelVersion\" : \"1.0\"\r\n\t},\r\n\t\"serviceType\" : \"PortMirroring\",\r\n\t\"serviceRole\" : \"InfraRole\",\r\n\t\"environmentContext\" : \"Luna\",\r\n\t\"workloadContext\" : \"Oxygen\",\r\n\t\"serviceVnfs\": [\r\n\t\r\n\t\t{ \"modelInfo\" : {\r\n\t\t\t\"modelName\" : \"vSAMP10a\",\r\n\t\t\t\"modelUuid\" : \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelInvariantUuid\" : \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\"modelCustomizationUuid\" : \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\t\t\t\"modelInstanceName\" : \"vSAMP10a 1\"\r\n\t\t\t},\r\n\t\t\"toscaNodeType\" : \"VF\",\r\n\t\t\"nfFunction\" \t: null,\r\n\t\t\"nfType\" \t\t: null,\r\n\t\t\"nfRole\" \t\t: null,\r\n\t\t\"nfNamingCode\" \t: null,\r\n\t\t\"multiStageDesign\"\t\t: null,\r\n\t\t\t\"vfModules\": [\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest4\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"025606c1-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba01a\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest3\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560575-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"NetworkFqdnTest5\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"025607e4-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"06bd0a18-65c0-4418-83c7-5b0d14cba01a\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"label\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::PCM::module-2\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"7774b4e4-7d37-11e7-bb31-be2e44b06b34\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"93e9c1d2-7d37-11e7-bb31-be2e44b06b34\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"6728bee8-7d3a-11e7-bb31-be2e44b06b34\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::PCM::module-1\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n\t\t\t\t\t},\t\t\"isBase\" : false,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 0,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10aDEV::base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"base\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10a::base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560de2-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"2\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_36e76920-ef30-4793-9979-cbd7d4b2bfc4\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"base\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"base::module-0\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02561381-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"1\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_51baae4c-b7c7-4f57-b77e-6e01acca89e5\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"module-0\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"modelInfo\" : { \r\n\t\t\t\t\t\t\"modelName\" : \"vSAMP10a::PCM::module-1\",\r\n\t\t\t\t\t\t\"modelUuid\" : \"02560f1b-4223-11e7-9252-005056850d2e\",\r\n\t\t\t\t\t\t\"modelInvariantUuid\" : null,\r\n\t\t\t\t\t\t\"modelVersion\" : \"1\",\r\n\t\t\t\t\t\t\"modelCustomizationUuid\" : \"MIGRATED_e9be2ed7-45b6-479c-b06e-9093899f8ce8\"\r\n\t\t\t\t\t},\t\t\"isBase\" : true,\r\n\t\t\t\t\t\"vfModuleLabel\" : \"PCM\",\r\n\t\t\t\t\t\"initialCount\" : 1,\r\n\t\t\t\t\t\"hasVolumeGroup\" : true\r\n\t\t\t\t}\r\n\t\t\t]\r\n\t\t}\r\n\t],\r\n\t\"serviceNetworks\": [],\r\n\t\"serviceAllottedResources\": [\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Tunnel_Xconn\",\r\n\t\t\t\t\"modelUuid\" : \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"5b9bee43-f537-4fb3-9e8b-4de9f714d28a\",\r\n\t\t\t\t\"modelInstanceName\" : \"Pri_Tunnel_Xconn 9\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : null,\r\n\t\t\t\"allottedResourceType\" : null,\r\n\t\t\t\"allottedResourceRole\" : null,\r\n\t\t\t\"providingServiceModelInvariantUuid\" : null,\r\n\t\t\t\"nfFunction\" : null,\r\n\t\t\t\"nfType\" : null,\r\n\t\t\t\"nfRole\" : null,\r\n\t\t\t\"nfNamingCode\" : null\r\n\t\t}\r\n\t],\r\n\t\"serviceConfigs\": [\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Mulder\",\r\n\t\t\t\t\"modelUuid\" : \"025606c1-4fff-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"025606c1-4eee-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"025606c1-4ddd-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInstanceName\" : \"X_FILES_001\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : \"Scully\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"modelInfo\" : {\r\n\t\t\t\t\"modelName\" : \"Krychuk\",\r\n\t\t\t\t\"modelUuid\" : \"025606c1-5fff-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInvariantUuid\" : \"025606c1-5eee-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelVersion\" : \"1.0\",\r\n\t\t\t\t\"modelCustomizationUuid\" : \"025606c1-5ddd-11e7-9252-005056850d2e\",\r\n\t\t\t\t\"modelInstanceName\" : \"X_FILES_002\"\r\n\t\t\t},\r\n\t\t\t\"toscaNodeType\" : \"Skinner\"\r\n\t\t}\r\n\t]\r\n\t}}\r\n\r\n"
+ String sliceProfile = "{\r\n \"snssaiList\": [ \r\n \"001-100001\"\r\n ],\r\n \"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n \"plmnIdList\": [\r\n \"460-00\",\r\n \"460-01\"\r\n ],\r\n \"perfReq\": {\r\n \"perfReqEmbbList \": [\r\n {\r\n \"activityFactor\": 50\r\n }\r\n ]\r\n },\r\n \"maxNumberofUEs\": 200, \r\n \"coverageAreaTAList\": [ \r\n \"1\",\r\n \"2\",\r\n \"3\",\r\n \"4\"\r\n ],\r\n \"latency\": 2,\r\n \"resourceSharingLevel\": \"non-shared\" \r\n }"
+ String vnfs="[{\"toscaNodeType\":\"VF\",\"vfModules\":[{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\"modelName\":\"NetworkFqdnTest4\",\"modelVersion\":\"2.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba01a\",\"modelUuid\":\"025606c1-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\"modelName\":\"NetworkFqdnTest3\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d13cba0bb\",\"modelUuid\":\"02560575-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":true},{\"initialCount\":0,\"vfModuleLabel\":\"label\",\"modelInfo\":{\"modelInvariantUuid\":\"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\"modelName\":\"NetworkFqdnTest5\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"06bd0a18-65c0-4418-83c7-5b0d14cba01a\",\"modelUuid\":\"025607e4-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":false},{\"initialCount\":0,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":\"93e9c1d2-7d37-11e7-bb31-be2e44b06b34\",\"modelName\":\"vSAMP10aDEV::PCM::module-2\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"6728bee8-7d3a-11e7-bb31-be2e44b06b34\",\"modelUuid\":\"7774b4e4-7d37-11e7-bb31-be2e44b06b34\"},\"hasVolumeGroup\":true,\"isBase\":false},{\"initialCount\":0,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":\"64efd51a-2544-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10aDEV::PCM::module-1\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"b4ea86b4-253f-11e7-93ae-92361f002671\",\"modelUuid\":\"066de97e-253e-11e7-93ae-92361f002671\"},\"hasVolumeGroup\":true,\"isBase\":false},{\"initialCount\":1,\"vfModuleLabel\":\"base\",\"modelInfo\":{\"modelInvariantUuid\":\"78ca26d0-246d-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10aDEV::base::module-0\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"cb82ffd8-252a-11e7-93ae-92361f002671\",\"modelUuid\":\"20c4431c-246d-11e7-93ae-92361f002671\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"base\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"vSAMP10a::base::module-0\",\"modelVersion\":\"2\",\"modelCustomizationUuid\":\"MIGRATED_36e76920-ef30-4793-9979-cbd7d4b2bfc4\",\"modelUuid\":\"02560de2-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"module-0\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"base::module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"MIGRATED_51baae4c-b7c7-4f57-b77e-6e01acca89e5\",\"modelUuid\":\"02561381-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":false,\"isBase\":true},{\"initialCount\":1,\"vfModuleLabel\":\"PCM\",\"modelInfo\":{\"modelInvariantUuid\":null,\"modelName\":\"vSAMP10a::PCM::module-1\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"MIGRATED_e9be2ed7-45b6-479c-b06e-9093899f8ce8\",\"modelUuid\":\"02560f1b-4223-11e7-9252-005056850d2e\"},\"hasVolumeGroup\":true,\"isBase\":true}],\"modelInfo\":{\"modelInvariantUuid\":\"2fff5b20-214b-11e7-93ae-92361f002671\",\"modelName\":\"vSAMP10a\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002671\",\"modelInstanceName\":\"vSAMP10a 1\",\"modelUuid\":\"ff2ae348-214a-11e7-93ae-92361f002671\"},\"nfRole\":null,\"nfType\":null,\"multiStageDesign\":null,\"nfFunction\":null,\"nfNamingCode\":null}]\r\n"
+ String service = "{\r\n \"modelName\" : \"eMBB-NSST\",\r\n \"modelUuid\" : \"ecfa2329-8765-4665-84e0-a32a2ac2be90\",\r\n \"modelInvariantUuid\" : \"2eeeb5ff-4655-47d8-8aa3-044682246b60\",\r\n \"modelVersion\" : \"1.0\"\r\n }"
+
+ when(mockExecution.getVariable("serviceVnfs")).thenReturn(vnfs)
+
+ when(mockExecution.getVariable("serviceType")).thenReturn("5g")
+ when(mockExecution.getVariable("vnfs")).thenReturn(vnfs)
+ when(mockExecution.getVariable("serviceModelInfo")).thenReturn(service)
+ when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile)
+ allocate.prepareSOMacroRequestPayload(mockExecution)
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("requestPayload"), captor.capture())
+ assertNotNull(captor.getValue())
+ }
+
+ @Test
+ void testPrepareVnfInstanceParamsJson() {
+ List<Map<String, Object>> snssaiList = new ArrayList<>()
+ Map<String, Object> snssaiMap = new LinkedHashMap<>()
+ snssaiMap.put("snssai", "01-5C83F071")
+ snssaiMap.put("status", "activated")
+ snssaiList.add(snssaiMap)
+ Map<String, Object> snssaiMap1 = new LinkedHashMap<>()
+ snssaiMap1.put("snssai", "01-5B179BD4")
+ snssaiMap1.put("status", "activated")
+ snssaiList.add(snssaiMap1)
+
+ when(mockExecution.getVariable("snssaiAndOrchStatusList")).thenReturn(snssaiList)
+
+ String returnedJsonAsString= allocate.prepareVnfInstanceParamsJson(mockExecution)
+ String expectedJsonAsString = """{supportedNssai={"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}}"""
+ assertEquals(expectedJsonAsString, returnedJsonAsString)
+ }
+
+ @Test
+ void testGetNetworkInstanceWithSPInstanceAssociatedWithNssiId(){
+
+ setUpBaseMockData()
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ DoAllocateCoreSharedSlice obj = spy(DoAllocateCoreSharedSlice.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX")
+ when(client.exists(resourceUri1)).thenReturn(true)
+ AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn())
+ when(client.get(resourceUri1, NotFoundException.class)).thenReturn(wrapper1)
+
+ //networkServiceInstanceId
+ when(mockExecution.getVariable("networkServiceInstanceId")).thenReturn("206535e7-77c9-4036-9387-3f1cf57b4379")
+
+ AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "206535e7-77c9-4036-9387-3f1cf57b4379")
+ when(client.exists(resourceUri2)).thenReturn(true)
+ AAIResultWrapper wrapper2 = new AAIResultWrapper(mockQueryNS())
+ when(client.get(resourceUri2, NotFoundException.class)).thenReturn(wrapper2)
+
+ //Check Vnf
+ when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912")
+ AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "eeb66c6f-36bd-47ad-8294-48f46b1aa912")
+ when(client.exists(resourceUri3)).thenReturn(true)
+ AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf())
+ when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3)
+
+
+ //Allotted Resources-1
+ AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "0d3d3cce-46a8-486d-816a-954e71697c4e")
+ when(client.exists(resourceUri4)).thenReturn(true)
+ AAIResultWrapper wrapper4 = new AAIResultWrapper(mockServiceProfile1())
+ when(client.get(resourceUri4, NotFoundException.class)).thenReturn(wrapper4)
+
+ //Allotted Resources-2
+ AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "1c7046f2-a5a3-4d7f-9da8-388ee641a795")
+ when(client.exists(resourceUri5)).thenReturn(true)
+ AAIResultWrapper wrapper5 = new AAIResultWrapper(mockServiceProfile2())
+ when(client.get(resourceUri5, NotFoundException.class)).thenReturn(wrapper5)
+
+ obj.getNetworkInstanceAssociatedWithNssiId(mockExecution)
+
+ //networkServiceInstanceId
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceId"), captor.capture())
+ assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceInstanceName"), captor.capture())
+ assertEquals("nsi_DemoEmbb", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelInvariantUuid"), captor.capture())
+ assertEquals("848c5656-5594-4d41-84bb-7afc7c64765c", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("owningEntityId"), captor.capture())
+ assertEquals("OE-generic", captor.getValue())
+
+ //assertEquals("206535e7-77c9-4036-9387-3f1cf57b4379", captor.getValue())
+
+ //VnfId
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("vnfId"), captor.capture())
+ assertEquals("eeb66c6f-36bd-47ad-8294-48f46b1aa912", captor.getValue())
+
+ //
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("snssaiAndOrchStatusList"), captor.capture())
+ List<Map<String, Object>> snssaiList = new ArrayList<>()
+ Map<String, Object> snssaiMap = new LinkedHashMap<>()
+ snssaiMap.put("snssai", "01-5C83F071")
+ snssaiMap.put("orchestrationStatus", "activated")
+ snssaiList.add(snssaiMap)
+ Map<String, Object> snssaiMap1 = new LinkedHashMap<>()
+ snssaiMap1.put("snssai", "01-5B179BD4")
+ snssaiMap1.put("orchestrationStatus", "activated")
+ snssaiList.add(snssaiMap1)
+ assertEquals(snssaiList, captor.getValue())
+
+ //Verify Project
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("projectName"), captor.capture())
+ assertEquals("Project-generic", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("tenantId"), captor.capture())
+ assertEquals("3d5819f1542e4ef9a4ccb0bcb278ca10", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("cloudOwner"), captor.capture())
+ assertEquals("k8scloudowner", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("lcpCloudRegionId"), captor.capture())
+ assertEquals("k8sregion", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("platformName"), captor.capture())
+ assertEquals("test", captor.getValue())
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("lineOfBusinessName"), captor.capture())
+ assertEquals("LOB-Demonstration", captor.getValue())
+
+ }
+
+ void setUpBaseMockData() {
+
+ String sliceParams ="""{
+ "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX",
+ "snssaiList": [
+ "01-5B179BD4"
+ ],
+ "sliceProfileId": "ab9af40f13f721b5f13539d87484098"
+ }"""
+
+ when(mockExecution.getVariable("msoRequestId")).thenReturn("5ad89cf9-0569-4a93-4509-d8324321e2be")
+ when(mockExecution.getVariable("serviceInstanceID")).thenReturn("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX")
+ when(mockExecution.getVariable("nsiId")).thenReturn("NSI-M-001-HDBNJ-NSMF-01-A-ZX")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G")
+ when(mockExecution.getVariable("operationType")).thenReturn("deactivateInstance")
+ when(mockExecution.getVariable("jobId")).thenReturn("5ad89cf9-0569-4a93-9999-d8324321e2be")
+ when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams)
+ }
+
+ String mockQueryNS() {
+ return """
+ {
+ "service-instance-id": "206535e7-77c9-4036-9387-3f1cf57b4379",
+ "service-instance-name": "nsi_DemoEmbb",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-invariant-id": "848c5656-5594-4d41-84bb-7afc7c64765c",
+ "model-version-id": "2de92587-3395-44e8-bb2c-b9529747e580",
+ "resource-version": "1599228110527",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/206535e7-77c9-4036-9387-3f1cf57b4379/service-data/service-topology/",
+ "orchestration-status": "Assigned",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "owning-entity",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v19/business/owning-entities/owning-entity/OE-generic",
+ "relationship-data": [{
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "OE-generic"
+ }]
+ }, {
+ "related-to": "generic-vnf",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v19/network/generic-vnfs/generic-vnf/eeb66c6f-36bd-47ad-8294-48f46b1aa912",
+ "relationship-data": [{
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "eeb66c6f-36bd-47ad-8294-48f46b1aa912"
+ }],
+ "related-to-property": [{
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "vfwuctest 0"
+ }]
+ }, {
+ "related-to": "project",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v19/business/projects/project/Project-generic",
+ "relationship-data": [{
+ "relationship-key": "project.project-name",
+ "relationship-value": "Project-generic"
+ }]
+ }]
+ }
+}
+ """
+ }
+
+ String mockQueryVnf() {
+
+ return """
+ {
+ "vnf-id": "eeb66c6f-36bd-47ad-8294-48f46b1aa912",
+ "vnf-name": "vfwuctest 0",
+ "vnf-type": "vfwuctest/null",
+ "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "prov-status": "PREPROV",
+ "orchestration-status": "ConfigAssigned",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1599228155361",
+ "model-invariant-id": "1086e068-c932-4b61-ae3b-2d2eb0cbe3ec",
+ "model-version-id": "7fbb28cf-7dfc-447a-892c-4a3130b371d2",
+ "model-customization-id": "471b3188-e8f2-470b-9f4d-89e74d45445f",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "tenant",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion/tenants/tenant/3d5819f1542e4ef9a4ccb0bcb278ca10",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "k8scloudowner"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "k8sregion"
+ }, {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "3d5819f1542e4ef9a4ccb0bcb278ca10"
+ }],
+ "related-to-property": [{
+ "property-key": "tenant.tenant-name",
+ "property-value": "onap-tm5g-dev"
+ }]
+ }, {
+ "related-to": "cloud-region",
+ "relationship-label": "org.onap.relationships.inventory.LocatedIn",
+ "related-link": "/aai/v19/cloud-infrastructure/cloud-regions/cloud-region/k8scloudowner/k8sregion",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "k8scloudowner"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "k8sregion"
+ }],
+ "related-to-property": [{
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": "OwnerType"
+ }]
+ }, {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v19/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vfw-k8s/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vfw-k8s"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379"
+ }],
+ "related-to-property": [{
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "vfw-0201"
+ }]
+ }, {
+ "related-to": "platform",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v19/business/platforms/platform/test",
+ "relationship-data": [{
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "test"
+ }]
+ }, {
+ "related-to": "line-of-business",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v19/business/lines-of-business/line-of-business/LOB-Demonstration",
+ "relationship-data": [{
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "LOB-Demonstration"
+ }]
+ }]
+ }
+}
+ """
+ }
+
+ String mockQuerySliceServiceReturn(){
+ String expect =
+ """{
+ "service-instance-id": "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX",
+ "service-instance-name": "nssi_DemoEmbb",
+ "service-role": "nssi",
+ "environment-context": "cn",
+ "model-invariant-id": "da575e8e-0863-4172-88b3-b3a9ead67895",
+ "model-version-id": "e398c92f-27da-44b9-a717-1dbfc1bdd82e",
+ "service-instance-location-id": "39-00",
+ "resource-version": "1593525640482",
+ "orchestration-status": "activated",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/206535e7-77c9-4036-9387-3f1cf57b4379",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "206535e7-77c9-4036-9387-3f1cf57b4379"
+ }],
+ "related-to-property": [{
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "nsi_DemoEmbb"
+ }]
+ },
+ {
+ "related-to": "allotted-resource",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0d3d3cce-46a8-486d-816a-954e71697c4e/allotted-resources/allotted-resource/d63c241a-4c0b-4294-b4c3-5a57421a1769",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "0d3d3cce-46a8-486d-816a-954e71697c4e"
+ }, {
+ "relationship-key": "allotted-resource.id",
+ "relationship-value": "d63c241a-4c0b-4294-b4c3-5a57421a1769"
+ }],
+ "related-to-property": [{
+ "property-key": "allotted-resource.description"
+ }, {
+ "property-key": "allotted-resource.allotted-resource-name",
+ "property-value": "Allotted_DemoEmbb_shared"
+ }]
+ }, {
+ "related-to": "allotted-resource",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/1c7046f2-a5a3-4d7f-9da8-388ee641a795/allotted-resources/allotted-resource/362e46c2-cd84-45e4-a6c1-77f4ef88328d",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "1c7046f2-a5a3-4d7f-9da8-388ee641a795"
+ }, {
+ "relationship-key": "allotted-resource.id",
+ "relationship-value": "362e46c2-cd84-45e4-a6c1-77f4ef88328d"
+ }],
+ "related-to-property": [{
+ "property-key": "allotted-resource.description"
+ }, {
+ "property-key": "allotted-resource.allotted-resource-name",
+ "property-value": "Allotted_DemoEmbb"
+ }]
+ }
+ ]
+ }
+}
+ """
+ return expect
+ }
+
+ String mockServiceProfile1() {
+ return """{
+ "service-instance-id": "0d3d3cce-46a8-486d-816a-954e71697c4e",
+ "service-instance-name": "DemoEmbb2",
+ "service-role": "e2esliceprofile-service",
+ "environment-context": "01-5C83F071",
+ "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d11e",
+ "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0292",
+ "service-instance-location-id": "39-00",
+ "resource-version": "1593511782269",
+ "orchestration-status": "activated",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520"
+ }],
+ "related-to-property": [{
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "DemoEmbb"
+ }]
+ }]
+ },
+ "allotted-resources": {
+ "allotted-resource": [{
+ "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d",
+ "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc",
+ "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461",
+ "resource-version": "1593511173712",
+ "type": "Allotted Resource",
+ "allotted-resource-name": "Allotted_DemoEmbb",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c"
+ }],
+ "related-to-property": [{
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "nsi_DemoEmbb"
+ }]
+ }]
+ }
+ }]
+ },
+ "slice-profiles": {
+ "slice-profile": [{
+ "profile-id": "31a83df8-5bd0-4df7-a50f-7900476b81a2",
+ "latency": 3,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 500,
+ "exp-data-rate-DL": 2000,
+ "activity-factor": 0,
+ "e2e-latency": 0,
+ "jitter": 0,
+ "survival-time": 0,
+ "exp-data-rate": 0,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 0,
+ "s-nssai": "01-5C83F071",
+ "resource-version": "1593525640617"
+ }]
+ }
+}"""
+ }
+
+ String mockServiceProfile2() {
+ return """{
+ "service-instance-id": "1c7046f2-a5a3-4d7f-9da8-388ee641a795",
+ "service-instance-name": "DemoEmbb",
+ "service-role": "e2esliceprofile-service",
+ "environment-context": "01-5B179BD4",
+ "model-invariant-id": "040b1b40-3120-446b-b8e3-4f21d153d12e",
+ "model-version-id": "8b7dabb3-3f27-4555-a9fe-803e862b0282",
+ "service-instance-location-id": "39-00",
+ "resource-version": "1593511782169",
+ "orchestration-status": "activated",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4b2bdbc0-cf7e-4c50-882a-f660e3ab8520",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "4b2bdbc0-cf7e-4c50-882a-f660e3ab8520"
+ }],
+ "related-to-property": [{
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "DemoEmbb"
+ }]
+ }]
+ },
+ "allotted-resources": {
+ "allotted-resource": [{
+ "id": "362e46c2-cd84-45e4-a6c1-77f4ef88328d",
+ "model-invariant-id": "e5941a50-ddb4-4f74-be03-25449ae02ddc",
+ "model-version-id": "ab171d60-c2cc-4903-ac1d-c451b647e461",
+ "resource-version": "1593511173712",
+ "type": "Allotted Resource",
+ "allotted-resource-name": "Allotted_DemoEmbb",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v19/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ea107578-9854-4718-8145-7c7febf0de6c",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "ea107578-9854-4718-8145-7c7febf0de6c"
+ }],
+ "related-to-property": [{
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "nsi_DemoEmbb"
+ }]
+ }]
+ }
+ }]
+ },
+ "slice-profiles": {
+ "slice-profile": [{
+ "profile-id": "b86df550-9d70-452b-a5a9-eb8823417255",
+ "latency": 6,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "Beijing;Beijing;HaidianDistrict;WanshouluStreet",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 500,
+ "exp-data-rate-DL": 1000,
+ "activity-factor": 0,
+ "e2e-latency": 0,
+ "jitter": 0,
+ "survival-time": 0,
+ "exp-data-rate": 0,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 0,
+ "s-nssai": "01-5B179BD4",
+ "resource-version": "1593511356725"
+ }]
+ }
+}"""
+ }
+} \ No newline at end of file