Altered bpmn and audit behavior on delete vf mod 07/88007/1
authorBoslet, Cory <cory.boslet@att.com>
Fri, 17 May 2019 14:36:25 +0000 (10:36 -0400)
committerBenjamin, Max (mb388a) <mb388a@us.att.com>
Fri, 17 May 2019 14:36:33 +0000 (10:36 -0400)
Renamed variable from contin to flowShouldContinue.
Updated bpmn junits and exceptionbuilder junits.
Updated bpmns to use non interrupting escalation event.
Altered bpmn and audit behavior on delete vf module

Change-Id: I4ade4c934a9193099cfd29d740c68e60633c03e5
Issue-ID: SO-1896
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java

index b69ab15..dabfc81 100644 (file)
@@ -152,7 +152,7 @@ public class ExceptionBuilder {
                 .getProcessDefinition(execution.getProcessDefinitionId()).getKey();
     }
 
-    public void processAuditException(DelegateExecutionImpl execution) {
+    public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) {
         logger.info("Building a WorkflowException for Subflow");
 
         StringBuilder errorMessage = new StringBuilder();
@@ -203,11 +203,15 @@ public class ExceptionBuilder {
         errorMessage.append(
                 "Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.");
 
-        WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString());
-        execution.setVariable("WorkflowException", exception);
-        execution.setVariable("WorkflowExceptionErrorMessage", errorMessage);
-        logger.info("Outgoing WorkflowException is {}", exception);
-        logger.info("Throwing MSOWorkflowException");
-        throw new BpmnError("AAIInventoryFailure");
+        if (flowShouldContinue) {
+            execution.setVariable("StatusMessage", errorMessage.toString());
+        } else {
+            WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString());
+            execution.setVariable("WorkflowException", exception);
+            execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString());
+            logger.info("Outgoing WorkflowException is {}", exception);
+            logger.info("Throwing MSOWorkflowException");
+            throw new BpmnError("AAIInventoryFailure");
+        }
     }
 }
index 4ade9db..549f16b 100644 (file)
@@ -22,6 +22,7 @@ package org.onap.so.client.exception;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.when;
 import org.camunda.bpm.engine.delegate.BpmnError;
@@ -131,7 +132,7 @@ public class ExceptionBuilderTest extends BaseTest {
     public void processAuditExceptionTest() {
         try {
             Mockito.doReturn(extractPojosForBB).when(exceptionBuilder).getExtractPojosForBB();
-            exceptionBuilder.processAuditException((DelegateExecutionImpl) execution);
+            exceptionBuilder.processAuditException((DelegateExecutionImpl) execution, false);
         } catch (BpmnError bpmnException) {
             assertEquals("AAIInventoryFailure", bpmnException.getErrorCode());
             WorkflowException we = execution.getVariable("WorkflowException");
@@ -142,4 +143,19 @@ public class ExceptionBuilderTest extends BaseTest {
         }
     }
 
+    @Test
+    public void processAuditExceptionContinueTest() {
+        try {
+            Mockito.doReturn(extractPojosForBB).when(exceptionBuilder).getExtractPojosForBB();
+            exceptionBuilder.processAuditException((DelegateExecutionImpl) execution, true);
+            String sm = execution.getVariable("StatusMessage");
+            assertNotNull(sm);
+            assertEquals(
+                    "create VF-Module testVfModuleId1 failed due to incomplete A&AI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that AIC RO did not create vserver testVServerId in AAI. Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.",
+                    sm);
+        } catch (BpmnError bpmnException) {
+            fail();
+        }
+    }
+
 }
index 435d85d..ff37874 100644 (file)
@@ -69,7 +69,7 @@
       </bpmn:endEvent>
       <bpmn:sequenceFlow id="SequenceFlow_19gbhlj" sourceRef="catchInventoryException" targetRef="processAuditException" />
       <bpmn:sequenceFlow id="SequenceFlow_0l4jzc5" sourceRef="processAuditException" targetRef="EndEvent_067jv1n" />
-      <bpmn:serviceTask id="processAuditException" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+      <bpmn:serviceTask id="processAuditException" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)), false)}">
         <bpmn:incoming>SequenceFlow_19gbhlj</bpmn:incoming>
         <bpmn:outgoing>SequenceFlow_0l4jzc5</bpmn:outgoing>
       </bpmn:serviceTask>
index 41c3966..b774c05 100644 (file)
       <bpmn:outgoing>SequenceFlow_1ut7n32</bpmn:outgoing>
     </bpmn:exclusiveGateway>
     <bpmn:subProcess id="SubProcess_0grvkj2" name="Audit Exception Sub Process" triggeredByEvent="true">
-      <bpmn:startEvent id="StartEvent_1euiddy">
-        <bpmn:outgoing>SequenceFlow_0xuodpy</bpmn:outgoing>
-        <bpmn:errorEventDefinition errorRef="Error_0jjnve8" />
-      </bpmn:startEvent>
       <bpmn:endEvent id="EndEvent_1gzq57j">
         <bpmn:incoming>SequenceFlow_1fhst92</bpmn:incoming>
       </bpmn:endEvent>
-      <bpmn:serviceTask id="ServiceTask_1isbxvo" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+      <bpmn:serviceTask id="ServiceTask_1isbxvo" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)), true)}">
         <bpmn:incoming>SequenceFlow_0xuodpy</bpmn:incoming>
         <bpmn:outgoing>SequenceFlow_1fhst92</bpmn:outgoing>
       </bpmn:serviceTask>
       <bpmn:sequenceFlow id="SequenceFlow_0xuodpy" sourceRef="StartEvent_1euiddy" targetRef="ServiceTask_1isbxvo" />
       <bpmn:sequenceFlow id="SequenceFlow_1fhst92" sourceRef="ServiceTask_1isbxvo" targetRef="EndEvent_1gzq57j" />
+      <bpmn:startEvent id="StartEvent_1euiddy" isInterrupting="false">
+        <bpmn:outgoing>SequenceFlow_0xuodpy</bpmn:outgoing>
+        <bpmn:escalationEventDefinition escalationRef="Escalation_130je8j" camunda:escalationCodeVariable="test" />
+      </bpmn:startEvent>
     </bpmn:subProcess>
     <bpmn:sequenceFlow id="SequenceFlow_179btn2" sourceRef="aaiCatch" targetRef="DeleteNetworkPolicies" />
     <bpmn:intermediateThrowEvent id="aaiThrow" name="Update AAI">
       <bpmn:outgoing>SequenceFlow_179btn2</bpmn:outgoing>
       <bpmn:linkEventDefinition name="AAI" />
     </bpmn:intermediateCatchEvent>
-    <bpmn:exclusiveGateway id="auditSuccessfulCheck" name="Audit&#10; Successful?" default="SequenceFlow_17cd9e2">
-      <bpmn:incoming>SequenceFlow_0qfmmgt</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_17cd9e2</bpmn:outgoing>
-      <bpmn:outgoing>SequenceFlow_1gdyk9j</bpmn:outgoing>
-    </bpmn:exclusiveGateway>
-    <bpmn:sequenceFlow id="SequenceFlow_17cd9e2" name="Yes" sourceRef="auditSuccessfulCheck" targetRef="ExclusiveGateway_1pydilb" />
+    <bpmn:sequenceFlow id="SequenceFlow_17cd9e2" name="Yes/No" sourceRef="auditSuccessfulCheck" targetRef="ExclusiveGateway_1pydilb">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditIsSuccessful") == false || execution.getVariable("auditIsSuccessful") == true}]]></bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="SequenceFlow_1gdyk9j" name="No" sourceRef="auditSuccessfulCheck" targetRef="EndEvent_0b0ocu0">
       <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditIsSuccessful") == false}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
-    <bpmn:endEvent id="EndEvent_0b0ocu0">
-      <bpmn:incoming>SequenceFlow_1gdyk9j</bpmn:incoming>
-      <bpmn:errorEventDefinition errorRef="Error_0jjnve8" />
-    </bpmn:endEvent>
     <bpmn:inclusiveGateway id="ExclusiveGateway_1yvh16a">
       <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming>
       <bpmn:incoming>SequenceFlow_1ut7n32</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_14bu4ys</bpmn:outgoing>
     </bpmn:inclusiveGateway>
+    <bpmn:inclusiveGateway id="auditSuccessfulCheck" name="Audit&#10; Successful?">
+      <bpmn:incoming>SequenceFlow_0qfmmgt</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_17cd9e2</bpmn:outgoing>
+      <bpmn:outgoing>SequenceFlow_1gdyk9j</bpmn:outgoing>
+    </bpmn:inclusiveGateway>
+    <bpmn:endEvent id="EndEvent_0b0ocu0">
+      <bpmn:incoming>SequenceFlow_1gdyk9j</bpmn:incoming>
+      <bpmn:escalationEventDefinition escalationRef="Escalation_130je8j" />
+    </bpmn:endEvent>
   </bpmn:process>
   <bpmn:error id="Error_0jjnve8" name="Error_3k24na6" errorCode="AAIInventoryFailure" />
+  <bpmn:escalation id="Escalation_130je8j" name="audit" escalationCode="audit1" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteVfModuleBB">
       <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="DeleteVfModuleBB_Start">
       <bpmndi:BPMNShape id="SubProcess_0grvkj2_di" bpmnElement="SubProcess_0grvkj2" isExpanded="true">
         <dc:Bounds x="231" y="642" width="350" height="200" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="StartEvent_1euiddy_di" bpmnElement="StartEvent_1euiddy">
-        <dc:Bounds x="262" y="725" width="36" height="36" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="189" y="765" width="90" height="12" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_1gzq57j_di" bpmnElement="EndEvent_1gzq57j">
         <dc:Bounds x="510" y="725" width="36" height="36" />
         <bpmndi:BPMNLabel>
         <di:waypoint xsi:type="dc:Point" x="298" y="743" />
         <di:waypoint xsi:type="dc:Point" x="353" y="743" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="237" y="722" width="90" height="12" />
+          <dc:Bounds x="280.5" y="722" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1fhst92_di" bpmnElement="SequenceFlow_1fhst92">
           <dc:Bounds x="150" y="530" width="55" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="ExclusiveGateway_187bfld_di" bpmnElement="auditSuccessfulCheck" isMarkerVisible="true">
-        <dc:Bounds x="779.6431784107947" y="108" width="50" height="50" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="775" y="162" width="60" height="24" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_17cd9e2_di" bpmnElement="SequenceFlow_17cd9e2">
         <di:waypoint xsi:type="dc:Point" x="830" y="133" />
         <di:waypoint xsi:type="dc:Point" x="868" y="133" />
         <di:waypoint xsi:type="dc:Point" x="868" y="174" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="838" y="114" width="19" height="12" />
+          <dc:Bounds x="830" y="114" width="36" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1gdyk9j_di" bpmnElement="SequenceFlow_1gdyk9j">
         <di:waypoint xsi:type="dc:Point" x="805" y="108" />
         <di:waypoint xsi:type="dc:Point" x="805" y="56" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="812" y="77.49056603773585" width="14" height="12" />
+          <dc:Bounds x="812" y="77" width="14" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNShape id="EndEvent_1wydovd_di" bpmnElement="EndEvent_0b0ocu0">
-        <dc:Bounds x="787" y="20" width="36" height="36" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="805" y="59.13043478260869" width="0" height="12" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="InclusiveGateway_0cjvlht_di" bpmnElement="ExclusiveGateway_1yvh16a">
         <dc:Bounds x="900" y="259" width="50" height="50" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="879" y="312" width="0" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="InclusiveGateway_0i6rdd1_di" bpmnElement="auditSuccessfulCheck">
+        <dc:Bounds x="780" y="108" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="775" y="162" width="60" height="24" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="StartEvent_04qhoba_di" bpmnElement="StartEvent_1euiddy">
+        <dc:Bounds x="262" y="725" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="189" y="765" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="EndEvent_1onxfk1_di" bpmnElement="EndEvent_0b0ocu0">
+        <dc:Bounds x="787" y="20" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="760" y="59" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>
index 83363d4..0a6a773 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0">
   <bpmn:process id="ExecuteBuildingBlock" name="ExecuteBuildingBlock" isExecutable="true">
     <bpmn:startEvent id="Start_ExecuteBuildingBlock" name="start">
       <bpmn:outgoing>SequenceFlow_0rq4c5r</bpmn:outgoing>
@@ -10,6 +10,7 @@
         <camunda:out source="WorkflowException" target="WorkflowException" />
         <camunda:in source="mso-request-id" target="mso-request-id" />
         <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" />
+        <camunda:out source="StatusMessage" target="StatusMessage" />
       </bpmn:extensionElements>
       <bpmn:incoming>SequenceFlow_19wuics</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_01h9qmz</bpmn:outgoing>
index 76ca2a8..35b77d9 100644 (file)
@@ -22,6 +22,7 @@
         <camunda:out source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" />
         <camunda:out source="RetryDuration" target="RetryDuration" />
         <camunda:in source="suppressRollback" target="suppressRollback" />
+        <camunda:out source="StatusMessage" target="StatusMessage" />
       </bpmn:extensionElements>
       <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1hsqed1</bpmn:outgoing>
index e88df73..d9166c9 100644 (file)
@@ -37,6 +37,7 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest {
     @Before
     public void before() {
         variables.put("auditInventoryNeeded", true);
+        variables.put("auditIsSuccessful", true);
     }
 
     @Test
index f0a102d..753a050 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -227,11 +227,16 @@ public class WorkflowActionBBTasks {
             final String action = (String) execution.getVariable(G_ACTION);
             final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
             final String resourceName = (String) execution.getVariable("resourceName");
+            String statusMessage = (String) execution.getVariable("StatusMessage");
             String macroAction = "";
-            if (aLaCarte) {
-                macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly.";
+            if (statusMessage == null) {
+                if (aLaCarte) {
+                    macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly.";
+                } else {
+                    macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly.";
+                }
             } else {
-                macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly.";
+                macroAction = statusMessage;
             }
             execution.setVariable("finalStatusMessage", macroAction);
             Timestamp endTime = new Timestamp(System.currentTimeMillis());