This content has been marked as final.
Show 5 replies
-
1. Re: Re: task in start state
kukeltje Jan 16, 2008 5:11 AM (in response to debnathm)please create a unit test that demonstrates the problem
-
2. Re: task in start state
debnathm Jan 16, 2008 6:02 AM (in response to debnathm)Hi
Here is the JUnit test case. Please check if the APIs have
been used correctly
Thanks,
Debnathpackage org.jbpm.tutorial.startstatetask; import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ProcessInstance; import org.jbpm.graph.exe.Token; import org.jbpm.taskmgmt.exe.TaskMgmtInstance; import junit.framework.TestCase; public class StartStateTask extends TestCase { public void testStartStateTask() { ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition> " + " <start-state name='start'>" + " <task name='StartStateTask'> " + " <controller> " + " <variable access='read,write,required' name='variable1' mapped-name='Var1'></variable> " + " </controller> " + " </task> " + " <transition to='task-node1' name='to_task_node1'></transition>" + " </start-state> " + " <task-node name='task-node1'> " + " <task name='SecondTask'>" + " <controller> " + " <variable access='read,write,required' name='variable2' mapped-name='Var2'></variable>" + " </controller> " + " </task> " + "<transition to='end' name='to_end'></transition>" + "</task-node>" + "<end-state name='end'></end-state>" + "</process-definition>"); ProcessInstance processInstance = new ProcessInstance(processDefinition); Token token = processInstance.getRootToken(); TaskMgmtInstance taskmgmtInstance = processInstance.getTaskMgmtInstance(); assertEquals(true, taskmgmtInstance.hasUnfinishedTasks(token)); }
} -
3. Re: Re: task in start state
kukeltje Jan 16, 2008 1:13 PM (in response to debnathm)jbpm contains many unittests. If you look at the test (code below for convenience) you'll quickly see the difference
package org.jbpm.taskmgmt.exe; import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ProcessInstance; import junit.framework.TestCase; public class StartTaskTest extends TestCase { public void testStartTaskPresent() { ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition>" + " <start-state>" + " <task name='lets get it started' />" + " <transition to='going steady' />" + " </start-state>" + " <state name='going steady' />" + "</process-definition>" ); ProcessInstance processInstance = new ProcessInstance(processDefinition); TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance(); assertNotNull(taskInstance); assertEquals("lets get it started", taskInstance.getName()); taskInstance.end(); assertEquals("going steady", processInstance.getRootToken().getNode().getName()); } public void testStartTaskAbsent() { ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition>" + " <start-state>" + " <transition to='going steady' />" + " </start-state>" + " <state name='going steady' />" + "</process-definition>" ); ProcessInstance processInstance = new ProcessInstance(processDefinition); TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance(); assertNull(taskInstance); } }
-
4. Re: task in start state
debnathm Jan 23, 2008 1:53 AM (in response to debnathm)It worked. Thanks,
Debnath -
5. Re: Re: task in start state
kukeltje Jan 23, 2008 4:11 AM (in response to debnathm)you see... there is so much documentation and api examples....