Merge "- Make association from the cvnfc to the fabric"
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
index 3c073af..d758243 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
@@ -50,7 +50,6 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
-import org.onap.so.client.RestTemplateConfig;
 import javax.inject.Provider;
 
 @Component
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 8894df0..da989b0 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -977,29 +977,28 @@
 
         logger.debug("VF Category is : " + vfCustomizationCategory);
 
-        if (vfResourceStructure.getVfModuleStructure() != null
-                && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
+        String vfCustomizationUUID =
+                vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
 
-            String vfCustomizationUUID =
-                    vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+        logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
 
-            logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+        IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
 
-            IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+        // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
+        // comparing their VF Modules UUID's
+        logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
+                + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
+                + vfCustomizationUUID);
 
-            // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
-            // comparing their VF Modules UUID's
-            logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
-                    + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
-                    + vfCustomizationUUID);
+        if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
 
-            if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+            logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+                    + " matches vfNotificationResource CustomizationUUID");
 
-                logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
-                        + " matches vfNotificationResource CustomizationUUID");
+            VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service);
 
-                VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service);
-
+            if (vfResourceStructure.getVfModuleStructure() != null
+                    && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
                 Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>();
                 Set<VnfcCustomization> existingVnfcSet = new HashSet<>();
                 List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom = new ArrayList<>();
@@ -1036,34 +1035,33 @@
                                         + vfMetadata.getVfModuleModelCustomizationUUID());
 
                 }
-
-
-                // Check for VNFC Instance Group info and add it if there is
-                List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct,
-                        EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"),
-                        TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
-
-
-                for (IEntityDetails groupEntity : vfcEntityList) {
-                    VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization =
-                            createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct);
-                    vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
-                }
-
-                List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList);
-                if (!CollectionUtils.isEmpty(seqResult)) {
-                    String resultStr = seqResult.stream().collect(Collectors.joining(","));
-                    vnfResource.setVnfcInstanceGroupOrder(resultStr);
-                    logger.debug(
-                            "vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr);
-                }
-                // add this vnfResource with existing vnfResource for this service
-                addVnfCustomization(service, vnfResource);
-            } else {
-                logger.debug("Notification VF ResourceCustomizationUUID: "
-                        + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
-                        + "Tosca VF Customization UUID: " + vfCustomizationUUID);
             }
+
+
+            // Check for VNFC Instance Group info and add it if there is
+            List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct,
+                    EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"),
+                    TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
+
+
+            for (IEntityDetails groupEntity : vfcEntityList) {
+                VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization =
+                        createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct);
+                vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
+            }
+
+            List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList);
+            if (!CollectionUtils.isEmpty(seqResult)) {
+                String resultStr = seqResult.stream().collect(Collectors.joining(","));
+                vnfResource.setVnfcInstanceGroupOrder(resultStr);
+                logger.debug("vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr);
+            }
+            // add this vnfResource with existing vnfResource for this service
+            addVnfCustomization(service, vnfResource);
+        } else {
+            logger.debug("Notification VF ResourceCustomizationUUID: "
+                    + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+                    + "Tosca VF Customization UUID: " + vfCustomizationUUID);
         }
     }
 
@@ -1494,17 +1492,17 @@
         Optional<ToscaCsar> toscaCsarOpt =
                 toscaCsarRepo.findById(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
         ToscaCsar toscaCsar;
-        if (toscaCsarOpt.isPresent()) {
-            toscaCsar = toscaCsarOpt.get();
-        } else {
+        if (!toscaCsarOpt.isPresent()) {
             toscaCsar = new ToscaCsar();
+            toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
+        } else {
+            toscaCsar = toscaCsarOpt.get();
         }
         if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
             toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
         } else {
             toscaCsar.setArtifactChecksum(MANUAL_RECORD);
         }
-        toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
         toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
         toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
         toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
@@ -1878,10 +1876,11 @@
         InstanceGroup existingInstanceGroup =
                 instanceGroupRepo.findByModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
 
-        VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
+        VFCInstanceGroup vfcInstanceGroup;
 
         if (existingInstanceGroup == null) {
             // Populate InstanceGroup
+            vfcInstanceGroup = new VFCInstanceGroup();
             vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
             vfcInstanceGroup
                     .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
index cfcf5ac..2a4b3aa 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
@@ -43,6 +43,8 @@
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mockito;
 import org.mockito.Spy;
 import org.onap.so.asdc.BaseTest;
 import org.onap.so.asdc.client.test.emulators.DistributionClientEmulator;
@@ -67,6 +69,7 @@
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.test.util.ReflectionTestUtils;
 
 public class ASDCRestInterfaceTest extends BaseTest {
 
@@ -107,6 +110,7 @@
     public void setUp() {
         // ASDC Controller writes to this path
         System.setProperty("mso.config.path", folder.getRoot().toString());
+        ReflectionTestUtils.setField(toscaInstaller, "toscaCsarRepo", toscaCsarRepo);
     }
 
     @Test
@@ -310,9 +314,9 @@
                 HttpMethod.POST, entity, String.class);
         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
 
-        Optional<Service> service = serviceRepo.findById("5c4d4793-67fb-4155-b7d8-60ec011138c9");
+        Optional<Service> service = serviceRepo.findById("317887d3-a4e4-45cb-8971-2a78426fefac");
         assertTrue(service.isPresent());
-        assertEquals("SDWAN", service.get().getModelName());
+        assertEquals("CCVPNService", service.get().getModelName());
     }
 
     protected String createURLWithPort(String uri) {
diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json b/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json
index bc7d7d7..1ca96f7 100644
--- a/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json
+++ b/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json
@@ -1,31 +1,31 @@
 {
-  "distributionID": "cbc7ab24-7d96-4cb5-949c-f23ada265513",
-  "serviceName": "SDWAN",
-  "serviceVersion": "2.0",
-  "serviceUUID": "5c4d4793-67fb-4155-b7d8-60ec011138c9",
-  "serviceDescription": "SDWAN Service",
-  "serviceInvariantUUID": "e830c260-ee21-4830-980c-c802cd9bbb1c",
+  "distributionID": "8a01603d-606d-4e40-8bc4-37107ad97897",
+  "serviceName": "CCVPNService",
+  "serviceVersion": "1.0",
+  "serviceUUID": "317887d3-a4e4-45cb-8971-2a78426fefac",
+  "serviceDescription": "CCVPN",
+  "serviceInvariantUUID": "e43f9b81-3035-44df-b618-a787e1c49427",
   "resources": [
     {
-      "resourceInstanceName": "siteVF 0",
-      "resourceName": "siteVF",
+      "resourceInstanceName": "siteResource",
+      "resourceCustomizationUUID": "e9e01777-bb2f-42f0-b825-aef0f4c37ccf",
+      "resourceName": "siteResource",
       "resourceVersion": "1.0",
       "resoucreType": "VF",
-      "resourceUUID": "2c10d85c-e492-4813-a2d6-d1fab757fe49",
-      "resourceInvariantUUID": "ed9b1fe5-1e94-4974-a48f-389571837fd6",
-      "resourceCustomizationUUID": "33de5105-edf3-48cb-bda0-37b2aa2f681f",
+      "resourceUUID": "5a641276-443b-45ca-ac9c-a0ee84f5007b",
+      "resourceInvariantUUID": "5338673f-df81-483a-afa4-b9766442ebf1",
       "category": "Configuration",
       "subcategory": "Configuration",
       "artifacts": []
     },
     {
-      "resourceInstanceName": "vpn 0",
-      "resourceName": "vpn",
-      "resourceVersion": "2.0",
+      "resourceInstanceName": "SDWANVPNResource",
+      "resourceCustomizationUUID": "7815f32c-bdbf-41f7-9a18-6f0e6d5a0d0e",
+      "resourceName": "SDWANVPNResource",
+      "resourceVersion": "1.0",
       "resoucreType": "VF",
-      "resourceUUID": "235861f1-ea93-4443-94fa-82f29903f54f",
-      "resourceInvariantUUID": "c4eff5e7-c4fe-4caf-989b-11efc8e42a73",
-      "resourceCustomizationUUID": "faa89d44-329b-4fcb-a5dc-6e6f84946537",
+      "resourceUUID": "5f9f2164-f7e4-461d-b8de-3470297ce2b3",
+      "resourceInvariantUUID": "5ca15886-9990-419c-a4bb-f0229eac0926",
       "category": "Configuration",
       "subcategory": "Configuration",
       "artifacts": []
@@ -33,24 +33,14 @@
   ],
   "serviceArtifacts": [
     {
-      "artifactName": "service-Sdwan-template.yml",
-      "artifactType": "TOSCA_TEMPLATE",
-      "artifactURL": "/sdc/v1/catalog/services/Sdwan/2.0/artifacts/service-Sdwan-template.yml",
-      "artifactChecksum": "Zjg4MmJmNzI1MTliYzBiZjA2ZmJjN2EwNzZhZTcxYTQ=",
-      "artifactDescription": "TOSCA representation of the asset",
-      "artifactTimeout": 0,
-      "artifactUUID": "5e7beb91-61f9-4613-8cc5-1d288a624abb",
-      "artifactVersion": "2"
-    },
-    {
-      "artifactName": "service-Sdwan-csar.csar",
+      "artifactName": "service-Ccvpnservice-csar.csar",
       "artifactType": "TOSCA_CSAR",
-      "artifactURL": "/service-Sdwan-csar.csar",
-      "artifactChecksum": "ODA1ZGViMzI0NzIxMmRmNTIzYzE0ZTg5NmExYWFjZTE=",
+      "artifactURL": "/service-Ccvpnservice-csar.csar",
+      "artifactChecksum": "NTZlNGU4YTQwNzVkZWMwYWZkODE5M2MwYzcyNzM3M2U\u003d",
       "artifactDescription": "TOSCA definition package of the asset",
       "artifactTimeout": 0,
-      "artifactUUID": "771ec21a-1d14-4891-a56f-d4e47e2c8c91",
-      "artifactVersion": "2"
+      "artifactVersion": "2",
+      "artifactUUID": "59f34dcf-ec33-4a88-8dbe-aa7f4571ef59"
     }
   ],
   "workloadContext": "Production"
diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Ccvpnservice-csar.csar b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Ccvpnservice-csar.csar
new file mode 100644
index 0000000..ce2ac5e
--- /dev/null
+++ b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Ccvpnservice-csar.csar
Binary files differ
diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar
deleted file mode 100644
index 7a50842..0000000
--- a/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar
+++ /dev/null
Binary files differ
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
index e71404a..93f98a3 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
@@ -1384,172 +1384,6 @@
     }
 
     /**
-     * Runs a program to inject sniro workflow messages into the test environment. A program is essentially just a list
-     * of keys that identify event data to be injected, in sequence. For more details, see injectSNIROCallbacks(String
-     * contentType, String messageType, String content, long timeout)
-     *
-     * Errors are handled with junit assertions and will cause the test to fail. NOTE: Each callback must have a
-     * workflow message type associated with it.
-     *
-     * @param callbacks an object containing event data for the program
-     * @param program the program to execute
-     */
-    protected void injectSNIROCallbacks(CallbackSet callbacks, String program) {
-
-        String[] cmds = program.replaceAll("\\s+", "").split(",");
-
-        for (String cmd : cmds) {
-            String action = cmd;
-            String modifier = "STD";
-
-            if (cmd.contains(":")) {
-                String[] parts = cmd.split(":");
-                action = parts[0];
-                modifier = parts[1];
-            }
-
-            String messageType = null;
-            String content = null;
-            String contentType = null;
-
-            if ("STD".equals(modifier)) {
-                CallbackData callbackData = callbacks.get(action);
-
-                if (callbackData == null) {
-                    String msg = "No '" + action + "' workflow message callback is defined";
-                    logger.debug(msg);
-                    fail(msg);
-                }
-
-                messageType = callbackData.getMessageType();
-
-                if (messageType == null || messageType.trim().equals("")) {
-                    String msg = "No workflow message type is defined in the '" + action + "' callback";
-                    logger.debug(msg);
-                    fail(msg);
-                }
-
-                content = callbackData.getContent();
-                contentType = callbackData.getContentType();
-            } else {
-                String msg = "Invalid workflow message program modifier: '" + modifier + "'";
-                logger.debug(msg);
-                fail(msg);
-            }
-
-            if (!injectSNIROCallbacks(contentType, messageType, content, 10000)) {
-                fail("Failed to inject '" + action + "' workflow message");
-            }
-
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException e) {
-                fail("Interrupted after injection of '" + action + "' workflow message");
-            }
-        }
-    }
-
-    /**
-     * Injects a sniro workflow message. The specified callback response may contain the placeholder strings
-     * ((CORRELATOR)) and ((SERVICE_RESOURCE_ID)) The ((CORRELATOR)) is replaced with the actual correlator value from
-     * the request. The ((SERVICE_RESOURCE_ID)) is replaced with the actual serviceResourceId value from the sniro
-     * request. Currently this only works with sniro request that contain only 1 resource.
-     *
-     * @param contentType the HTTP contentType for the message (possibly null)
-     * @param messageType the message type
-     * @param content the message content (possibly null)
-     * @param timeout the timeout in milliseconds
-     * @return true if the message could be injected, false otherwise
-     */
-    protected boolean injectSNIROCallbacks(String contentType, String messageType, String content, long timeout) {
-        String correlator = (String) getProcessVariable("ReceiveWorkflowMessage", messageType + "_CORRELATOR", timeout);
-
-        if (correlator == null) {
-            return false;
-        }
-        if (content != null) {
-            content = content.replace("((CORRELATOR))", correlator);
-            if (messageType.equalsIgnoreCase("SNIROResponse")) {
-                ServiceDecomposition decomp =
-                        (ServiceDecomposition) getProcessVariable("Homing", "serviceDecomposition", timeout);
-                List<Resource> resourceList = decomp.getServiceResources();
-                if (resourceList.size() == 1) {
-                    String resourceId = "";
-                    for (Resource resource : resourceList) {
-                        resourceId = resource.getResourceId();
-                    }
-                    String homingList = getJsonValue(content, "solutionInfo.placementInfo");
-                    JSONArray placementArr = null;
-                    try {
-                        placementArr = new JSONArray(homingList);
-                    } catch (Exception e) {
-                        return false;
-                    }
-                    if (placementArr.length() == 1) {
-                        content = content.replace("((SERVICE_RESOURCE_ID))", resourceId);
-                    }
-                    String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo");
-                    JSONArray licenseArr = null;
-                    try {
-                        licenseArr = new JSONArray(licenseInfoList);
-                    } catch (Exception e) {
-                        return false;
-                    }
-                    if (licenseArr.length() == 1) {
-                        content = content.replace("((SERVICE_RESOURCE_ID))", resourceId);
-                    }
-                } else {
-                    try {
-                        String homingList = getJsonValue(content, "solutionInfo.placementInfo");
-                        String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo");
-                        JSONArray placementArr = new JSONArray(homingList);
-                        JSONArray licenseArr = new JSONArray(licenseInfoList);
-                        for (Resource resource : resourceList) {
-                            String resourceModuleName = resource.getModelInfo().getModelInstanceName();
-                            String resourceId = resource.getResourceId();
-
-                            for (int i = 0; i < placementArr.length(); i++) {
-                                JSONObject placementObj = placementArr.getJSONObject(i);
-                                String placementModuleName = placementObj.getString("resourceModuleName");
-                                if (placementModuleName.equalsIgnoreCase(resourceModuleName)) {
-                                    String placementString = placementObj.toString();
-                                    placementString = placementString.replace("((SERVICE_RESOURCE_ID))", resourceId);
-                                    JSONObject newPlacementObj = new JSONObject(placementString);
-                                    placementArr.put(i, newPlacementObj);
-                                }
-                            }
-
-                            for (int i = 0; i < licenseArr.length(); i++) {
-                                JSONObject licenseObj = licenseArr.getJSONObject(i);
-                                String licenseModuleName = licenseObj.getString("resourceModuleName");
-                                if (licenseModuleName.equalsIgnoreCase(resourceModuleName)) {
-                                    String licenseString = licenseObj.toString();
-                                    licenseString = licenseString.replace("((SERVICE_RESOURCE_ID))", resourceId);
-                                    JSONObject newLicenseObj = new JSONObject(licenseString);
-                                    licenseArr.put(i, newLicenseObj);
-                                }
-                            }
-                        }
-                        String newPlacementInfos = placementArr.toString();
-                        String newLicenseInfos = licenseArr.toString();
-                        content = updJsonValue(content, "solutionInfo.placementInfo", newPlacementInfos);
-                        content = updJsonValue(content, "solutionInfo.licenseInfo", newLicenseInfos);
-                    } catch (Exception e) {
-                        return false;
-                    }
-
-                }
-            }
-        }
-        logger.debug("Injecting " + messageType + " message");
-
-        Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content);
-        logger.debug("Workflow response to {} message: {}", messageType, response);
-        return true;
-    }
-
-
-    /**
      * Wait for the process to end.
      * 
      * @param businessKey the process business key
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
index 9340609..d9c6857 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
@@ -33,6 +33,7 @@
 import org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables;
 import org.camunda.bpm.engine.variable.VariableMap;
 import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBFailure;
 import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBTasks;
 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
@@ -79,6 +80,8 @@
     @Autowired
     private ExceptionBuilder exceptionBuilder;
     @Autowired
+    private WorkflowActionBBFailure workflowActionBBFailure;
+    @Autowired
     private WorkflowActionBBTasks workflowActionBBTasks;
 
     @Override
@@ -178,13 +181,15 @@
     protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
         logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
                 ErrorCode.UnknownError.getValue(), msg, ex);
-        execution.setVariable("ExecuteActivityErrorMessage", msg);
+        execution.setVariable(EXECUTE_ACTIVITY_ERROR_MESSAGE, msg);
+        workflowActionBBFailure.updateRequestStatusToFailed(execution);
         exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
     }
 
     protected void buildAndThrowException(DelegateExecution execution, String msg) {
         logger.error(msg);
         execution.setVariable(EXECUTE_ACTIVITY_ERROR_MESSAGE, msg);
+        workflowActionBBFailure.updateRequestStatusToFailed(execution);
         exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
     }
 }
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
index 56ff813..c005629 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
@@ -22,22 +22,41 @@
 
 
 import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import org.camunda.bpm.engine.delegate.BpmnError;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
 import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBFailure;
 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.client.exception.ExceptionBuilder;
 
 public class ExecuteActivityTest extends BaseTaskTest {
     @InjectMocks
     protected ExecuteActivity executeActivity = new ExecuteActivity();
 
+    @InjectMocks
+    @Spy
+    private ExceptionBuilder exceptionBuilder;
+
+    @Mock
+    private WorkflowActionBBFailure workflowActionBBFailure;
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     private DelegateExecution execution;
 
     @Before
@@ -72,4 +91,17 @@
         assertEquals(ebb.getBuildingBlock(), bb);
     }
 
+    @Test
+    public void buildAndThrowException_Test() throws Exception {
+        doNothing().when(workflowActionBBFailure).updateRequestStatusToFailed(execution);
+        doReturn("Process key").when(exceptionBuilder).getProcessKey(execution);
+        thrown.expect(BpmnError.class);
+        executeActivity.buildAndThrowException(execution, "TEST EXCEPTION MSG");
+        String errorMessage = (String) execution.getVariable("ExecuteActivityErrorMessage");
+        assertEquals(errorMessage, "TEST EXCEPTION MSG");
+        WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
+        assertEquals(workflowException.getErrorMessage(), "TEST EXCEPTION MSG");
+        assertEquals(workflowException.getErrorCode(), 7000);
+    }
+
 }
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index a5ccb1b..8896e93 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -83,6 +83,7 @@
 public class OrchestrationRequests {
 
     private static Logger logger = LoggerFactory.getLogger(OrchestrationRequests.class);
+    private static final String ERROR_MESSAGE_PREFIX = "Error Source: %s, Error Message: %s";
 
     @Autowired
     private RequestsDbClient requestsDbClient;
@@ -449,7 +450,12 @@
 
         String statusMessages = null;
         if (iar.getStatusMessage() != null) {
-            statusMessages = "STATUS: " + iar.getStatusMessage();
+            if (StringUtils.isNotBlank(iar.getExtSystemErrorSource())) {
+                statusMessages = "STATUS: "
+                        + String.format(ERROR_MESSAGE_PREFIX, iar.getExtSystemErrorSource(), iar.getStatusMessage());
+            } else {
+                statusMessages = "STATUS: " + iar.getStatusMessage();
+            }
         }
 
         if (OrchestrationRequestFormat.STATUSDETAIL.toString().equalsIgnoreCase(format)) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
index f672648..627bbc6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
@@ -25,6 +25,7 @@
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.doReturn;
 import javax.ws.rs.core.Response;
 import org.apache.commons.lang.StringUtils;
@@ -232,6 +233,21 @@
     }
 
     @Test
+    public void mapRequestStatusAndExtSysErrSrcToRequestErrorMessageTest() throws ApiException {
+        InstanceReferences instanceReferences = new InstanceReferences();
+        instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+        iar.setExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
+        iar.setFlowStatus(null);
+        iar.setStatusMessage("Error retrieving cloud region from AAI");
+
+        Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+                OrchestrationRequestFormat.DETAIL.toString());
+
+        assertTrue(actual.getRequestStatus().getStatusMessage()
+                .contains("Error Source: " + ROLLBACK_EXT_SYSTEM_ERROR_SOURCE));
+    }
+
+    @Test
     public void mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulCompletionTest() throws ApiException {
         InstanceReferences instanceReferences = new InstanceReferences();
         instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);