aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElena Kuleshov <EK1439@att.com>2018-09-20 11:12:01 -0400
committerElena Kuleshov <EK1439@att.com>2018-09-20 11:12:20 -0400
commit82e8b0b7045ea96eb1788317fb4101a53ecc77be (patch)
tree195652afac489527537d22cffba3d61a2c7c5f66
parent19659e205ef636cec767e32a62cc549cf9156d5b (diff)
Activity for Flow Completion Status
Add a JUnit for existing workflow exception Changes to base test to include flowCompletionTasks Workflow Designer - implementation of Completion Activity Change-Id: Id80a92f97603c10a40ef401522a05a52d976247e Issue-ID: SO-843 Signed-off-by: Elena Kuleshov <EK1439@att.com>
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json14
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn49
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java4
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java56
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java80
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java68
6 files changed, 271 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json
new file mode 100644
index 0000000000..e031c85501
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/FlowCompleteActivitySpec.json
@@ -0,0 +1,14 @@
+{
+ "name": "FlowCompleteActivity",
+ "description": "Activity to Complete the BPMN Flow",
+ "categoryList": [
+ "VNF"
+ ],
+ "inputParameters": [
+ {
+ "name": "WorkflowException",
+ "type": "WorkflowException"
+ }
+ ],
+ "outputParameters": []
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn
new file mode 100644
index 0000000000..e255689e75
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/FlowCompleteActivity.bpmn
@@ -0,0 +1,49 @@
+<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0">
+ <bpmn:process id="FlowCompleteActivity" name="FlowCompleteActivity" isExecutable="true">
+ <bpmn:startEvent id="FlowCompleteActivity_Start">
+ <bpmn:outgoing>SequenceFlow_1tbhm2c</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:endEvent id="FlowCompleteActivity_End">
+ <bpmn:incoming>SequenceFlow_10spt85</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_1tbhm2c" sourceRef="FlowCompleteActivity_Start" targetRef="TaskUpdateRequestDB" />
+ <bpmn:sequenceFlow id="SequenceFlow_10spt85" sourceRef="TaskUpdateRequestDB" targetRef="FlowCompleteActivity_End" />
+ <bpmn:serviceTask id="TaskUpdateRequestDB" name="Update Request DB with Status" camunda:expression="${FlowCompletionTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_1tbhm2c</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_10spt85</bpmn:outgoing>
+ </bpmn:serviceTask>
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="FlowCompleteActivity">
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="FlowCompleteActivity_Start">
+ <dc:Bounds x="173" y="102" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_0uee341_di" bpmnElement="FlowCompleteActivity_End">
+ <dc:Bounds x="428" y="102" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="446" y="138" width="0" height="0" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1tbhm2c_di" bpmnElement="SequenceFlow_1tbhm2c">
+ <di:waypoint xsi:type="dc:Point" x="209" y="120" />
+ <di:waypoint xsi:type="dc:Point" x="264" y="120" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="237" y="105" width="0" height="0" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_10spt85_di" bpmnElement="SequenceFlow_10spt85">
+ <di:waypoint xsi:type="dc:Point" x="364" y="120" />
+ <di:waypoint xsi:type="dc:Point" x="394" y="120" />
+ <di:waypoint xsi:type="dc:Point" x="394" y="120" />
+ <di:waypoint xsi:type="dc:Point" x="428" y="120" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="409" y="120" width="0" height="0" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0f1gnqq_di" bpmnElement="TaskUpdateRequestDB">
+ <dc:Bounds x="264" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
index 8bd4aeb387..ac62af2e9d 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
@@ -63,6 +63,7 @@ import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCChangeAssignTasks;
import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCDeactivateTasks;
import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCQueryTasks;
import org.onap.so.bpmn.infrastructure.sdnc.tasks.SDNCUnassignTasks;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.FlowCompletionTasks;
import org.onap.so.bpmn.infrastructure.workflow.tasks.OrchestrationStatusValidator;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowAction;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBTasks;
@@ -199,6 +200,9 @@ public abstract class BaseBPMNTest {
@MockBean
protected ConfigurationScaleOut configurationScaleOut;
+ @MockBean
+ protected FlowCompletionTasks flowCompletionTasks;
+
@LocalServerPort
private int port;
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java
new file mode 100644
index 0000000000..50184a535d
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/FlowCompleteActivity.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.bpmn.subprocess;
+
+import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doThrow;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.BaseBPMNTest;
+
+public class FlowCompleteActivity extends BaseBPMNTest{
+ @Test
+ public void sunnyDayFlowCompleteActivity_Test() throws InterruptedException {
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("FlowCompleteActivity", variables);
+ assertThat(pi).isNotNull();
+ assertThat(pi).isStarted().hasPassedInOrder("FlowCompleteActivity_Start",
+ "TaskUpdateRequestDB",
+ "FlowCompleteActivity_End");
+ assertThat(pi).isEnded();
+ }
+
+ @Test
+ public void rainyDayFlowCompleteActivity_Test() throws Exception {
+ doThrow(new BpmnError("7000", "TESTING ERRORS")).when(flowCompletionTasks)
+ .updateRequestDbStatus(any(BuildingBlockExecution.class));
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("FlowCompleteActivity", variables);
+ assertThat(pi).isNotNull();
+ assertThat(pi).isStarted().hasPassedInOrder("FlowCompleteActivity_Start",
+ "TaskUpdateRequestDB").hasNotPassed(
+ "FlowCompleteActivity_End");
+ assertThat(pi).isEnded();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java
new file mode 100644
index 0000000000..ec2ccdf202
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse;
+import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Component
+public class FlowCompletionTasks {
+
+ private static final Logger logger = LoggerFactory.getLogger(FlowCompletionTasks.class);
+
+ @Autowired
+ private RequestsDbClient requestDbclient;
+
+ public void updateRequestDbStatus(BuildingBlockExecution execution) {
+ try {
+ String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId();
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+
+ WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
+ if (workflowException == null) {
+ request.setStatusMessage("RequestCompletedSuccessfully");
+ request.setRequestStatus("COMPLETE");
+
+ }
+ else {
+ request.setStatusMessage(workflowException.getErrorMessage());
+ request.setRequestStatus("FAILED");
+ }
+ request.setProgress(100L);
+ request.setLastModifiedBy("CamundaBPMN");
+
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception e) {
+ logger.error("Unable to save the updated request status to the DB",e);
+ }
+ }
+
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
new file mode 100644
index 0000000000..03ed2cb4d4
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class FlowCompletionTasksTest extends BaseTaskTest {
+
+ @Autowired
+ protected FlowCompletionTasks flowCompletionTasks;
+
+ @Before
+ public void before() {
+ setRequestContext();
+ }
+
+ @Test
+ public void updateRequestDbStatusComplete_Test() throws Exception{
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ flowCompletionTasks.updateRequestDbStatus(execution);
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ assertEquals(mockedRequest.getRequestStatus(), "COMPLETE");
+ }
+
+ @Test
+ public void updateRequestDbStatusFailed_Test() throws Exception{
+ WorkflowException workflowException = new WorkflowException("testProcessKey", 7000, "Error");
+ execution.setVariable("WorkflowException", workflowException);
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ flowCompletionTasks.updateRequestDbStatus(execution);
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ assertEquals(mockedRequest.getRequestStatus(), "FAILED");
+ }
+}