07-18-2012 02:59 PM
07-25-2012 09:59 AM
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples"
xmlns:tns="Examples"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<error id="myError" errorCode="123" />
<process id="EventSubprocessErrorStartTest" isExecutable="true">
<startEvent id="startEvent01">
<outgoing>toReview</outgoing>
</startEvent>
<userTask id="reviewUserTask" name="Review">
<incoming>toReview</incoming>
<outgoing>toOkGtw</outgoing>
</userTask>
<sequenceFlow id="toReview" sourceRef="startEvent01" targetRef="reviewUserTask" />
<sequenceFlow id="toOkGtw" sourceRef="reviewUserTask" targetRef="okGtw" />
<exclusiveGateway gatewayDirection="Diverging" id="okGtw" name="ok?">
<incoming>toOkGtw</incoming>
<outgoing>toEmptyEnd</outgoing>
<outgoing>toErrorEnd</outgoing>
</exclusiveGateway>
<sequenceFlow id="toEmptyEnd" sourceRef="okGtw" targetRef="emptyEnd">
<conditionExpression id="exp01" xsi:type="tFormalExpression">${condition=='A'}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="toErrorEnd" sourceRef="okGtw" targetRef="errorEnd">
<conditionExpression id="exp02" xsi:type="tFormalExpression">${condition=='R'}</conditionExpression>
</sequenceFlow>
<endEvent id="emptyEnd" name="emptyEnd">
<incoming>toEmptyEnd</incoming>
</endEvent>
<endEvent id="errorEnd" name="err">
<incoming>toErrorEnd</incoming>
<errorEventDefinition errorRef="myError" />
</endEvent>
<subProcess id="eventSubProcess" triggeredByEvent="true">
<startEvent id="catchError">
<errorEventDefinition errorRef="myError" />
</startEvent>
<sequenceFlow id="flow2" sourceRef="catchError" targetRef="taskAfterErrorCatch" />
<userTask id="taskAfterErrorCatch" name="Provide additional data" />
</subProcess>
</process>
</definitions>
07-25-2012 10:15 AM
07-25-2012 10:46 AM
07-25-2012 10:56 AM
@Test
public void testEventSubprocessoErrorStart() {
org.activiti.engine.repository.Deployment deployment =
repositoryService.createDeployment()
.addClasspathResource("org/activiti/examples/bpmn/subprocess/EventSubprocess.bpmn20.xml")
.deploy();
ProcessInstance pi = runtimeService.startProcessInstanceByKey("EventSubprocessErrorStartTest");
//should return only one task called 'Review'
List<Task> tasks = taskService.createTaskQuery()
.processInstanceId(pi.getId()).list();
assertEquals(1, tasks.size());
Task reviewTask = tasks.get(0);
assertEquals("Review", reviewTask.getName());
//
//creating the variable to evaluate the expression that will lead to an error end event
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("condition", "R");
//complete the 'Review' task with the variables
taskService.complete(reviewTask.getId(), vars);
//should return only one task (event subprocess 'Report' task) bot no one will be returned
tasks = taskService.createTaskQuery().list();
assertEquals(1, tasks.size());
// Clean up
repositoryService.deleteDeployment(deployment.getId(), true);
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples"
xmlns:tns="Examples"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<error id="myError" errorCode="123" />
<process id="EventSubprocessErrorStartTest" isExecutable="true">
<startEvent id="startEvent01">
<outgoing>toReview</outgoing>
</startEvent>
<userTask id="reviewUserTask" name="Review">
<incoming>toReview</incoming>
<outgoing>toOkGtw</outgoing>
</userTask>
<exclusiveGateway gatewayDirection="Diverging" id="okGtw" name="ok?">
<incoming>toOkGtw</incoming>
<outgoing>toEmptyEnd</outgoing>
<outgoing>toErrorEnd</outgoing>
</exclusiveGateway>
<endEvent id="emptyEnd" name="emptyEnd">
<incoming>toEmptyEnd</incoming>
</endEvent>
<endEvent id="errorEnd" name="err">
<incoming>toErrorEnd</incoming>
<errorEventDefinition errorRef="myError" />
</endEvent>
<sequenceFlow id="toReview" sourceRef="startEvent01" targetRef="reviewUserTask" />
<sequenceFlow id="toOkGtw" sourceRef="reviewUserTask" targetRef="okGtw" />
<sequenceFlow id="toEmptyEnd" sourceRef="okGtw" targetRef="emptyEnd">
<conditionExpression id="exp01" xsi:type="tFormalExpression">${condition=='A'}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="toErrorEnd" sourceRef="okGtw" targetRef="errorEnd">
<conditionExpression id="exp02" xsi:type="tFormalExpression">${condition=='R'}</conditionExpression>
</sequenceFlow>
<subProcess id="eventSubProcess" triggeredByEvent="true">
<startEvent id="errStartEvent" name="err">
<outgoing>toReport</outgoing>
<errorEventDefinition errorRef="myError"/>
</startEvent>
<userTask id="reportUserTask" name="Report">
<incoming>toReport</incoming>
<outgoing>toSubEmptyEnd</outgoing>
</userTask>
<endEvent id="subEmptyEnd">
<incoming>toSubEmptyEnd</incoming>
</endEvent>
<sequenceFlow id="toReport" sourceRef="errStartEvent"
targetRef="reportUserTask" />
<sequenceFlow id="toSubEmptyEnd" sourceRef="reportUserTask"
targetRef="subEmptyEnd" />
</subProcess>
</process>
</definitions>
07-25-2012 11:25 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.