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

The following examples show how to use org.camunda.bpm.engine.task.Task#setOwner() . 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: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testExtendingTaskQueryWithAssigneeNotIn() {
  // given
  Task task = taskService.newTask("assigneeTask");
  task.setName("Task 5");
  task.setOwner(testUser.getId());
  taskService.saveTask(task);
  taskService.setAssignee(task.getId(), "john");

  // then
  TaskQuery query = taskService.createTaskQuery().taskAssigneeNotIn("kermit");
  saveQuery(query);
  List<Task> origQueryTasks = filterService.list(filter.getId());
  List<Task> selfExtendQueryTasks = filterService.list(filter.getId(), query);

  TaskQuery extendingQuery = taskService.createTaskQuery();
  extendingQuery.taskAssigneeNotIn("john", "kermit");
  List<Task> extendingQueryTasks = filterService.list(filter.getId(), extendingQuery);

  // then
  assertEquals(1, origQueryTasks.size());
  assertEquals(1, selfExtendQueryTasks.size());
  assertEquals(0, extendingQueryTasks.size());
}
 
Example 2
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testExtendingTaskQueryWithAssigneeIn() {
  // given
  Task task = taskService.newTask("assigneeTask");
  task.setName("Task 4");
  task.setOwner(testUser.getId());
  taskService.saveTask(task);
  taskService.setAssignee(task.getId(), "john");

  // then
  TaskQuery query = taskService.createTaskQuery().taskAssigneeIn("john");
  saveQuery(query);
  List<Task> origQueryTasks = filterService.list(filter.getId());
  List<Task> selfExtendQueryTasks = filterService.list(filter.getId(), query);

  TaskQuery extendingQuery = taskService.createTaskQuery();
  extendingQuery.taskAssigneeIn("john", "kermit");
  List<Task> extendingQueryTasks = filterService.list(filter.getId(), extendingQuery);

  // then
  assertEquals(1, origQueryTasks.size());
  assertEquals(1, selfExtendQueryTasks.size());
  assertEquals(2, extendingQueryTasks.size());
}
 
Example 3
Source File: TaskAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testAssignSameAssigneeAndOwnerToTask() {

    // given
    createGrantAuthorization(Resources.TASK, Authorization.ANY, userId, Permissions.ALL);

    // when
    Task newTask = taskService.newTask();
    newTask.setAssignee("Horst");
    newTask.setOwner("Horst");

    // then
    try {
      taskService.saveTask(newTask);
    } catch (Exception e) {
      fail("Setting same assignee and owner to user should not fail!");
    }

    taskService.deleteTask(newTask.getId(), true);
  }
 
Example 4
Source File: TaskListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateTaskListenerOnPropertyUpdateOnlyOnce() {
  // given
  createAndDeployModelWithTaskEventsRecorderOnUserTask(TaskListener.EVENTNAME_UPDATE);
  runtimeService.startProcessInstanceByKey("process");
  Task task = taskService.createTaskQuery().singleResult();

  // when
  task.setAssignee("test");
  task.setDueDate(new Date());
  task.setOwner("test");
  taskService.saveTask(task);

  // then
  assertEquals(1, RecorderTaskListener.getEventCount(TaskListener.EVENTNAME_UPDATE));
}
 
Example 5
Source File: TaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskOwner() {
  Task task = taskService.newTask();
  task.setOwner("johndoe");
  taskService.saveTask(task);

  // Fetch the task again and update
  task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
  assertEquals("johndoe", task.getOwner());

  task.setOwner("joesmoe");
  taskService.saveTask(task);

  task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
  assertEquals("joesmoe", task.getOwner());

  // Finally, delete task
  taskService.deleteTask(task.getId(), true);
}
 
Example 6
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 7
Source File: TaskDto.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void updateTask(Task task) {
  task.setName(getName());
  task.setDescription(getDescription());
  task.setPriority(getPriority());
  task.setAssignee(getAssignee());
  task.setOwner(getOwner());

  DelegationState state = null;
  if (getDelegationState() != null) {
    DelegationStateConverter converter = new DelegationStateConverter();
    state = converter.convertQueryParameterToType(getDelegationState());
  }
  task.setDelegationState(state);

  task.setDueDate(getDue());
  task.setFollowUpDate(getFollowUp());
  task.setParentTaskId(getParentTaskId());
  task.setCaseInstanceId(getCaseInstanceId());
  task.setTenantId(getTenantId());
}
 
Example 8
Source File: TaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskDelegationThroughServiceCall() {
  Task task = taskService.newTask();
  task.setOwner("johndoe");
  taskService.saveTask(task);
  String taskId = task.getId();

  // Fetch the task again and update
  task = taskService.createTaskQuery().taskId(taskId).singleResult();

  taskService.delegateTask(taskId, "joesmoe");

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

  // Finally, delete task
  taskService.deleteTask(taskId, true);
}
 
Example 9
Source File: HistoricTaskInstanceQueryOrTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnHistoricTasksWithMultipleOrCriteria() {
  // given
  Task task1 = taskService.newTask();
  task1.setName("aTaskName");
  taskService.saveTask(task1);

  Task task2 = taskService.newTask();
  task2.setDescription("aTaskDescription");
  taskService.saveTask(task2);

  Task task3 = taskService.newTask();
  taskService.saveTask(task3);

  Task task4 = taskService.newTask();
  task4.setPriority(5);
  taskService.saveTask(task4);

  Task task5 = taskService.newTask();
  task5.setOwner("aTaskOwner");
  taskService.saveTask(task5);

  // when
  List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
      .taskId(task3.getId())
      .taskPriority(5)
      .taskOwner("aTaskOwner")
    .endOr()
    .list();

  // then
  assertEquals(5, tasks.size());
}
 
Example 10
Source File: TaskAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testStandaloneTaskSetOwnerOutsideCommandContextInsert() {
  // given
  String taskId = "myTask";
  createGrantAuthorization(TASK, ANY, userId, CREATE);
  createGrantAuthorization(TASK, taskId, userId, UPDATE);

  Task task = taskService.newTask(taskId);
  task.setOwner("demo");

  // when
  taskService.saveTask(task);

  // then
  disableAuthorization();
  Authorization authorization = authorizationService
      .createAuthorizationQuery()
      .userIdIn("demo")
      .singleResult();
  enableAuthorization();

  assertNotNull(authorization);
  assertEquals(TASK.resourceType(), authorization.getResourceType());
  assertEquals(taskId, authorization.getResourceId());
  assertTrue(authorization.isPermissionGranted(READ));
  assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));

  deleteTask(taskId, true);
}
 
Example 11
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);
}
 
Example 12
Source File: HistoricIdentityLinkLogTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testShouldAddIdentityLinkForTaskCreationWithAssigneeAndOwner() {

    String taskAssigneeId = "Assigneee";
    String taskOwnerId = "Owner";
    // Pre test
    List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 0);

    Task taskAssignee = taskService.newTask(taskAssigneeId);
    taskAssignee.setAssignee(USER_1);
    taskService.saveTask(taskAssignee);

    Task taskOwner = taskService.newTask(taskOwnerId);
    taskOwner.setOwner(OWNER_1);
    taskService.saveTask(taskOwner);

    Task taskEmpty = taskService.newTask();
    taskService.saveTask(taskEmpty);

    // then
    historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 2);

    // Basic Query test
    HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.type(IdentityLinkType.ASSIGNEE).count(), 1);
    assertEquals(query.userId(USER_1).count(), 1);

    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.type(IdentityLinkType.OWNER).count(), 1);
    assertEquals(query.userId(OWNER_1).count(), 1);

    taskService.deleteTask(taskAssigneeId,true);
    taskService.deleteTask(taskOwnerId,true);
    taskService.deleteTask(taskEmpty.getId(), true);
  }
 
Example 13
Source File: TaskAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testStandaloneTaskSaveWithGenericResourceIdOwner() {
  createGrantAuthorization(TASK, ANY, userId, CREATE);

  Task task = taskService.newTask();
  task.setOwner("*");

  try {
    taskService.saveTask(task);
    fail("it should not be possible to save a task with the generic resource id *");
  } catch (ProcessEngineException e) {
    assertTextPresent("Cannot create default authorization for owner *: "
        + "id cannot be *. * is a reserved identifier", e.getMessage());
  }
}
 
Example 14
Source File: HistoricTaskInstanceQueryOrTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldReturnHistoricTasksFilteredByMultipleOrAndCriteria() {
  // given
  Task task1 = taskService.newTask();
  task1.setPriority(4);
  taskService.saveTask(task1);

  Task task2 = taskService.newTask();
  task2.setName("aTaskName");
  task2.setOwner("aTaskOwner");
  task2.setAssignee("aTaskAssignee");
  task2.setPriority(4);
  taskService.saveTask(task2);

  Task task3 = taskService.newTask();
  task3.setName("aTaskName");
  task3.setOwner("aTaskOwner");
  task3.setAssignee("aTaskAssignee");
  task3.setPriority(4);
  task3.setDescription("aTaskDescription");
  taskService.saveTask(task3);

  Task task4 = taskService.newTask();
  task4.setOwner("aTaskOwner");
  task4.setAssignee("aTaskAssignee");
  task4.setPriority(4);
  task4.setDescription("aTaskDescription");
  taskService.saveTask(task4);

  Task task5 = taskService.newTask();
  task5.setDescription("aTaskDescription");
  task5.setOwner("aTaskOwner");
  taskService.saveTask(task5);

  // when
  List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
      .taskId(task3.getId())
    .endOr()
    .taskOwner("aTaskOwner")
    .taskPriority(4)
    .taskAssignee("aTaskAssignee")
    .list();

  // then
  assertEquals(3, tasks.size());
}
 
Example 15
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void createTasksForOrQueries() {
  Task task1 = taskService.newTask();
  task1.setName("taskForOr");
  task1.setDescription("aTaskDescription");
  task1.setPriority(3);
  taskService.saveTask(task1);

  Task task2 = taskService.newTask();
  task2.setName("taskForOr");
  task2.setDescription("aTaskDescription");
  task2.setAssignee("aTaskAssignee");
  task2.setTenantId("aTenantId");
  taskService.saveTask(task2);

  Task task3 = taskService.newTask();
  task3.setName("taskForOr");
  task3.setOwner("aTaskOwner");
  taskService.saveTask(task3);

  Task task4 = taskService.newTask();
  task4.setName("taskForOr");
  task4.setOwner("aTaskOwner");
  task4.setPriority(3);
  taskService.saveTask(task4);

  Task task5 = taskService.newTask();
  task5.setDescription("aTaskDescription");
  task5.setAssignee("aTaskAssignee");
  taskService.saveTask(task5);

  Task task6 = taskService.newTask();
  task6.setDescription("aTaskDescription");
  task6.setAssignee("aTaskAssignee");
  task6.setTenantId("aTenantId");
  taskService.saveTask(task6);

  Task task7 = taskService.newTask();
  task7.setTenantId("aTenantId");
  task7.setOwner("aTaskOwner");
  task7.setPriority(3);
  task7.setAssignee("aTaskAssignee");
  taskService.saveTask(task7);
}
 
Example 16
Source File: HistoricTaskInstanceQueryOrTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldReturnHistoricTasksFilteredByMultipleOrQueries() {
  // given
  Task task1 = taskService.newTask();
  task1.setName("aTaskName");
  taskService.saveTask(task1);

  Task task2 = taskService.newTask();
  task2.setName("aTaskName");
  task2.setDescription("aTaskDescription");
  taskService.saveTask(task2);

  Task task3 = taskService.newTask();
  task3.setName("aTaskName");
  task3.setDescription("aTaskDescription");
  task3.setOwner("aTaskOwner");
  taskService.saveTask(task3);

  Task task4 = taskService.newTask();
  task4.setName("aTaskName");
  task4.setDescription("aTaskDescription");
  task4.setOwner("aTaskOwner");
  task4.setAssignee("aTaskAssignee");
  taskService.saveTask(task4);

  Task task5 = taskService.newTask();
  task5.setName("aTaskName");
  task5.setDescription("aTaskDescription");
  task5.setOwner("aTaskOwner");
  task5.setAssignee("aTaskAssignee");
  task5.setPriority(4);
  taskService.saveTask(task5);

  Task task6 = taskService.newTask();
  task6.setName("aTaskName");
  task6.setDescription("aTaskDescription");
  task6.setOwner("aTaskOwner");
  task6.setAssignee("aTaskAssignee");
  task6.setPriority(4);
  taskService.saveTask(task6);

  // when
  List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
    .endOr()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
      .taskAssignee("aTaskAssignee")
    .endOr()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
      .taskOwner("aTaskOwner")
      .taskAssignee("aTaskAssignee")
    .endOr()
    .or()
      .taskAssignee("aTaskAssignee")
      .taskPriority(4)
    .endOr()
    .list();

  // then
  assertEquals(3, tasks.size());
}
 
Example 17
Source File: TaskQueryOrTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldReturnTasksFilteredByMultipleOrAndCriteria() {
  // given
  Task task1 = taskService.newTask();
  task1.setPriority(4);
  taskService.saveTask(task1);

  Task task2 = taskService.newTask();
  task2.setName("aTaskName");
  task2.setOwner("aTaskOwner");
  task2.setAssignee("aTaskAssignee");
  task2.setPriority(4);
  taskService.saveTask(task2);

  Task task3 = taskService.newTask();
  task3.setName("aTaskName");
  task3.setOwner("aTaskOwner");
  task3.setAssignee("aTaskAssignee");
  task3.setPriority(4);
  task3.setDescription("aTaskDescription");
  taskService.saveTask(task3);

  Task task4 = taskService.newTask();
  task4.setOwner("aTaskOwner");
  task4.setAssignee("aTaskAssignee");
  task4.setPriority(4);
  task4.setDescription("aTaskDescription");
  taskService.saveTask(task4);

  Task task5 = taskService.newTask();
  task5.setDescription("aTaskDescription");
  task5.setOwner("aTaskOwner");
  taskService.saveTask(task5);

  // when
  List<Task> tasks = taskService.createTaskQuery()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
      .taskId(task3.getId())
    .endOr()
    .taskOwner("aTaskOwner")
    .taskPriority(4)
    .taskAssignee("aTaskAssignee")
    .list();

  // then
  assertEquals(3, tasks.size());
}
 
Example 18
Source File: TaskQueryOrTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldReturnTasksFilteredByMultipleOrQueries() {
  // given
  Task task1 = taskService.newTask();
  task1.setName("aTaskName");
  taskService.saveTask(task1);

  Task task2 = taskService.newTask();
  task2.setName("aTaskName");
  task2.setDescription("aTaskDescription");
  taskService.saveTask(task2);

  Task task3 = taskService.newTask();
  task3.setName("aTaskName");
  task3.setDescription("aTaskDescription");
  task3.setOwner("aTaskOwner");
  taskService.saveTask(task3);

  Task task4 = taskService.newTask();
  task4.setName("aTaskName");
  task4.setDescription("aTaskDescription");
  task4.setOwner("aTaskOwner");
  task4.setAssignee("aTaskAssignee");
  taskService.saveTask(task4);

  Task task5 = taskService.newTask();
  task5.setName("aTaskName");
  task5.setDescription("aTaskDescription");
  task5.setOwner("aTaskOwner");
  task5.setAssignee("aTaskAssignee");
  task5.setPriority(4);
  taskService.saveTask(task5);

  Task task6 = taskService.newTask();
  task6.setName("aTaskName");
  task6.setDescription("aTaskDescription");
  task6.setOwner("aTaskOwner");
  task6.setAssignee("aTaskAssignee");
  task6.setPriority(4);
  taskService.saveTask(task6);

  // when
  List<Task> tasks = taskService.createTaskQuery()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
    .endOr()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
      .taskAssignee("aTaskAssignee")
    .endOr()
    .or()
      .taskName("aTaskName")
      .taskDescription("aTaskDescription")
      .taskOwner("aTaskOwner")
      .taskAssignee("aTaskAssignee")
    .endOr()
    .or()
      .taskAssignee("aTaskAssignee")
      .taskPriority(4)
    .endOr()
    .list();

  // then
  assertEquals(3, tasks.size());
}
 
Example 19
Source File: GetHistoricOperationLogsForOptimizeTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private void createLogEntriesThatShouldNotBeReturned(String processInstanceId) {
  ClockUtil.setCurrentTime(new Date());

  String processTaskId = taskService.createTaskQuery().singleResult().getId();

  // create and remove some links
  taskService.addCandidateUser(processTaskId, "er");
  taskService.deleteCandidateUser(processTaskId, "er");
  taskService.addCandidateGroup(processTaskId, "wir");
  taskService.deleteCandidateGroup(processTaskId, "wir");

  // assign and reassign the owner
  taskService.setOwner(processTaskId, "icke");

  // change priority of task
  taskService.setPriority(processTaskId, 10);

  // add and delete an attachment
  Attachment attachment = taskService.createAttachment(
    "image/ico",
    processTaskId,
    processInstanceId,
    "favicon.ico",
    "favicon",
    "http://camunda.com/favicon.ico"
  );
  taskService.deleteAttachment(attachment.getId());
  runtimeService.deleteProcessInstance(processInstanceId, "that's why");

  // create a standalone userTask
  Task userTask = taskService.newTask();
  userTask.setName("to do");
  taskService.saveTask(userTask);

  // change some properties manually to create an update event
  ClockUtil.setCurrentTime(new Date());
  userTask.setDescription("desc");
  userTask.setOwner("icke");
  userTask.setAssignee("er");
  userTask.setDueDate(new Date());
  taskService.saveTask(userTask);

  taskService.deleteTask(userTask.getId(), true);
}
 
Example 20
Source File: HistoricTaskInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testGroupTaskQuery() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess");
  String taskId = taskService.createTaskQuery().singleResult().getId();
  // if
  identityService.setAuthenticatedUserId("aAssignerId");
  taskService.addCandidateUser(taskId, "aUserId");
  taskService.addCandidateGroup(taskId, "aGroupId");
  taskService.addCandidateGroup(taskId, "bGroupId");
  Task taskOne = taskService.newTask("taskOne");
  taskOne.setAssignee("aUserId");
  taskService.saveTask(taskOne);
  Task taskTwo = taskService.newTask("taskTwo");
  taskTwo.setAssignee("aUserId");
  taskService.saveTask(taskTwo);
  Task taskThree = taskService.newTask("taskThree");
  taskThree.setOwner("aUserId");
  taskService.saveTask(taskThree);
  taskService.deleteCandidateGroup(taskId, "aGroupId");
  taskService.deleteCandidateGroup(taskId, "bGroupId");
  historyService.createHistoricTaskInstanceQuery();

  // Query test
  HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
  assertEquals(4, query.taskInvolvedUser("aUserId").count());
  query = historyService.createHistoricTaskInstanceQuery();
  assertEquals(1, query.taskHadCandidateUser("aUserId").count());
  query = historyService.createHistoricTaskInstanceQuery();
  assertEquals(1, query.taskHadCandidateGroup("aGroupId").count());
  assertEquals(1, query.taskHadCandidateGroup("bGroupId").count());
  assertEquals(0, query.taskInvolvedUser("aUserId").count());
  query = historyService.createHistoricTaskInstanceQuery();
  assertEquals(4, query.taskInvolvedUser("aUserId").count());
  assertEquals(1, query.taskHadCandidateUser("aUserId").count());
  assertEquals(1, query.taskInvolvedUser("aUserId").count());
  // delete task
  taskService.deleteTask("taskOne",true);
  taskService.deleteTask("taskTwo",true);
  taskService.deleteTask("taskThree",true);
}