Hi
I created a diagram which contains a start event - userTask (two userTasks) - end event .
In the second userTask i have a boolean form .
I want to if i put “true” in the test unit , process will be finished .
And if i put “false” in the test unit , process will be returned to first userTask.
this is my bpmn file :
testProcess.bpmn (3.7 KB)
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="Definitions_1e0hqjp" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
<collaboration id="Collaboration_1b9qb7x">
<participant id="Participant_08joys0" processRef="BudgetDeclaration" />
</collaboration>
<process id="BudgetDeclaration" name="BudgetDeclaration" isExecutable="true">
<startEvent id="start" name="شروع">
<extensionElements>
<camunda:formData>
<camunda:formField id="prc_instance_id" label="prc_instance_id" type="long" />
</camunda:formData>
</extensionElements>
</startEvent>
<userTask id="task1" name="task1" />
<userTask id="task2" name="task2">
<extensionElements>
<camunda:formData>
<camunda:formField id="prc_ok" label="بررسی اطلاعات" type="boolean">
<camunda:properties>
<camunda:property id="true" value="تایید" />
<camunda:property id="false" value="نیاز به اصلاح" />
</camunda:properties>
</camunda:formField>
</camunda:formData>
</extensionElements>
</userTask>
<exclusiveGateway id="ExclusiveGateway_0guleu7" />
<endEvent id="end" name="پایان" />
<sequenceFlow id="SequenceFlow_17u7y0t" name="نیاز به اصلاح" sourceRef="ExclusiveGateway_0guleu7" targetRef="task1">
<conditionExpression xsi:type="tFormalExpression">${prc_ok==false}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="SequenceFlow_1qkgdn3" name="تایید" sourceRef="ExclusiveGateway_0guleu7" targetRef="end">
<conditionExpression xsi:type="tFormalExpression">${prc_ok==true}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="SequenceFlow_06cn4hr" sourceRef="task2" targetRef="ExclusiveGateway_0guleu7" />
<sequenceFlow id="SequenceFlow_1v3uoyt" sourceRef="task1" targetRef="task2" />
<sequenceFlow id="SequenceFlow_1gmutkt" sourceRef="start" targetRef="task1" />
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_BudgetDeclaration">
<bpmndi:BPMNPlane id="BPMNPlane_BudgetDeclaration" bpmnElement="Collaboration_1b9qb7x">
<bpmndi:BPMNShape id="Participant_08joys0_di" bpmnElement="Participant_08joys0" bioc:fill="#D58989">
<omgdc:Bounds x="116" y="3" width="600" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_start" bpmnElement="start">
<omgdc:Bounds x="174" y="110" width="36" height="36" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="181" y="146" width="23" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_task1" bpmnElement="task1">
<omgdc:Bounds x="260" y="88" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_task2" bpmnElement="task2">
<omgdc:Bounds x="400" y="89" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_ExclusiveGateway_0guleu7" bpmnElement="ExclusiveGateway_0guleu7" isMarkerVisible="true">
<omgdc:Bounds x="555" y="108" width="40" height="40" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_end" bpmnElement="end">
<omgdc:Bounds x="660" y="110" width="36" height="36" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="670" y="146" width="17" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_17u7y0t" bpmnElement="SequenceFlow_17u7y0t">
<omgdi:waypoint x="574" y="147" />
<omgdi:waypoint x="574" y="214" />
<omgdi:waypoint x="309" y="214" />
<omgdi:waypoint x="310" y="168" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="519" y="182" width="52" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1qkgdn3" bpmnElement="SequenceFlow_1qkgdn3">
<omgdi:waypoint x="595" y="128" />
<omgdi:waypoint x="660" y="128" />
<bpmndi:BPMNLabel>
<omgdc:Bounds x="627" y="114" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_06cn4hr" bpmnElement="SequenceFlow_06cn4hr">
<omgdi:waypoint x="500" y="127" />
<omgdi:waypoint x="556" y="127" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1v3uoyt" bpmnElement="SequenceFlow_1v3uoyt">
<omgdi:waypoint x="360" y="128" />
<omgdi:waypoint x="400" y="129" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1gmutkt" bpmnElement="SequenceFlow_1gmutkt">
<omgdi:waypoint x="210" y="128" />
<omgdi:waypoint x="260" y="128" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
and this is my test class file :
FinalTest.txt (1.2 KB)
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import org.junit.Rule;
import org.junit.Test;
public class FinalTest {
@Rule
public ProcessEngineRule rule = new ProcessEngineRule();
@Test
@Deployment(resources = { "BudgetDeclaration.bpmn" })
public void executeProcess() {
ProcessInstance processInstance = runtimeService().startProcessInstanceByKey("BudgetDeclaration");
assertThat(processInstance).isActive();
assertThat(processInstanceQuery().count()).isEqualTo(1);
assertThat(processInstance).task("task1");
assertThat(task(processInstance)).isNotNull();
complete(task(processInstance));
assertThat(processInstance).task("task2");
assertThat(task(processInstance)).isNotNull();
complete(task(processInstance));
assertThat(processInstance).isEnded();
}
}