@Test
  @BZ("1178153")
  public void testGetTasksAssignedAsPotentialOwnerUser() {
    createRuntimeManager(GET_TASKS_OWNER_USER);
    KieSession ksession = getRuntimeEngine().getKieSession();
    SynchronizedTaskService taskService =
        (SynchronizedTaskService) getRuntimeEngine().getTaskService();

    long pid = ksession.startProcess(GET_TASKS_OWNER_USER_ID).getId();

    // Task is potentially assigned to several users - mary,john,ibek.
    List<TaskSummary> taskList =
        taskService.getTasksAssignedAsPotentialOwner("jack", new ArrayList<String>());
    Assertions.assertThat(taskList).hasSize(0);

    taskList = taskService.getTasksAssignedAsPotentialOwner("mary", new ArrayList<String>());
    Assertions.assertThat(taskList).hasSize(1);
    Assertions.assertThat(taskList.get(0).getStatus()).isEqualTo(Status.Ready);

    ksession.abortProcessInstance(pid);
  }
  @Test
  @BZ("1103977")
  public void testGetTasksAssignedAsPotentialOwnerGroup() {
    createRuntimeManager(GET_TASKS_OWNER_GROUP);
    KieSession ksession = getRuntimeEngine().getKieSession();
    SynchronizedTaskService taskService =
        (SynchronizedTaskService) getRuntimeEngine().getTaskService();

    long pid = ksession.startProcess(GET_TASKS_OWNER_GROUP_ID).getId();

    // Task is assigned to group HR.
    List<TaskSummary> taskList =
        taskService.getTasksAssignedAsPotentialOwner(null, Arrays.asList("HR"));

    Assertions.assertThat(taskList).hasSize(1);
    Assertions.assertThat(taskList.get(0).getStatus()).isEqualTo(Status.Ready);

    Long taskId = taskList.get(0).getId();
    taskService.claim(taskId, "mary");
    taskService.start(taskId, "mary");
    taskService.complete(taskId, "mary", null);

    Task task = taskService.getTaskById(taskId);
    Assertions.assertThat(task.getTaskData().getStatus()).isEqualTo(Status.Completed);

    // Next task is assigned to group PM.
    // So task list for HR will be empty.
    taskList = taskService.getTasksAssignedAsPotentialOwner(null, Arrays.asList("HR"));
    Assertions.assertThat(taskList).hasSize(0);

    taskList = taskService.getTasksAssignedAsPotentialOwner(null, Arrays.asList("PM"));
    Assertions.assertThat(taskList).hasSize(1);
    Assertions.assertThat(taskList.get(0).getStatus()).isEqualTo(Status.Ready);

    ksession.abortProcessInstance(pid);
  }