Java Code Examples for org.camunda.bpm.engine.task.Task#delegate()

The following examples show how to use org.camunda.bpm.engine.task.Task#delegate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = TWO_TASKS_PROCESS)
@Test
public void testResolveWithParametersTask() {
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoTasksProcess");

  // Fetch first task
  Task task = taskService.createTaskQuery().singleResult();
  assertEquals("First task", task.getName());

  task.delegate("johndoe");

  // Resolve first task
  Map<String, Object> taskParams = new HashMap<>();
  taskParams.put("myParam", "myValue");
  taskService.resolveTask(task.getId(), taskParams);

  // Verify that task is resolved
  task = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED).singleResult();
  assertEquals("First task", task.getName());

  // Verify task parameters set on execution
  Map<String, Object> variables = runtimeService.getVariables(processInstance.getId());
  assertEquals(1, variables.size());
  assertEquals("myValue", variables.get("myParam"));
}
 
Example 2
Source File: TaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * @see http://jira.codehaus.org/browse/ACT-1059
 */
@Test
public void testSetDelegationState() {
  Task task = taskService.newTask();
  task.setOwner("wuzh");
  task.delegate("other");
  taskService.saveTask(task);
  String taskId = task.getId();

  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals("wuzh", task.getOwner());
  assertEquals("other", task.getAssignee());
  assertEquals(DelegationState.PENDING, task.getDelegationState());

  task.setDelegationState(DelegationState.RESOLVED);
  taskService.saveTask(task);

  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals("wuzh", task.getOwner());
  assertEquals("other", task.getAssignee());
  assertEquals(DelegationState.RESOLVED, task.getDelegationState());

  taskService.deleteTask(taskId, true);
}
 
Example 3
Source File: TaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskDelegation() {
  Task task = taskService.newTask();
  task.setOwner("johndoe");
  task.delegate("joesmoe");
  taskService.saveTask(task);
  String taskId = task.getId();

  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals("johndoe", task.getOwner());
  assertEquals("joesmoe", task.getAssignee());
  assertEquals(DelegationState.PENDING, task.getDelegationState());

  taskService.resolveTask(taskId);
  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals("johndoe", task.getOwner());
  assertEquals("johndoe", task.getAssignee());
  assertEquals(DelegationState.RESOLVED, task.getDelegationState());

  task.setAssignee(null);
  task.setDelegationState(null);
  taskService.saveTask(task);
  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals("johndoe", task.getOwner());
  assertNull(task.getAssignee());
  assertNull(task.getDelegationState());

  task.setAssignee("jackblack");
  task.setDelegationState(DelegationState.RESOLVED);
  taskService.saveTask(task);
  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals("johndoe", task.getOwner());
  assertEquals("jackblack", task.getAssignee());
  assertEquals(DelegationState.RESOLVED, task.getDelegationState());

  // Finally, delete task
  taskService.deleteTask(taskId, true);
}