[jbpm-commits] JBoss JBPM SVN: r6139 - in jbpm4/trunk/modules/examples/src/test: java/org/jbpm/examples/bpmn/sequenceflow and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Jan 27 07:50:20 EST 2010


Author: jbarrez
Date: 2010-01-27 07:50:20 -0500 (Wed, 27 Jan 2010)
New Revision: 6139

Added:
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/sequenceflow/
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/sequenceflow/ConditionalSequenceflowTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/sequenceflow/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/sequenceflow/conditional_sequence_flow.bpmn.xml
Log:
Examples conditional sequence flow

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/sequenceflow/ConditionalSequenceflowTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/sequenceflow/ConditionalSequenceflowTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/sequenceflow/ConditionalSequenceflowTest.java	2010-01-27 12:50:20 UTC (rev 6139)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.bpmn.sequenceflow;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.TaskQuery;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Joram Barrez
+ */
+public class ConditionalSequenceflowTest extends JbpmTestCase {
+  
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    NewDeployment deployment = repositoryService.createDeployment();
+    deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/sequenceflow/conditional_sequence_flow.bpmn.xml");
+    registerDeployment(deployment.deploy());
+  }
+  
+  public void testBothSequenceflowTaken() {
+    Map<String, Object> vars = new HashMap<String, Object>();
+    vars.put("var", 250);
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("conditionalSequenceFlow", vars);
+    
+    TaskQuery taskQuery = taskService.createTaskQuery()
+                                      .processInstanceId(processInstance.getId())
+                                      .orderAsc(TaskQuery.PROPERTY_NAME);
+    Task task = taskQuery.uniqueResult();
+    assertEquals("First task", task.getName());
+    taskService.completeTask(task.getId());
+    
+    List<Task> tasks = taskQuery.list();
+    assertEquals(2, tasks.size());
+    assertEquals("Second task", tasks.get(0).getName());
+    assertEquals("Third task", tasks.get(1).getName());
+  }
+  
+  public void testOnlyOneSequenceFlow() {
+    Map<String, Object> vars = new HashMap<String, Object>();
+    vars.put("var", 25);
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("conditionalSequenceFlow", vars);
+    
+    TaskQuery taskQuery = taskService.createTaskQuery()
+                                      .processInstanceId(processInstance.getId());
+    Task task = taskQuery.uniqueResult();
+    assertEquals("First task", task.getName());
+    taskService.completeTask(task.getId());
+    
+    task = taskQuery.uniqueResult();
+    assertEquals("Second task", task.getName());
+  }
+  
+  public void testDefaultSequenceFlow() {
+    Map<String, Object> vars = new HashMap<String, Object>();
+    vars.put("var", 2);
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("conditionalSequenceFlow", vars);
+    
+    TaskQuery taskQuery = taskService.createTaskQuery()
+                                      .processInstanceId(processInstance.getId());
+    Task task = taskQuery.uniqueResult();
+    assertEquals("First task", task.getName());
+    taskService.completeTask(task.getId());
+    
+    task = taskQuery.uniqueResult();
+    assertNotNull(task);
+    assertEquals("Fourth task", task.getName());
+  }
+  
+
+}

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/sequenceflow/conditional_sequence_flow.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/sequenceflow/conditional_sequence_flow.bpmn.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/sequenceflow/conditional_sequence_flow.bpmn.xml	2010-01-27 12:50:20 UTC (rev 6139)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions id="vacationRequest"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+	xmlns="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
+	expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://jbpm.org/example/bpmn2/conditional_sequence_flow"
+	xmlns:jbpm="http://jbpm.org/bpmn2">
+
+	<process id="conditionalSequenceFlow">
+
+		<startEvent id="start" />
+
+		<sequenceFlow id="flow1" sourceRef="start" targetRef="task1" />
+
+		<userTask id="task1" default="flow4" name="First task" />
+
+	  <sequenceFlow id='flow2' sourceRef='task1' targetRef='task2' >" +
+      <conditionExpression xsi:type='tFormalExpression'>${var &gt; 10}</conditionExpression>
+    </sequenceFlow>
+    
+    <sequenceFlow id='flow3' sourceRef='task1' targetRef='task3' >" +
+      <conditionExpression xsi:type='tFormalExpression'>${var &gt; 100}</conditionExpression>
+    </sequenceFlow>
+    
+    <sequenceFlow id="flow4" sourceRef="task1" targetRef="task4" />
+    
+    <userTask id="task2" name="Second task" />
+    
+    <sequenceFlow id="flow5" sourceRef="task2" targetRef="theEnd" />
+    
+    <userTask id="task3" name="Third task" />
+    
+    <sequenceFlow id="flow5" sourceRef="task2" targetRef="theEnd" />
+    
+    <userTask id="task4" name="Fourth task" />
+    
+    <sequenceFlow id="flow5" sourceRef="task2" targetRef="theEnd" />
+
+		<endEvent id="theEnd" name="End" />
+
+
+	</process>
+</definitions>



More information about the jbpm-commits mailing list