5G core nssmf - Allocate api 84/116284/3
authoraleemraja <ar00500721@techmahindra.com>
Fri, 18 Dec 2020 12:29:03 +0000 (17:59 +0530)
committerAleem Raja <ar00500721@techmahindra.com>
Fri, 18 Dec 2020 13:57:37 +0000 (13:57 +0000)
Code changes to fix issues observed during testing for share/non-shared
nssmf Allocate api

Issue-ID: SO-3418
Signed-off-by: aleemraja <ar00500721@techmahindra.com>
Change-Id: I37ce7d21eaba8ea51a91a7034502323b2cf3a615

bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy
bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy
bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreNSSI.bpmn
bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateCoreSharedSlice.bpmn

index 64c36e7..ec97972 100644 (file)
@@ -68,10 +68,7 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor {
         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")
@@ -79,8 +76,8 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor {
             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") ?: ""
-
+            List serviceProxyList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(json, "serviceResources.serviceProxy"))
+            String networkServiceModelInfo = serviceProxyList.get(0)
             execution.setVariable("networkServiceModelInfo", networkServiceModelInfo)
             logger.debug("***** nsstName is: "+ nsstName)
             execution.setVariable("nsstName",nsstName)
@@ -93,6 +90,7 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor {
         }
         logger.debug(Prefix+" **** Exit DoAllocateCoreNSSI ::: getNSSTName ****")
     }
+
     void prepareOOFRequest(DelegateExecution execution){
         logger.debug(Prefix+" **** Enter DoAllocateCoreNSSI ::: prepareOOFRequest ****")
         //API Path
@@ -105,8 +103,6 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor {
         //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)
@@ -128,6 +124,10 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor {
         String solutions =""
         if(requestStatus.equals("completed")) {
             solutions = jsonUtil.getJsonValue(OOFResponse, "solutions")
+            List solutionsList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(OOFResponse, "solutions"))
+            if(solutionsList!=null && !solutionsList.isEmpty() ) {
+                solutions = solutionsList.get(0)
+            }
         } else {
             String statusMessage = jsonUtil.getJsonValue(OOFResponse, "statusMessage")
             logger.error("received failed status from oof "+ statusMessage)
@@ -139,16 +139,20 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor {
 
     void prepareFailedOperationStatusUpdate(DelegateExecution execution){
         logger.debug(Prefix + " **** Enter DoAllocateCoreNSSI ::: prepareFailedOperationStatusUpdate ****")
-        String serviceId = execution.getVariable("nssiId")
+        String serviceId = execution.getVariable("nsiId")
         String jobId = execution.getVariable("jobId")
         String nsiId = execution.getVariable("nsiId")
-        String operationType = execution.getVariable("operationType")
+        String nssiId = execution.getVariable("nssiId")
+        String operationType = "ALLOCATE"
+        logger.debug("serviceId: "+serviceId+" jobId: "+jobId+" nsiId: "+nsiId+" operationType: "+operationType)
+        String modelUuid= execution.getVariable("modelUuid")
         ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
         resourceOperationStatus.setServiceId(serviceId)
+        resourceOperationStatus.setJobId(jobId)
         resourceOperationStatus.setOperationId(jobId)
-        resourceOperationStatus.setResourceTemplateUUID(nsiId)
+        resourceOperationStatus.setResourceTemplateUUID(modelUuid)
         resourceOperationStatus.setOperType(operationType)
-        resourceOperationStatus.setProgress(0)
+        resourceOperationStatus.setProgress("0")
         resourceOperationStatus.setStatus("failed")
         resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed")
         requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
index c5a928a..1ca0605 100644 (file)
@@ -64,6 +64,8 @@ import org.onap.so.bpmn.core.json.JsonUtils
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 import org.springframework.http.HttpEntity
+import org.onap.aai.domain.yang.NetworkPolicy
+import org.onap.aaiclient.client.aai.AAINamespaceConstants
 
 import javax.ws.rs.NotFoundException
 
@@ -79,24 +81,26 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
     public void preProcessRequest(DelegateExecution execution) {
         logger.debug(Prefix+ "**** Enter DoAllocateCoreNonSharedSlice:::  preProcessRequest ****")
         String nssiServiceInstanceId= execution.getVariable("serviceInstanceId")
+        logger.debug("nssiServiceInstanceId:  "+nssiServiceInstanceId)
         execution.setVariable("nssiServiceInstanceId", nssiServiceInstanceId)
         //Set orchestration-status as created
         execution.setVariable("orchestrationStatus", "created")
         //networkServiceName
-        String networkServiceName = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelName") ?: ""
+        String networkServiceName = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelInfo.modelName") ?: ""
         execution.setVariable("networkServiceName", networkServiceName.replaceAll(" Service Proxy", ""))
         //networkServiceModelUuid
-        String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelUuid") ?: ""
+        logger.debug("networkServiceName:  "+networkServiceName)
+        String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "sourceModelUuid") ?: ""
         execution.setVariable("networkServiceModelUuid", networkServiceModelUuid)
-               String sliceParams = execution.getVariable("sliceParams")
-               logger.debug("sliceParams "+sliceParams)
-               List<String> bhEndPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints"))
-               if(bhEndPoints.empty) {
-                       logger.debug("End point info is empty")
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 500, "End point info is empty")
-               }else {
-                       execution.setVariable("bh_endpoint", bhEndPoints.get(0))
-               }
+        String sliceParams = execution.getVariable("sliceParams")
+        logger.debug("sliceParams "+sliceParams)
+        List<String> bhEndPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints"))
+        if(bhEndPoints.empty) {
+            logger.debug("End point info is empty")
+            exceptionUtil.buildAndThrowWorkflowException(execution, 500, "End point info is empty")
+        }else {
+            execution.setVariable("bh_endpoint", bhEndPoints.get(0))
+        }
         logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice:::  preProcessRequest ****")
     }
 
@@ -139,10 +143,8 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
             si.setWorkloadContext(workloadContext)
             logger.debug("AAI service Instance Request Payload : "+si.toString())
             AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(serviceType).serviceInstance(serviceInstanceId))
-            Response response = getAAIClient().create(uri, si)
-            if(response.getStatus()!=200) {
-                exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI instance creation failed")
-            }
+            getAAIClient().create(uri, si)
+
             execution.setVariable("nssiServiceInstance", si)
         } catch (BpmnError e) {
             throw e;
@@ -151,12 +153,14 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
             logger.debug(msg)
             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
         }
+        getVnfInstanceName(execution)
         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'
+        //extAPI path hardcoded for testing purposes, will be updated in next patch
+        String extAPIPath = "https://nbi.onap:8443/nbi/api/v4" + "/serviceOrder"
         execution.setVariable("ExternalAPIURL", extAPIPath)
         ObjectMapper objectMapper = new ObjectMapper();
         Map<String, Object> serviceOrder = new LinkedHashMap()
@@ -186,10 +190,10 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
         // service Details
         Map<String, Object> service = new LinkedHashMap()
         //ServiceName
-        String serviceName= "nsi_"+execution.getVariable("networkServiceName")
+        String serviceName= "ns_"+execution.getVariable("networkServiceName")+"_"+execution.getVariable("serviceInstanceId")
         service.put("name",  serviceName)
         // Service Type
-        service.put("serviceType", execution.getVariable("serviceType"))
+        service.put("serviceType", execution.getVariable("subscriptionServiceType"))
         //Service State
         service.put("serviceState", "active")
         Map<String, String> serviceSpecification = new LinkedHashMap()
@@ -198,7 +202,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
         //serviceCharacteristic List
         List serviceCharacteristicList = new ArrayList()
         Map<String, Object> serviceCharacteristic = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class);
-        List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic)
+        List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(execution, serviceCharacteristic)
         logger.debug("serviceCharacteristicListMap  "+serviceCharacteristicListMap)
         serviceCharacteristicList.add(serviceCharacteristic)
         //service.put("serviceCharacteristic", serviceCharacteristicList)
@@ -213,10 +217,23 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
         logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest****")
     }
 
-    private List retrieveServiceCharacteristicsAsKeyValue(Map serviceCharacteristics) {
+    private void getVnfInstanceName(DelegateExecution execution) {
+        //Get NetworkService modelInvariantUuid
+        String  networkServiceModelUuid = execution.getVariable("networkServiceModelUuid")
+        String json = catalogDbUtils.getServiceResourcesByServiceModelUuid(execution, networkServiceModelUuid, "v2")
+        logger.debug("json returned: "+json)
+        logger.debug(("Service Vnfs JSON: "+jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs")))
+        List serviceVnfs = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs"))
+        String networkServiceVnfJson = serviceVnfs.get(0)
+        String vnfInstanceName = (jsonUtil.getJsonValue(networkServiceVnfJson, "modelInfo.modelInstanceName")).trim() ?: ""
+        execution.setVariable("vnfInstanceName", vnfInstanceName)
+    }
+
+    private List retrieveServiceCharacteristicsAsKeyValue(DelegateExecution execution, Map serviceCharacteristics) {
         logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****")
         List serviceCharacteristicsList = new ArrayList()
         ObjectMapper mapperObj = new ObjectMapper();
+        String vnfInstanceName = execution.getVariable("vnfInstanceName")
         Map<String, Object> serviceCharacteristicsObject = new LinkedHashMap()
         for (Map.Entry<String, Integer> entry : serviceCharacteristics.entrySet()) {
             Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>()
@@ -224,7 +241,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
             //For G Release we are sending single value from  snssaiList
             if(entry.getKey().equals("snssaiList")) {
                 List sNssaiValue = entry.getValue()
-                serviceCharacteristicsObject.put("name", "snssai")
+                serviceCharacteristicsObject.put("name", vnfInstanceName+"_snssai")
                 ServiceCharacteristicValueObject.put("serviceCharacteristicValue", sNssaiValue.get(0))
                 serviceCharacteristicsObject.put("value", ServiceCharacteristicValueObject)
             }
@@ -303,18 +320,12 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
                 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)) {
+                if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState) || "INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
                     execution.setVariable("status", "processing")
                 }
                 else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
@@ -328,6 +339,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
                     msg = "ServiceOrder failed"
                     exceptionUtil.buildAndThrowWorkflowException(execution, 7000,  msg)
                 }
+                logger.debug("NBI serviceOrder state: "+serviceOrderState)
             }
             else{
                 msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode
@@ -340,9 +352,6 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
         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")
@@ -353,47 +362,42 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
         }
     }
 
-
     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")
+        String serviceType = execution.getVariable("subscriptionServiceType")
+        logger.debug("networkServiceInstanceId:  "+networkServiceInstanceId +" nssiId:  "+nssiId  +" globalCustId:  "+globalCustId+  " serviceType:  "+serviceType)
         try{
             //Update NSSI orchestration status nssiServiceInstance
             ServiceInstance si = execution.getVariable("nssiServiceInstance")
+            logger.debug("nssiServiceInstance "+si)
             si.setOrchestrationStatus("activated")
+            AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(nssiId))
+            logger.debug("uri to call:  "+uri)
 
-            AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(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()
+                String msg = "Update OrchestrationStatus in AAI failed, " + e
                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
             }
-
             //URI for NSSI
             AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId));
-
+            logger.debug("nssiUri to update RelationShip :  "+nssiUri)
             //URI for Network Service Instance
             AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstanceId))
-
+            logger.debug("networkServiceInstanceUri to update RelationShip :  "+networkServiceInstanceUri)
             // 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 {
-                               //end point update
-                               createEndPointsInAai(execution)
-                execution.setVariable("progress", 100)
-                execution.setVariable("status", "finished")
-                execution.setVariable("statusDescription", "DoAllocateCoreNonSharedNSSI success")
-                setResourceOperationStatus(execution)
-            }
+            getAAIClient().connect(nssiUri, networkServiceInstanceUri, AAIEdgeLabel.COMPOSED_OF);
+            //end point update
+            createEndPointsInAai(execution)
+            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)
@@ -402,78 +406,81 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
         logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: updateRelationship ****")
     }
 
-       private void createEndPointsInAai(DelegateExecution execution) {
-               String type = "endpoint"
-               String function = "core_EP"
-               int prefixLength = 24
-               String addressFamily = "ipv4"
-               //BH RAN end point update
-               String bh_endpoint = execution.getVariable("bhEndPoints")
-               String bh_routeId = UUID.randomUUID().toString()
-               execution.setVariable("coreEp_ID_bh", bh_routeId)
-               String role = "CN"
-               String cnIpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
-               String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
-               String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
-               NetworkRoute bh_ep = new NetworkRoute()
-               bh_ep.setRouteId(bh_routeId)
-               bh_ep.setFunction(function)
-               bh_ep.setRole(role)
-               bh_ep.setType(type)
-               bh_ep.setIpAddress(cnIpAddress)
-               bh_ep.setLogicalInterfaceId(LogicalLinkId)
-               bh_ep.setNextHop(nextHopInfo)
-               bh_ep.setPrefixLength(prefixLength)
-               bh_ep.setAddressFamily(addressFamily)
-               try {
-                       AAIResourcesClient client = new AAIResourcesClient()
-                       logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
-                       AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
-                       client.create(networkRouteUri, bh_ep)
-                       //relationship b/w bh_ep and Core NSSI
-                       def coreNssi = execution.getVariable("NSSIserviceInstanceId")
-                       Relationship relationship = new Relationship()
-                       String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
-                       relationship.setRelatedLink(relatedLink)
-                       relationship.setRelatedTo("network-route")
-                       relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
-                       try {
-                               AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
-                                               execution.getVariable("globalSubscriberId"),
-                                               execution.getVariable("subscriptionServiceType"),
-                                               coreNssi).relationshipAPI()
-                               client.create(uri, relationship)
-                       } catch (BpmnError e) {
-                               throw e
-                       } catch (Exception ex) {
-                               String msg = "Exception in CreateCommunicationService.createRelationShipInAAI. " + ex.getMessage()
-                               logger.info(msg)
-                               exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
-                       }
-               } catch (BpmnError e) {
-                       throw e
-               } catch (Exception ex) {
-                       String msg = "Exception in createEndPointsInAai " + ex.getMessage()
-                       logger.info(msg)
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
-               }
-       }
-
     /**
-     * prepare ResourceOperation status
+     * creates EndPoints in AAI
      * @param execution
-     * @param operationType
      */
+    private void createEndPointsInAai(DelegateExecution execution) {
+        String type = "endpoint"
+        String function = "core_EP"
+        int prefixLength = 24
+        String addressFamily = "ipv4"
+        //BH end point update
+        String bh_endpoint = execution.getVariable("bh_endpoint")
+        String bh_routeId = UUID.randomUUID().toString()
+        execution.setVariable("coreEp_ID_bh", bh_routeId)
+        String role = "CN"
+        String cnIpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
+        String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
+        String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
+        NetworkRoute bh_ep = new NetworkRoute()
+        logger.debug("bh_endpoint: "+bh_endpoint  +"  "+ "bh_routeId: "+bh_routeId  +"  "+ "cnIpAddress: "+cnIpAddress  +"   "+ "role: "+role  +"  "+  "cnIpAddress: "+cnIpAddress +"  "+ "LogicalLinkId: "+LogicalLinkId  +"  "+  "nextHopInfo: "+nextHopInfo  +"  "+  "bh_ep: "+bh_ep)
+        bh_ep.setRouteId(bh_routeId)
+        bh_ep.setFunction(function)
+        bh_ep.setRole(role)
+        bh_ep.setType(type)
+        bh_ep.setIpAddress(cnIpAddress)
+        bh_ep.setLogicalInterfaceId(LogicalLinkId)
+        bh_ep.setNextHop(nextHopInfo)
+        bh_ep.setPrefixLength(prefixLength)
+        bh_ep.setAddressFamily(addressFamily)
+        try {
+            AAIResourcesClient client = new AAIResourcesClient()
+            logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
+            AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
+            client.create(networkRouteUri, bh_ep)
+            //relationship b/w bh_ep and Core NSSI
+            def coreNssi = execution.getVariable("nssiServiceInstanceId")
+            Relationship relationship = new Relationship()
+            String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
+            relationship.setRelatedLink(relatedLink)
+            relationship.setRelatedTo("network-route")
+            relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
+            logger.debug("networkRouteUri: "+networkRouteUri+"relationship: "+relationship)
+            try {
+                AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+                        execution.getVariable("globalSubscriberId"),
+                        execution.getVariable("subscriptionServiceType"),
+                        coreNssi).relationshipAPI()
+                logger.debug("uri: "+uri)
+                client.create(uri, relationship)
+            } catch (BpmnError e) {
+                throw e
+            } catch (Exception ex) {
+                String msg = "Exception in createRelationShipInAAI. " + ex.getMessage()
+                logger.debug(msg+": "+ex)
+                exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+            }
+        } catch (BpmnError e) {
+            throw e
+        } catch (Exception ex) {
+            String msg = "Exception in createEndPointsInAai " + ex.getMessage()
+            logger.info(msg)
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+        }
+    }
+
     private void setResourceOperationStatus(DelegateExecution execution) {
         logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****")
-        String serviceId = execution.getVariable("nssiId")
+        String serviceId = execution.getVariable("nsiId")
         String jobId = execution.getVariable("jobId")
         String nsiId = execution.getVariable("nsiId")
-        String operationType = execution.getVariable("operationType")
+        String operationType = "ALLOCATE"
         ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
         resourceOperationStatus.setServiceId(serviceId)
         resourceOperationStatus.setOperationId(jobId)
         resourceOperationStatus.setResourceTemplateUUID(nsiId)
+        resourceOperationStatus.setResourceInstanceID(nssiId)
         resourceOperationStatus.setOperType(operationType)
         resourceOperationStatus.setStatus(execution.getVariable("status"))
         resourceOperationStatus.setProgress(execution.getVariable("progress"))
@@ -484,17 +491,21 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
 
     void prepareFailedOperationStatusUpdate(DelegateExecution execution){
         logger.debug(Prefix + " **** Enter DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****")
-        String serviceId = execution.getVariable("nssiId")
+        String serviceId = execution.getVariable("nsiId")
         String jobId = execution.getVariable("jobId")
         String nsiId = execution.getVariable("nsiId")
-        String operationType = execution.getVariable("operationType")
-
+        String nssiId = execution.getVariable("nssiId")
+        String operationType = "ALLOCATE"
+        //modelUuid
+        String modelUuid= execution.getVariable("modelUuid")
+        logger.debug("serviceId: "+serviceId +"  "+ "jobId: "+jobId   +"  "+  "nsiId: "+nsiId +"   "+  "operationType: "+operationType)
         ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
         resourceOperationStatus.setServiceId(serviceId)
+        resourceOperationStatus.setJobId(jobId)
         resourceOperationStatus.setOperationId(jobId)
-        resourceOperationStatus.setResourceTemplateUUID(nsiId)
+        resourceOperationStatus.setResourceTemplateUUID(modelUuid)
         resourceOperationStatus.setOperType(operationType)
-        resourceOperationStatus.setProgress(0)
+        resourceOperationStatus.setProgress("0")
         resourceOperationStatus.setStatus("failed")
         resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed")
         requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
index 5ecfc9a..b3c99c6 100644 (file)
@@ -115,7 +115,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
         logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getNetworkInstanceAssociatedWithNssiId ****")
 
         //NSSI Id as service Instance Id to get from Request
-        String serviceInstanceId = execution.getVariable("serviceInstanceID")
+        String serviceInstanceId = execution.getVariable("nssiId")
 
         String errorMsg = "query Network Service Instance from AAI failed"
         AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg)
@@ -304,14 +304,6 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
         logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: getVnfRelationships ****")
     }
 
-
-    /**
-     * query AAI
-     * @param execution
-     * @param aaiObjectName
-     * @param instanceId
-     * @return AAIResultWrapper
-     */
     private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectName aaiObjectName, String instanceId, String errorMsg) {
         logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: queryAAI ****")
         String globalSubscriberId = execution.getVariable("globalSubscriberId")
@@ -368,6 +360,8 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
 
         Map vnfMap = vnfList.get(0)
         ModelInfo vnfModelInfo = vnfMap.get("modelInfo")
+        vnfModelInfo.setModelCustomizationId(vnfModelInfo.getModelCustomizationUuid())
+        vnfModelInfo.setModelVersionId(vnfModelInfo.getModelId())
         logger.debug("vnfModelInfo "+vnfModelInfo)
 
         //List of VFModules
@@ -380,6 +374,8 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
         //Traverse VFModules List and add in vfModelInfoList
         for (vfModule in vfModuleList) {
             ModelInfo vfModelInfo = vfModule.get("modelInfo")
+            vfModelInfo.setModelCustomizationId(vfModelInfo.getModelCustomizationUuid())
+            vfModelInfo.setModelVersionId(vfModelInfo.getModelId())
             logger.debug("vfModelInfo "+vfModelInfo)
             vfModelInfoList.add(vfModelInfo)
         }
@@ -410,25 +406,31 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
             //Individual VFModule List
             Map<String, Object> vfModuleValues = new LinkedHashMap<>()
             vfModuleValues.put("modelInfo", vfModuleModelInfo)
-            vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName())
+            vfModuleValues.put("instanceName", vfModuleModelInfo.getModelName())
 
             //VFModule InstanceParams should be empty or this field should not be there?
             List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>()
             vfModuleValues.put("instanceParams", vfModuleInstanceParams)
+            vfModules.add(vfModuleValues)
         }
 
         //Vnf intsanceParams
         Map<String, Object> sliceProfile = mapper.readValue(execution.getVariable("sliceProfile"), Map.class);
 
-        List vnfInstanceParamsList = new ArrayList<>()
+        List<Map<String, Object>> vnfInstanceParamsList = new ArrayList<>()
         String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution)
-        vnfInstanceParamsList.add(supportedsNssaiJson)
+
+        Map<String, Object> supportedNssai= new LinkedHashMap<>()
+        supportedNssai.put("supportedsNssai", supportedsNssaiJson)
+        vnfInstanceParamsList.add(supportedNssai)
 
         Platform platform = new Platform()
-        platform.setPlatformName(execution.getVariable("platform"))
+               String platformName = execution.getVariable("platformName")
+        platform.setPlatformName(platformName)
 
         LineOfBusiness lineOfbusiness = new LineOfBusiness()
-        lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness"))
+        String lineOfBusinessName = execution.getVariable("lineOfBusinessName")
+        lineOfbusiness.setLineOfBusinessName(lineOfBusinessName)
 
         //Vnf Values
         Map<String, Object> vnfValues = new LinkedHashMap<>()
@@ -438,7 +440,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
         vnfValues.put("cloudConfiguration", cloudConfiguration)
         vnfValues.put("vfModules", vfModules)
         vnfValues.put("modelInfo", vnfModelInfo)
-        vnfValues.put("instanceName", execution.getVariable("vnfInstanceName"))
+        vnfValues.put("instanceName", vnfModelInfo.getModelInstanceName())
         vnfValues.put("instanceParams",vnfInstanceParamsList)
 
         vnfModelInfoList.add(vnfValues)
@@ -496,10 +498,8 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
         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 ****")
     }
 
@@ -508,14 +508,11 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
         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("****  supportedsNssaiJson**** "+supportedsNssaiJson)
         logger.debug(Prefix+" **** Exit DoAllocateCoreSharedSlice ::: prepareVnfInstanceParamsJson ****")
-        return supportedNssai
+        return supportedsNssaiJson
     }
 
     public void sendPutRequestToSOMacro(DelegateExecution execution) {
@@ -523,14 +520,9 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
         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)
-
+            String encodeString = "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="
+            logger.debug("msoEndpoint: "+msoEndpoint +"  "+ "url: "+url  +" requestBody: "+requestBody +"  "+ "encodeString: "+encodeString)
             HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
             httpClient.addAdditionalHeader("Authorization", encodeString)
             httpClient.addAdditionalHeader("Accept", "application/json")
@@ -546,84 +538,93 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
         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")
+            logger.debug("soResponse: "+soResponse)
+            logger.debug("soResponse JsonUtil: "+jsonUtil.getJsonValue(soResponse, "requestReferences.requestId"))
+            def macroOperationId = jsonUtil.getJsonValue(soResponse, "requestReferences.requestId")
+            def requestSelfLink = jsonUtil.getJsonValue(soResponse, "requestReferences.requestSelfLink")
             execution.setVariable("macroOperationId", macroOperationId)
+            execution.setVariable("requestSelfLink", requestSelfLink)
             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 ****")
+    public void getSOPUTProgress(DelegateExecution execution) {
+        logger.debug(Prefix+ " **** Enter DoAllocateCoreSharedSlice ::: getSOPUTProgress ****")
+        String url= execution.getVariable("requestSelfLink")
+        logger.debug("url  "+url)
+        HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
+               //Hardcoding for now, will be updated in next patch
+        httpClient.addAdditionalHeader("Authorization", "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==")
+        httpClient.addAdditionalHeader("Accept", "application/json")
+        Response httpResponse = httpClient.get()
+        logger.debug("httpResponse "+httpResponse)
+        int soResponseCode = httpResponse.getStatus()
+        logger.debug("soResponseCode : "+soResponseCode)
+        if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) {
+            String soResponse = httpResponse.readEntity(String.class)
+            logger.debug("soResponse: "+soResponse)
+            String requestState= jsonUtil.getJsonValue(soResponse, "request.requestStatus.requestState")
+            logger.debug("requestState: "+requestState)
+            execution.setVariable("requestState", requestState)
+        } else {
+            execution.setVariable("isSOResponseSucceed","no")
+            prepareFailedOperationStatusUpdate(execution)
+        }
+        logger.debug(Prefix+ " **** Exit DoAllocateCoreSharedSlice ::: getSOPUTProgress ****")
+    }
+
+    public void timeDelay(DelegateExecution execution) {
+        try {
+            logger.debug(Prefix+ " **** DoAllocateCoreSharedSlice ::: timeDelay going to sleep for 5 sec")
+            Thread.sleep(5000)
+            logger.debug("**** DoAllocateCoreNonSharedSlice ::: timeDelay wakeup after 5 sec")
+        } catch(InterruptedException e) {
+            logger.error(Prefix+ " **** DoAllocateCoreSharedSlice ::: timeDelay exception" + e)
+        }
     }
 
     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 {
+        if("COMPLETED".equals(execution.getVariable("requestState"))) {
             execution.setVariable("progress", "100")
             execution.setVariable("status", "finished")
             execution.setVariable("operationContent", "AllocteCoreNSSI successful.")
-            logger.debug("prepareFailureStatus,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}")
+            logger.debug("Success ,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}")
+        } else {
+            logger.debug("SO PUT Failure")
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure")
         }
         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")
+               logger.debug("serviceId: "+serviceId +"  "+ " jobId: "+jobId +"  "+ " nsiId: "+nsiId+" nssiId: "+nssiId+" operationType: "+operationType)
         ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
         resourceOperationStatus.setServiceId(serviceId)
         resourceOperationStatus.setOperationId(jobId)
         resourceOperationStatus.setResourceTemplateUUID(nsiId)
+               resourceOperationStatus.setResourceInstanceID(nssiId)
         resourceOperationStatus.setOperType(operationType)
         resourceOperationStatus.setStatus("finished")
         resourceOperationStatus.setProgress("100")
@@ -634,17 +635,19 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor {
 
     void prepareFailedOperationStatusUpdate(DelegateExecution execution){
         logger.debug(Prefix + " **** Enter DoAllocateCoreSharedSlice ::: prepareFailedOperationStatusUpdate ****")
-        String serviceId = execution.getVariable("nssiId")
+        String serviceId = execution.getVariable("nsiId")
         String jobId = execution.getVariable("jobId")
         String nsiId = execution.getVariable("nsiId")
-        String operationType = execution.getVariable("operationType")
-
+        String operationType = "ALLOCATE"
+        logger.debug("serviceId: "+serviceId +"  "+ " jobId: "+jobId +"  "+ " nsiId: "+nsiId+" operationType: "+operationType)
+        String modelUuid= execution.getVariable("modelUuid")
         ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
         resourceOperationStatus.setServiceId(serviceId)
+        resourceOperationStatus.setJobId(jobId)
         resourceOperationStatus.setOperationId(jobId)
-        resourceOperationStatus.setResourceTemplateUUID(nsiId)
+        resourceOperationStatus.setResourceTemplateUUID(modelUuid)
         resourceOperationStatus.setOperType(operationType)
-        resourceOperationStatus.setProgress(0)
+        resourceOperationStatus.setProgress("0")
         resourceOperationStatus.setStatus("failed")
         resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed")
         requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
index 6b15407..fa1cef2 100644 (file)
@@ -20,7 +20,8 @@
 
 package org.onap.so.bpmn.infrastructure.scripts
 
-import static org.junit.Assert.*
+import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertEquals
 
 import org.junit.Before
 import org.junit.Test
@@ -49,14 +50,19 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest {
     @Test
     public void testPreProcessRequest() {
 
-        String networkServiceModelInfo=""" {
-                                "modelName"              : "5GC-eMBB Service Proxy",
-                                "modelUuid"              : "b666119e-4400-47c6-a0c1-bbe050a33b47",
-                                "modelInvariantUuid"     : "a26327e1-4a9b-4883-b7a5-5f37dcb7405a",
+        String networkServiceModelInfo="""{
+                        "modelInfo"                : {
+                                "modelName"              : "vfw_cnf_service_2310 Service Proxy",
+                                "modelUuid"              : "35386eb0-b673-48c5-9757-45ecfc506bf8",
+                                "modelInvariantUuid"     : "b048d7bc-8bfd-4950-aea5-22b1aaf5d76b",
                                 "modelVersion"           : "1.0",
-                                "modelCustomizationUuid" : "cbc12c2a-67e6-4336-9236-eaf51eacdc75",
-                                "modelInstanceName"      : "5gcembb_proxy 0"
-        }"""
+                                "modelCustomizationUuid" : "82f4db76-e7ad-47eb-b5e3-661683f14de6",
+                                "modelInstanceName"      : "vfw_cnf_service_2310_proxy 0"
+                },
+                        "toscaNodeType"            : "org.openecomp.nodes.vfw_cnf_service_2310_proxy",
+                        "description"            : "A Proxy for Service vfw_cnf_service_2310",
+                        "sourceModelUuid"            : "f3666c56-744e-4055-9f4a-0726460898e0"
+                }"""
 
                String sliceParams= """{\r\n\t\"sliceProfile\": {\r\n\t\t\"snssaiList\": [\r\n\t\t\t\"001-100001\"\r\n\t\t],\r\n\t\t\"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n\t\t\"plmnIdList\": [\r\n\t\t\t\"460-00\",\r\n\t\t\t\"460-01\"\r\n\t\t],\r\n\t\t\"perfReq\": {\r\n\t\t\t\"perfReqEmbbList \": [{\r\n\t\t\t\t\"activityFactor\": 50\r\n\t\t\t}]\r\n\t\t},\r\n\t\t\"maxNumberofUEs\": 200,\r\n\t\t\"coverageAreaTAList\": [\r\n\t\t\t\"1\",\r\n\t\t\t\"2\",\r\n\t\t\t\"3\",\r\n\t\t\t\"4\"\r\n\t\t],\r\n\t\t\"latency\": 2,\r\n\t\t\"resourceSharingLevel\": \"non-shared\"\r\n\t},\r\n\t\"endPoints\": [{\r\n\t\t\"IpAdress\": \"\",\r\n\t\t\"LogicalLinkId\": \"\",\r\n\t\t\"nextHopInfo\": \"\"\r\n\t}],\r\n\t\"nsiInfo\": {\r\n\t\t\"nsiId\": \"NSI-M-001-HDBNJ-NSMF-01-A-ZX\",\r\n\t\t\"nsiName\": \"eMBB-001\"\r\n\t},\r\n\t\"scriptName\": \"AN1\"\r\n}"""
 
@@ -70,10 +76,10 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest {
 
         Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceModelUuid"), captor.capture())
         captor.getValue()
-        assertEquals("b666119e-4400-47c6-a0c1-bbe050a33b47", captor.getValue())
+        assertEquals("f3666c56-744e-4055-9f4a-0726460898e0", captor.getValue())
 
         Mockito.verify(mockExecution, times(1)).setVariable(eq("networkServiceName"), captor.capture())
-        assertEquals("5GC-eMBB", captor.getValue())
+        assertEquals("vfw_cnf_service_2310", captor.getValue())
 
         Mockito.verify(mockExecution, times(1)).setVariable(eq("orchestrationStatus"), captor.capture())
         assertEquals("created", captor.getValue())
@@ -90,6 +96,7 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest {
         when(mockExecution.getVariable("networkServiceName")).thenReturn("5g_embb")
         when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
         when(mockExecution.getVariable("networkServiceModelUuid")).thenReturn("12345")
+        when(mockExecution.getVariable("vnfInstanceName")).thenReturn("vf00")
 
         DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice()
         allocateNssi.prepareServiceOrderRequest(mockExecution)
@@ -106,7 +113,7 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest {
         Map<String, Object> ServiceCharacteristicValue = new LinkedHashMap<>()
         Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>()
         ServiceCharacteristicValueObject.put("serviceCharacteristicValue","001-100001")
-        ServiceCharacteristicValue.put("name", "snssai")
+        ServiceCharacteristicValue.put("name", "vf00_snssai")
         ServiceCharacteristicValue.put("value", ServiceCharacteristicValueObject)
 
         List expectedList= new ArrayList()
@@ -116,8 +123,7 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest {
         Map<String, Object> serviceCharacteristic = objectMapper.readValue(sliceProfile, Map.class);
 
         DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice()
-        List characteristicList=allocateNssi.retrieveServiceCharacteristicsAsKeyValue(serviceCharacteristic)
-
+        List characteristicList=allocateNssi.retrieveServiceCharacteristicsAsKeyValue(mockExecution, serviceCharacteristic)
         assertEquals(expectedList, characteristicList)
     }
 }
\ No newline at end of file
index 0ac48ad..9068692 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.onap.so.bpmn.infrastructure.scripts
 
+import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertEquals
+
 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
 import org.junit.Before
 import org.junit.Test
@@ -32,7 +35,6 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
-import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
 
 import static org.mockito.Mockito.spy
 import static org.mockito.Mockito.times
@@ -91,7 +93,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest {
     }
 
     @Test
-    public void tesPrepareSOMacroRequestPayload() {
+    public void testPrepareSOMacroRequestPayload() {
 
         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    }"
@@ -125,7 +127,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest {
         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"}]}}"""
+        String expectedJsonAsString = """{"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}"""
         assertEquals(expectedJsonAsString, returnedJsonAsString)
     }
 
@@ -137,6 +139,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest {
 
         DoAllocateCoreSharedSlice obj = spy(DoAllocateCoreSharedSlice.class)
         when(obj.getAAIClient()).thenReturn(client)
+
         AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX"))
         when(client.exists(resourceUri1)).thenReturn(true)
         AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn())
@@ -149,15 +152,14 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest {
         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(AAIFluentTypeBuilder.network().genericVnf("eeb66c6f-36bd-47ad-8294-48f46b1aa912"))
+
+        AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(mockExecution.getVariable("vnfId")))
         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(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("0d3d3cce-46a8-486d-816a-954e71697c4e"))
         when(client.exists(resourceUri4)).thenReturn(true)
@@ -185,22 +187,19 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest {
         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")
+        snssaiMap.put("status", "activated")
         snssaiList.add(snssaiMap)
         Map<String, Object> snssaiMap1 = new LinkedHashMap<>()
         snssaiMap1.put("snssai", "01-5B179BD4")
-        snssaiMap1.put("orchestrationStatus", "activated")
+        snssaiMap1.put("status", "activated")
         snssaiList.add(snssaiMap1)
         assertEquals(snssaiList, captor.getValue())
 
@@ -237,6 +236,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest {
 
         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("nssiId")).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")
index 92407e9..45ebfb9 100644 (file)
@@ -78,6 +78,7 @@ allocateNssi.prepareOOFRequest(execution)</bpmn:script>
         <camunda:in source="servicename" target="servicename" />
         <camunda:in source="msoRequestId" target="msoRequestId" />
         <camunda:in source="sliceProfile" target="sliceProfile" />
+        <camunda:in source="jobId" target="jobId" />
       </bpmn:extensionElements>
       <bpmn:incoming>SequenceFlow_1ygklb8</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0tytimn</bpmn:outgoing>
index 0a482be..88902d1 100644 (file)
@@ -39,37 +39,15 @@ allocateNssi.prepareSOMacroRequestPayload(execution)</bpmn:script>
 def allocateNssi = new DoAllocateCoreSharedSlice()
 allocateNssi.sendPutRequestToSOMacro(execution)</bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:scriptTask id="Activity_0ge2y0l" name="Prepare Call CheckServiceProcessStatus" scriptFormat="groovy">
+    <bpmn:scriptTask id="Activity_0ge2y0l" name="Call Get SO PUT progress" scriptFormat="groovy">
       <bpmn:incoming>Flow_0x7shtq</bpmn:incoming>
+      <bpmn:incoming>Flow_163kxug</bpmn:incoming>
       <bpmn:outgoing>Flow_1c9nkx4</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def allocateNssi = new DoAllocateCoreSharedSlice()
-allocateNssi.prepareCallCheckProcessStatus(execution)</bpmn:script>
+allocateNssi.getSOPUTProgress(execution)</bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:callActivity id="Activity_19xwwnc" name="CallCheckServiceProcessStatus" calledElement="CheckServiceProcessStatus">
-      <bpmn:extensionElements>
-        <camunda:in source="networkServiceInstanceId" target="serviceInstanceId" />
-        <camunda:in source="macroOperationId" target="operationId" />
-        <camunda:in source="successConditions" target="successConditions" />
-        <camunda:in source="errorConditions" target="errorConditions" />
-        <camunda:in source="processServiceType" target="processServiceType" />
-        <camunda:in source="timeOut" target="timeOut" />
-        <camunda:out source="operationStatus" target="result" />
-        <camunda:out source="operationContent" target="reason" />
-        <camunda:out source="WorkflowException" target="WorkflowException" />
-        <camunda:out source="isTimeOut" target="isTimeOut" />
-        <camunda:in source="subOperationType" target="operationType" />
-        <camunda:in source="initProgress" target="initProgress" />
-        <camunda:in source="endProgress" target="endProgress" />
-        <camunda:in source="serviceInstanceID" target="parentServiceInstanceId" />
-        <camunda:in source="globalSubscriberId" target="globalSubscriberId" />
-        <camunda:in source="operationId" target="parentOperationId" />
-      </bpmn:extensionElements>
-      <bpmn:incoming>Flow_1c9nkx4</bpmn:incoming>
-      <bpmn:outgoing>Flow_0c94gye</bpmn:outgoing>
-    </bpmn:callActivity>
-    <bpmn:sequenceFlow id="Flow_1c9nkx4" sourceRef="Activity_0ge2y0l" targetRef="Activity_19xwwnc" />
-    <bpmn:sequenceFlow id="Flow_0c94gye" sourceRef="Activity_19xwwnc" targetRef="Activity_1t49t6c" />
+    <bpmn:sequenceFlow id="Flow_1c9nkx4" sourceRef="Activity_0ge2y0l" targetRef="Gateway_1boyqt9" />
     <bpmn:scriptTask id="Activity_0no0sxa" name="Get VNF/VFs modelInfo from CatalogDB" scriptFormat="groovy">
       <bpmn:incoming>Flow_1973d9m</bpmn:incoming>
       <bpmn:outgoing>Flow_0da7dao</bpmn:outgoing>
@@ -78,13 +56,13 @@ def allocateNssi = new DoAllocateCoreSharedSlice()
 allocateNssi.getServiceVNFAndVFsFromCatalogDB(execution)</bpmn:script>
     </bpmn:scriptTask>
     <bpmn:scriptTask id="Activity_1t49t6c" name="Prepare Update Operation Status" scriptFormat="groovy">
-      <bpmn:incoming>Flow_0c94gye</bpmn:incoming>
+      <bpmn:incoming>Flow_15lksyg</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1re5jor</bpmn:outgoing>
       <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
 def allocateNssi = new DoAllocateCoreSharedSlice()
 allocateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:serviceTask id="Activity_0t6viuq" name="Update Service Operation Status">
+    <bpmn:serviceTask id="Activity_0t6viuq" name="Update Resource Operation Status">
       <bpmn:extensionElements>
         <camunda:connector>
           <camunda:inputOutput>
@@ -95,7 +73,7 @@ allocateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script>
                 <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry>
               </camunda:map>
             </camunda:inputParameter>
-            <camunda:inputParameter name="payload">${updateOperationStatus}</camunda:inputParameter>
+            <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter>
             <camunda:inputParameter name="method">POST</camunda:inputParameter>
             <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter>
             <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter>
@@ -111,11 +89,11 @@ allocateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script>
     <bpmn:sequenceFlow id="SequenceFlow_08q2fd9" sourceRef="Activity_12jcmzc" targetRef="Gateway_0sfmiku" />
     <bpmn:sequenceFlow id="SequenceFlow_1re5jor" sourceRef="Activity_1t49t6c" targetRef="Activity_0t6viuq" />
     <bpmn:sequenceFlow id="SequenceFlow_1j1qqcs" sourceRef="Task_16983t3" targetRef="IntermediateThrowEvent_09rhn4h" />
-    <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_09rhn4h" name="Call SO macro api">
+    <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_09rhn4h" name="CallSO">
       <bpmn:incoming>SequenceFlow_1j1qqcs</bpmn:incoming>
       <bpmn:linkEventDefinition name="CallSO" />
     </bpmn:intermediateThrowEvent>
-    <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0qh9wy2" name="Call SO macro api">
+    <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0qh9wy2" name="CallSO">
       <bpmn:outgoing>SequenceFlow_013bc74</bpmn:outgoing>
       <bpmn:linkEventDefinition name="CallSO" />
     </bpmn:intermediateCatchEvent>
@@ -178,16 +156,33 @@ allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script>
       <bpmn:sequenceFlow id="Flow_0kadgoq" sourceRef="Activity_0sqggtb" targetRef="Activity_1btidug" />
       <bpmn:sequenceFlow id="Flow_128o22z" sourceRef="Activity_1btidug" targetRef="Activity_1150yu6" />
     </bpmn:subProcess>
+    <bpmn:exclusiveGateway id="Gateway_1boyqt9" default="Flow_15lksyg">
+      <bpmn:incoming>Flow_1c9nkx4</bpmn:incoming>
+      <bpmn:outgoing>Flow_15lksyg</bpmn:outgoing>
+      <bpmn:outgoing>Flow_1lzv4jo</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:sequenceFlow id="Flow_15lksyg" sourceRef="Gateway_1boyqt9" targetRef="Activity_1t49t6c" />
+    <bpmn:sequenceFlow id="Flow_1lzv4jo" name="requestState=IN_PROGRESS" sourceRef="Gateway_1boyqt9" targetRef="Activity_1qm4des">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("requestState" ) == "IN_PROGRESS")}</bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
+    <bpmn:scriptTask id="Activity_1qm4des" name="Time Delay 5s" scriptFormat="groovy">
+      <bpmn:incoming>Flow_1lzv4jo</bpmn:incoming>
+      <bpmn:outgoing>Flow_163kxug</bpmn:outgoing>
+      <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def allocateNssi = new DoAllocateCoreSharedSlice()
+allocateNssi.timeDelay(execution)</bpmn:script>
+    </bpmn:scriptTask>
+    <bpmn:sequenceFlow id="Flow_163kxug" sourceRef="Activity_1qm4des" targetRef="Activity_0ge2y0l" />
   </bpmn:process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateCoreSharedSlice">
       <bpmndi:BPMNEdge id="Flow_1nn15tq_di" bpmnElement="Flow_1nn15tq">
-        <di:waypoint x="420" y="306" />
-        <di:waypoint x="420" y="360" />
-        <di:waypoint x="967" y="360" />
-        <di:waypoint x="967" y="321" />
+        <di:waypoint x="420" y="256" />
+        <di:waypoint x="420" y="200" />
+        <di:waypoint x="967" y="200" />
+        <di:waypoint x="967" y="241" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="687" y="342" width="14" height="12" />
+          <dc:Bounds x="687" y="182" width="15" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0x7shtq_di" bpmnElement="Flow_0x7shtq">
@@ -232,16 +227,9 @@ allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script>
           <dc:Bounds x="931.5" y="336" width="90" height="20" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="Flow_0c94gye_di" bpmnElement="Flow_0c94gye">
-        <di:waypoint x="736" y="281" />
-        <di:waypoint x="778" y="281" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="652" y="336" width="90" height="20" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_1c9nkx4_di" bpmnElement="Flow_1c9nkx4">
         <di:waypoint x="584" y="281" />
-        <di:waypoint x="636" y="281" />
+        <di:waypoint x="655" y="281" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="505" y="336" width="90" height="20" />
         </bpmndi:BPMNLabel>
@@ -271,6 +259,22 @@ allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script>
           <dc:Bounds x="207" y="179" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_15lksyg_di" bpmnElement="Flow_15lksyg">
+        <di:waypoint x="705" y="281" />
+        <di:waypoint x="778" y="281" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_1lzv4jo_di" bpmnElement="Flow_1lzv4jo">
+        <di:waypoint x="680" y="306" />
+        <di:waypoint x="680" y="340" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="603" y="315" width="78" height="27" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_163kxug_di" bpmnElement="Flow_163kxug">
+        <di:waypoint x="630" y="380" />
+        <di:waypoint x="534" y="380" />
+        <di:waypoint x="534" y="321" />
+      </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
         <dc:Bounds x="248" y="102" width="36" height="36" />
         <bpmndi:BPMNLabel>
@@ -298,9 +302,6 @@ allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script>
       <bpmndi:BPMNShape id="Activity_0ge2y0l_di" bpmnElement="Activity_0ge2y0l">
         <dc:Bounds x="484" y="241" width="100" height="80" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Activity_19xwwnc_di" bpmnElement="Activity_19xwwnc">
-        <dc:Bounds x="636" y="241" width="100" height="80" />
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_0k70k5i_di" bpmnElement="Activity_0no0sxa">
         <dc:Bounds x="654" y="80" width="100" height="80" />
       </bpmndi:BPMNShape>
@@ -313,21 +314,27 @@ allocateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script>
       <bpmndi:BPMNShape id="IntermediateThrowEvent_06785ru_di" bpmnElement="IntermediateThrowEvent_09rhn4h">
         <dc:Bounds x="949" y="102" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="923" y="142" width="90" height="14" />
+          <dc:Bounds x="950" y="142" width="36" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="IntermediateCatchEvent_09u3rdp_di" bpmnElement="IntermediateThrowEvent_0qh9wy2">
         <dc:Bounds x="182" y="263" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="156" y="303" width="90" height="14" />
+          <dc:Bounds x="183" y="303" width="36" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Gateway_0sfmiku_di" bpmnElement="Gateway_0sfmiku" isMarkerVisible="true">
         <dc:Bounds x="395" y="256" width="50" height="50" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="380" y="226" width="80" height="27" />
+          <dc:Bounds x="380" y="315.5" width="80" height="27" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Gateway_1boyqt9_di" bpmnElement="Gateway_1boyqt9" isMarkerVisible="true">
+        <dc:Bounds x="655" y="256" width="50" height="50" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_1iksno7_di" bpmnElement="Activity_1qm4des">
+        <dc:Bounds x="630" y="340" width="100" height="80" />
+      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Activity_08h38js_di" bpmnElement="Activity_08h38js" isExpanded="true">
         <dc:Bounds x="250" y="440" width="781" height="196" />
       </bpmndi:BPMNShape>