<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="decisiontest">
<start-state name="start">
<transition name="" to="task1"></transition>
</start-state>
<end-state name="end1"></end-state>
<task-node name="task1">
<task></task>
<transition name="" to="decision1"></transition>
</task-node>
<decision name="decision1" expression="#{role=='tr1'?'tr1':'tr2'}">
<transition name="tr1" to="task2"></transition>
<transition name="tr2" to="task3"></transition>
</decision>
<task-node name="task2">
<task></task>
<transition name="" to="end1"></transition>
</task-node>
<task-node name="task3">
<task></task>
<transition name="" to="end1"></transition>
</task-node>
</process-definition>
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import junit.framework.TestCase;
public class DecisionTest extends TestCase {
ProcessDefinition procdef;
ProcessInstance procInstance;
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
super.setUp();
procdef=ProcessDefinition.parseXmlResource("decision/decisiontest/processdefinition.xml");
procInstance=new ProcessInstance(procdef);
}
@Override
protected void tearDown() throws Exception {
// TODO Auto-generated method stub
super.tearDown();
}
public void testProcess(){
assertEquals("start", procInstance.getRootToken().getNode().getName());
procInstance.signal();
assertEquals("task1",procInstance.getRootToken().getNode().getName());
procInstance.getContextInstance().setVariable("role", "tr2");
procInstance.signal();
assertEquals("task2",procInstance.getRootToken().getNode().getName());
assertEquals("tr1", (String)procInstance.getContextInstance().getVariable("role"));
procInstance.signal();
assertTrue(procInstance.hasEnded());
}
}