[jboss-user] [jBPM Users] - Re: [JBPM4 Error]Getting error while 2 tasks are created on

nilspreusker do-not-reply at jboss.com
Wed Oct 28 11:13:34 EDT 2009


Sushant, try this:

JUnit Test Case:

package org.jbpm.examples.task.multiple1;
  | 
  | import java.util.List;
  | 
  | import org.jbpm.api.ProcessInstance;
  | import org.jbpm.api.task.Task;
  | import org.jbpm.test.JbpmTestCase;
  | 
  | public class MultipleTasksTest1 extends JbpmTestCase {
  | 
  | 	String deploymentId;
  | 
  | 	protected void setUp() throws Exception {
  | 		super.setUp();
  | 
  | 		// deploy the process definition
  | 		deploymentId = repositoryService.createDeployment()
  | 				.addResourceFromClasspath(
  | 						"org/jbpm/examples/task/multiple1/process.jpdl.xml")
  | 				.deploy();
  | 
  | 		// create actor
  | 		identityService.createUser("johndoe", "John", "Doe", "john at doe");
  | 	}
  | 
  | 	protected void tearDown() throws Exception {
  | 
  | 	}
  | 
  | 	public void testMultipleTasks() {
  | 		ProcessInstance processInstance = executionService
  | 				.startProcessInstanceByKey("MultipleTasks");
  | 
  | 		String processInstanceId = processInstance.getId();
  | 
  | 		assertTrue(executionService.createProcessInstanceQuery()
  | 				.processInstanceId(processInstanceId).uniqueResult().isActive(
  | 						"task1"));
  | 
  | 		List<Task> taskList = taskService.findPersonalTasks("johndoe");
  | 		assertEquals(1, taskList.size());
  | 		Task task = taskList.get(0);
  | 		assertEquals("task1", task.getName());
  | 		assertEquals("johndoe", task.getAssignee());
  | 
  | 		// submit the task
  | 		taskService.completeTask(task.getId(), "to task2");
  | 
  | 		// verify that the next task is active and has been assigned to
  | 		// 'johndoe'
  | 		taskList = taskService.findPersonalTasks("johndoe");
  | 		assertEquals(1, taskList.size());
  | 		task = taskList.get(0);
  | 		assertEquals("task2", task.getName());
  | 		assertEquals("johndoe", task.getAssignee());
  | 
  | 		// submit the task
  | 		taskService.completeTask(task.getId(), "to task3");
  | 
  | 		// verify that the next task is active and has been assigned to
  | 		// 'johndoe'
  | 		taskList = taskService.findPersonalTasks("johndoe");
  | 		assertEquals(1, taskList.size());
  | 		task = taskList.get(0);
  | 		assertEquals("task3", task.getName());
  | 		assertEquals("johndoe", task.getAssignee());
  | 	}
  | 
  | }
  | 

Process Definition (process.jpdl.xml):
<?xml version="1.0" encoding="UTF-8"?>
  | 
  | <process name="MultipleTasks" xmlns="http://jbpm.org/4.0/jpdl">
  |    <start g="38,16,48,48" name="start1">
  |       <transition g="-48,-19" name="to task1" to="task1"/>
  |    </start>
  |    <task assignee="johndoe" g="16,96,92,52" name="task1">
  |       <transition g="-48,-19" name="to task2" to="task2"/>
  |    </task>
  |    <task assignee="johndoe" g="16,180,92,52" name="task2">
  |       <transition name="to task3" to="task3" g="-48,-19"/>
  |    </task>
  |    <task assignee="johndoe" name="task3" g="16,264,92,52"/>
  | 
  | </process>

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

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



More information about the jboss-user mailing list