[jboss-user] [JBoss jBPM] - Re: Why my condtion doesn't get evaluated?

kukeltje do-not-reply at jboss.com
Tue Jun 26 07:38:11 EDT 2007


Unittests are great to reproduce issues instead of snippets (should be well known to.... ahhh never mind). The following unittest runs fine in the cvs head of 21-06-2007




package org.jbpm.jpdl.el;
  | 
  | import junit.framework.TestCase;
  | 
  | import org.jbpm.JbpmException;
  | import org.jbpm.graph.def.ProcessDefinition;
  | import org.jbpm.graph.exe.ProcessInstance;
  | 
  | public class DecisionExpressionTest extends TestCase {
  |   
  |   public static class Customer {
  |     String priority;
  |     int number;
  |     public Customer(String priority) {
  |       this.priority = priority;
  |     }
  |     public Customer(int number) {
  |       this.number = number;
  |     }
  |     public String getPriority() {
  |       return priority;
  |     }
  |     public int getNumber() {
  |       return number;
  |     }
  |   }
  |   
  |   public ProcessDefinition createCustomerPriorityProcess() {
  | 	    return ProcessDefinition.parseXmlString(
  | 	      "<process-definition>" +
  | 	      "  <start-state>" +
  | 	      "    <transition to='d'/>" +
  | 	      "  </start-state>" +
  | 	      "  <decision name='d'>" +
  | 	      "    <transition to='l' >" +
  | 	      "      <condition expression='#{customer.priority == \"LOW\"}' />" +
  | 	      "    </transition>" +	      
  | 	      "    <transition to='m'>" +
  | 	      "      <condition expression='#{customer.priority == \"MEDIUM\"}' />" +
  | 	      "    </transition>" +
  | 	      "    <transition to='h'>" +
  | 	      "      <condition expression='#{customer.priority == \"HIGH\"}' />" +
  | 	      "    </transition>" +
  | 	      "  </decision>" +
  | 	      "  <state name='l' />" +
  | 	      "  <state name='m' />" +
  | 	      "  <state name='h' />" +
  | 	      "</process-definition>"
  | 	    );
  | 	}
  | 
  |   public void testCustomerPriorityLow() {
  |     ProcessDefinition processDefinition = createCustomerPriorityProcess();
  |     ProcessInstance processInstance = new ProcessInstance(processDefinition);
  |     processInstance.getContextInstance().setVariable("customer", new Customer("LOW"));
  |     processInstance.signal();
  |     assertEquals("l", processInstance.getRootToken().getNode().getName());
  | 
  |   }
  | 
  |   public void testCustomerPriorityMedium() {
  |     ProcessDefinition processDefinition = createCustomerPriorityProcess();
  |     ProcessInstance processInstance = new ProcessInstance(processDefinition);
  |     processInstance.getContextInstance().setVariable("customer", new Customer("MEDIUM"));
  |     processInstance.signal();
  |     assertEquals("m", processInstance.getRootToken().getNode().getName());
  |   }
  |   
  |   public void testCustomerPriorityHigh() {
  | 	    ProcessDefinition processDefinition = createCustomerPriorityProcess();
  | 	    ProcessInstance processInstance = new ProcessInstance(processDefinition);
  | 	    processInstance.getContextInstance().setVariable("customer", new Customer("HIGH"));
  | 	    processInstance.signal();
  | 	    assertEquals("h", processInstance.getRootToken().getNode().getName());
  | 	  }
  | 
  |   public void testCustomerPriorityUndefined() {
  |     ProcessDefinition processDefinition = createCustomerPriorityProcess();
  |     ProcessInstance processInstance = new ProcessInstance(processDefinition);
  |     processInstance.getContextInstance().setVariable("customer", new Customer("UNDEFINED"));
  |     processInstance.signal();
  |     // 'Default' transition
  |     assertEquals("l", processInstance.getRootToken().getNode().getName());
  |   }
  | 
  |   public void testCustomerPriorityNull() {
  |     ProcessDefinition processDefinition = createCustomerPriorityProcess();
  |     ProcessInstance processInstance = new ProcessInstance(processDefinition);
  |     processInstance.getContextInstance().setVariable("customer", new Customer(null));
  |     processInstance.signal();
  |     // 'Default' transition
  |     assertEquals("l", processInstance.getRootToken().getNode().getName());  }
  | }
  | 

So find the differences

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

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



More information about the jboss-user mailing list