Java Code Examples for org.activiti.engine.task.Task#setDelegationState()

The following examples show how to use org.activiti.engine.task.Task#setDelegationState() . 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 activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * @see <a href="https://activiti.atlassian.net/browse/ACT-1059">https://activiti.atlassian.net/browse/ACT-1059</a>
 */
public void testSetDelegationState() {
  Task task = taskService.newTask();
  task.setOwner("wuzh");
  taskService.saveTask(task);
  taskService.delegateTask(task.getId(), "other");
  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 2
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testResolveTaskWithParametersNullParameters() {
  Task task = taskService.newTask();
  task.setDelegationState(DelegationState.PENDING);
  taskService.saveTask(task);

  String taskId = task.getId();
  taskService.resolveTask(taskId, null);

  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
    historyService.deleteHistoricTaskInstance(taskId);
  }

  // Fetch the task again
  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals(DelegationState.RESOLVED, task.getDelegationState());

  taskService.deleteTask(taskId, true);
}
 
Example 3
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void testResolveTaskWithParametersEmptyParameters() {
  Task task = taskService.newTask();
  task.setDelegationState(DelegationState.PENDING);
  taskService.saveTask(task);

  String taskId = task.getId();
  taskService.resolveTask(taskId, Collections.EMPTY_MAP);

  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
    historyService.deleteHistoricTaskInstance(taskId);
  }

  // Fetch the task again
  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals(DelegationState.RESOLVED, task.getDelegationState());

  taskService.deleteTask(taskId, true);
}
 
Example 4
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * @see <a href="https://activiti.atlassian.net/browse/ACT-1059">https://activiti.atlassian.net/browse/ACT-1059</a>
 */
public void testSetDelegationState() {
  Task task = taskService.newTask();
  task.setOwner("wuzh");
  taskService.saveTask(task);
  taskService.delegateTask(task.getId(), "other");
  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 5
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testResolveTaskWithParametersNullParameters() {
  Task task = taskService.newTask();
  task.setDelegationState(DelegationState.PENDING);
  taskService.saveTask(task);

  String taskId = task.getId();
  taskService.resolveTask(taskId, null);

  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
    historyService.deleteHistoricTaskInstance(taskId);
  }

  // Fetch the task again
  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals(DelegationState.RESOLVED, task.getDelegationState());

  taskService.deleteTask(taskId, true);
}
 
Example 6
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void testResolveTaskWithParametersEmptyParameters() {
  Task task = taskService.newTask();
  task.setDelegationState(DelegationState.PENDING);
  taskService.saveTask(task);

  String taskId = task.getId();
  taskService.resolveTask(taskId, Collections.EMPTY_MAP);

  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
    historyService.deleteHistoricTaskInstance(taskId);
  }

  // Fetch the task again
  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals(DelegationState.RESOLVED, task.getDelegationState());

  taskService.deleteTask(taskId, true);
}
 
Example 7
Source File: TaskBaseResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Populate the task based on the values that are present in the given {@link TaskRequest}.
 */
protected void populateTaskFromRequest(Task task, TaskRequest taskRequest) {
  if (taskRequest.isNameSet()) {
    task.setName(taskRequest.getName());
  }
  if (taskRequest.isAssigneeSet()) {
    task.setAssignee(taskRequest.getAssignee());
  }
  if (taskRequest.isDescriptionSet()) {
    task.setDescription(taskRequest.getDescription());
  }
  if (taskRequest.isDuedateSet()) {
    task.setDueDate(taskRequest.getDueDate());
  }
  if (taskRequest.isOwnerSet()) {
    task.setOwner(taskRequest.getOwner());
  }
  if (taskRequest.isParentTaskIdSet()) {
    task.setParentTaskId(taskRequest.getParentTaskId());
  }
  if (taskRequest.isPrioritySet()) {
    task.setPriority(taskRequest.getPriority());
  }
  if (taskRequest.isCategorySet()) {
    task.setCategory(taskRequest.getCategory());
  }
  if (taskRequest.isTenantIdSet()) {
    task.setTenantId(taskRequest.getTenantId());
  }
  if (taskRequest.isFormKeySet()) {
    task.setFormKey(taskRequest.getFormKey());
  }

  if (taskRequest.isDelegationStateSet()) {
    DelegationState delegationState = getDelegationState(taskRequest.getDelegationState());
    task.setDelegationState(delegationState);
  }
}
 
Example 8
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void testTaskDelegation() {
  Task task = taskService.newTask();
  task.setOwner("johndoe");
  taskService.saveTask(task);
  taskService.delegateTask(task.getId(), "joesmoe");
  String taskId = task.getId();

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

  // try to complete (should fail)
  try {
    taskService.complete(task.getId());
    fail();
  } catch (ActivitiException e) {
  }

  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);
}
 
Example 9
Source File: TaskQueryResourceTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
/**
 * Test querying tasks. GET runtime/tasks
 */
public void testQueryTasksWithPaging() throws Exception {
  try {
    Calendar adhocTaskCreate = Calendar.getInstance();
    adhocTaskCreate.set(Calendar.MILLISECOND, 0);

    processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime());
    List<String> taskIdList = new ArrayList<String>();
    for (int i = 0; i < 10; i++) {
      Task adhocTask = taskService.newTask();
      adhocTask.setAssignee("gonzo");
      adhocTask.setOwner("owner");
      adhocTask.setDelegationState(DelegationState.PENDING);
      adhocTask.setDescription("Description one");
      adhocTask.setName("Name one");
      adhocTask.setDueDate(adhocTaskCreate.getTime());
      adhocTask.setPriority(100);
      taskService.saveTask(adhocTask);
      taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT);
      taskIdList.add(adhocTask.getId());
    }
    Collections.sort(taskIdList);

    // Check filter-less to fetch all tasks
    String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY);
    ObjectNode requestNode = objectMapper.createObjectNode();
    String[] taskIds = new String[] { taskIdList.get(0), taskIdList.get(1), taskIdList.get(2) };
    assertResultsPresentInPostDataResponse(url + "?size=3&sort=id&order=asc", requestNode, taskIds);

    taskIds = new String[] { taskIdList.get(4), taskIdList.get(5), taskIdList.get(6), taskIdList.get(7) };
    assertResultsPresentInPostDataResponse(url + "?start=4&size=4&sort=id&order=asc", requestNode, taskIds);

    taskIds = new String[] { taskIdList.get(8), taskIdList.get(9) };
    assertResultsPresentInPostDataResponse(url + "?start=8&size=10&sort=id&order=asc", requestNode, taskIds);

  } finally {
    // Clean adhoc-tasks even if test fails
    List<Task> tasks = taskService.createTaskQuery().list();
    for (Task task : tasks) {
      if (task.getExecutionId() == null) {
        taskService.deleteTask(task.getId(), true);
      }
    }
  }
}
 
Example 10
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void testTaskDelegation() {
  Task task = taskService.newTask();
  task.setOwner("johndoe");
  taskService.saveTask(task);
  taskService.delegateTask(task.getId(), "joesmoe");
  String taskId = task.getId();

  task = taskService.createTaskQuery().taskId(taskId).singleResult();
  assertEquals("johndoe", task.getOwner());
  assertEquals("joesmoe", task.getAssignee());
  assertEquals(DelegationState.PENDING, task.getDelegationState());
  
  // try to complete (should fail)
  try {
  	taskService.complete(task.getId());
  	fail();
  } catch (ActivitiException e) {}

  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);
}