[jboss-user] [JBoss jBPM] - Re: Why my condtion doesn't get evaluated?
kukeltje
do-not-reply at jboss.com
Tue Jun 26 07:45:32 EDT 2007
oh and btw, this one does as well. (no expression)
| 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>#{customer.priority == 'LOW'}</condition>" +
| " </transition>" +
| " <transition to='m'>" +
| " <condition>#{customer.priority == 'MEDIUM'}</condition>" +
| " </transition>" +
| " <transition to='h'>" +
| " <condition>#{customer.priority == 'HIGH'}</condition>" +
| " </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()); }
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057675#4057675
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057675
More information about the jboss-user
mailing list