[jboss-user] [JBoss jBPM] - Re: Bugs in org.jbpm.graph.node.Decision?

ujay68 do-not-reply at jboss.com
Tue Aug 1 04:55:19 EDT 2006


Ronald, thanks for responding. Regardless of whether the "otherwise" transition should be first or last (which is just a matter of convention), the current behavior is wrong. Here's a test case:


  | package test;
  | 
  | import junit.framework.TestCase;
  | import org.jbpm.context.exe.ContextInstance;
  | import org.jbpm.graph.def.ProcessDefinition;
  | import org.jbpm.graph.exe.ProcessInstance;
  | import org.jbpm.graph.exe.Token;
  | 
  | 
  | public class TestDecision extends TestCase {
  | 
  |     public void testDecison0() {
  |         runProcess(0, "end");
  |     }
  | 
  |     public void testDecison1() {
  |         runProcess(1, "s1");
  |     }
  | 
  |     public void testDecison2() {
  |         runProcess(2, "s2");
  |     }
  | 
  |     private void runProcess(int value, String expectedState) {
  | 
  |         ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(getClass().getResourceAsStream("processdefinition.xml"));
  |         ProcessInstance processInstance = new ProcessInstance(processDefinition);
  | 
  |         ContextInstance contextInstance = processInstance.getContextInstance();
  |         contextInstance.setVariable("myVar", new Integer(value));
  | 
  |         Token token = processInstance.getRootToken();
  | 
  |         token.signal();
  |         assertSame(processDefinition.getNode(expectedState), token.getNode());
  | 
  |     }
  | }
  | 

With this processdefinition.xml:

  | <process-definition name='Test Decision'
  |                     xmlns='urn:jbpm.org:jpdl-3.1'
  |                     xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  |                     xsi:schemaLocation='urn:jbpm.org:jpdl-3.1 http://jbpm.org/jpdl-3.1.xsd'>
  | 
  |   <start-state>
  |     <transition to='d'/>
  |   </start-state>
  | 
  |   <decision name='d'>
  |     <transition to='s1'>
  |       <condition>#{myVar == 1}</condition>
  |     </transition>
  |     <transition to='s2'>
  |       <condition>#{myVar == 2}</condition>
  |     </transition>
  |     <transition to='end'/>
  |   </decision>
  | 
  |   <state name='s1'/>
  | 
  |   <state name='s2'/>
  | 
  |   <end-state name='end'/>
  | 
  | </process-definition>
  | 

testDecision0 and testDecision2 fail, the task being in the s1 state in both cases. When I put the otherwise transition at the first position, nothing changes.

Note that if you replace the conditions with an expression, like this, all works fine:

  |   <decision name='d' expression='#{ myVar }'>
  |     <transition name='0' to='end'/>
  |     <transition name='1' to='s1'/>
  |     <transition name='2' to='s2'/>
  |   </decision>
  | 

Regards,

Jay


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962090#3962090

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962090



More information about the jboss-user mailing list