package org.jbpm.examples.testReassign; import org.jbpm.test.JbpmTestCase; import org.jbpm.api.ProcessInstance; import org.jbpm.api.history.HistoryProcessInstance; import org.jbpm.api.history.HistoryActivityInstance; import org.jbpm.api.task.Task; import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl; import java.util.List; import java.util.Set; /** * Created by IntelliJ IDEA. * User: svemuri * Date: Jul 3, 2009 * Time: 3:01:56 AM */ public class ReassignTest extends JbpmTestCase { long deploymentDbid; protected void setUp() throws Exception { super.setUp(); deploymentDbid = repositoryService.createDeployment() .addResourceFromClasspath("org/jbpm/examples/testReassign/ReassignTest.jpdl.xml") .deploy(); } protected void tearDown() throws Exception { repositoryService.deleteDeploymentCascade(deploymentDbid); super.tearDown(); } public void test_whether_reassign_history_works() { ProcessInstance pi = executionService.startProcessInstanceByKey("ReassignTest"); List tasks = taskService.findPersonalTasks("shekharv"); assertTrue(tasks.size() == 1); long taskDbId = tasks.get(0).getDbid(); taskService.assignTask(taskDbId, "johndoe"); List tasksAfterReassignment = taskService.findPersonalTasks("shekharv"); assertTrue("shekharv should not have any tasks.",tasksAfterReassignment.size() == 0); List tasksForNewAssignee = taskService.findPersonalTasks("johndoe"); assertTrue("johndoe should have 1 task.", tasksForNewAssignee.size() == 1); assertEquals("johndoe", taskService.getTask(taskDbId).getAssignee()); taskService.completeTask(taskDbId, "end1"); List aiHistory = historyService .createHistoryActivityInstanceQuery() .executionId(pi.getId()).list(); HistoryTaskInstanceImpl hai = (HistoryTaskInstanceImpl) aiHistory.get(0); assertEquals("John Doe completed the Task, but someone else got the credit","johndoe", hai.getAssignee()); } }