コード例 #1
0
  @Test
  public void testTaskDataAutomaticMapping() throws Exception {
    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    MyObject myObject = new MyObject("MyObjectValue");
    workItem.setParameter("MyObject", myObject);
    Map<String, Object> mapParameter = new HashMap<String, Object>();
    mapParameter.put("MyObjectInsideTheMap", myObject);
    workItem.setParameter("MyMap", mapParameter);
    workItem.setParameter("MyObject", myObject);

    getHandler().executeWorkItem(workItem, manager);

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(1, tasks.size());
    TaskSummary taskSummary = tasks.get(0);
    assertEquals("TaskName", taskSummary.getName());
    assertEquals(10, taskSummary.getPriority());
    assertEquals("Comment", taskSummary.getDescription());
    assertEquals(Status.Reserved, taskSummary.getStatus());
    assertEquals("Darth Vader", taskSummary.getActualOwner().getId());

    Task task = taskService.getTaskById(taskSummary.getId());
    assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType());
    long contentId = task.getTaskData().getDocumentContentId();
    assertTrue(contentId != -1);

    Map<String, Object> data =
        (Map<String, Object>)
            ContentMarshallerHelper.unmarshall(
                taskService.getContentById(contentId).getContent(), ksession.getEnvironment());

    // Checking that the input parameters are being copied automatically if the Content Element
    // doesn't exist
    assertEquals("MyObjectValue", ((MyObject) data.get("MyObject")).getValue());
    assertEquals("10", data.get("Priority"));
    assertEquals(
        "MyObjectValue",
        ((MyObject) ((Map<String, Object>) data.get("MyMap")).get("MyObjectInsideTheMap"))
            .getValue());

    taskService.start(task.getId(), "Darth Vader");

    Map<String, Object> results = new HashMap<String, Object>();
    results.put("Result", "This is the result");

    taskService.complete(task.getId(), "Darth Vader", results);

    assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
    results = manager.getResults();
    assertNotNull(results);
    assertEquals("Darth Vader", results.get("ActorId"));
    assertEquals("This is the result", results.get("Result"));
  }
コード例 #2
0
  @Test
  public void testTaskExit() throws Exception {
    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    getHandler().executeWorkItem(workItem, manager);

    Task task = taskService.getTaskByWorkItemId(workItem.getId());

    taskService.exit(task.getId(), "Administrator");

    task = taskService.getTaskByWorkItemId(workItem.getId());
    assertEquals("TaskName", task.getNames().get(0).getText());
    assertEquals(10, task.getPriority());
    assertEquals("Comment", task.getDescriptions().get(0).getText());
    assertEquals(Status.Exited, task.getTaskData().getStatus());

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(0, tasks.size());
  }
コード例 #3
0
  @Test
  public void testTask() throws Exception {
    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    workItem.setProcessInstanceId(10);
    handler.executeWorkItem(workItem, manager);

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(1, tasks.size());
    TaskSummary task = tasks.get(0);
    assertEquals("TaskName", task.getName());
    assertEquals(10, task.getPriority());
    assertEquals("Comment", task.getDescription());
    assertEquals(Status.Reserved, task.getStatus());
    assertEquals("Darth Vader", task.getActualOwner().getId());
    assertEquals(10, task.getProcessInstanceId());

    taskService.start(task.getId(), "Darth Vader");
    taskService.complete(task.getId(), "Darth Vader", null);

    assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
  }
コード例 #4
0
  @Test
  public void testTaskExitNonAdministrator() throws Exception {
    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    getHandler().executeWorkItem(workItem, manager);

    Task task = taskService.getTaskByWorkItemId(workItem.getId());

    try {
      taskService.exit(task.getId(), "Darth Vader");
      fail("Should not allow to exit task for non administrators");
    } catch (PermissionDeniedException e) {

    }

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(1, tasks.size());
    TaskSummary taskSummary = tasks.get(0);
    assertEquals("TaskName", taskSummary.getName());
    assertEquals(10, taskSummary.getPriority());
    assertEquals("Comment", taskSummary.getDescription());
    assertEquals(Status.Reserved, taskSummary.getStatus());
    assertEquals("Darth Vader", taskSummary.getActualOwner().getId());
  }
コード例 #5
0
  @Test
  public void testTaskData() throws Exception {
    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    workItem.setParameter("Content", "This is the content");
    getHandler().executeWorkItem(workItem, manager);

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(1, tasks.size());
    TaskSummary taskSummary = tasks.get(0);
    assertEquals("TaskName", taskSummary.getName());
    assertEquals(10, taskSummary.getPriority());
    assertEquals("Comment", taskSummary.getDescription());
    assertEquals(Status.Reserved, taskSummary.getStatus());
    assertEquals("Darth Vader", taskSummary.getActualOwner().getId());

    Task task = taskService.getTaskById(taskSummary.getId());
    assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType());
    assertEquals(
        task.getTaskData().getProcessSessionId(), TestStatefulKnowledgeSession.testSessionId);
    long contentId = task.getTaskData().getDocumentContentId();
    assertTrue(contentId != -1);

    Object data =
        ContentMarshallerHelper.unmarshall(
            taskService.getContentById(contentId).getContent(), ksession.getEnvironment());
    assertEquals("This is the content", data);

    taskService.start(task.getId(), "Darth Vader");

    Map<String, Object> results = new HashMap<String, Object>();
    results.put("Result", "This is the result");
    //        ContentData result = ContentMarshallerHelper.marshal(,
    //                                                                ksession.getEnvironment());
    taskService.complete(task.getId(), "Darth Vader", results);

    assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
    results = manager.getResults();
    assertNotNull(results);
    assertEquals("Darth Vader", results.get("ActorId"));
    assertEquals("This is the result", results.get("Result"));
  }
コード例 #6
0
  @Test
  public void testTaskAbortSkippable() throws Exception {
    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    getHandler().executeWorkItem(workItem, manager);

    getHandler().abortWorkItem(workItem, manager);

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(0, tasks.size());
  }
コード例 #7
0
  public static WorkItem readWorkItem(MarshallerReaderContext context) throws IOException {
    ObjectInputStream stream = context.stream;

    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setId(stream.readLong());
    workItem.setProcessInstanceId(stream.readLong());
    workItem.setName(stream.readUTF());
    workItem.setState(stream.readInt());

    // WorkItem Paramaters
    int nbVariables = stream.readInt();
    if (nbVariables > 0) {

      for (int i = 0; i < nbVariables; i++) {
        String name = stream.readUTF();
        try {
          int index = stream.readInt();
          ObjectMarshallingStrategy strategy = null;
          // Old way of retrieving strategy objects
          if (index >= 0) {
            strategy = context.resolverStrategyFactory.getStrategy(index);
            if (strategy == null) {
              throw new IllegalStateException("No strategy of with index " + index + " available.");
            }
          }
          // New way
          else if (index == -2) {
            String strategyClassName = stream.readUTF();
            strategy = context.resolverStrategyFactory.getStrategyObject(strategyClassName);
            if (strategy == null) {
              throw new IllegalStateException(
                  "No strategy of type " + strategyClassName + " available.");
            }
          }

          Object value = strategy.read(stream);
          workItem.setParameter(name, value);
        } catch (ClassNotFoundException e) {
          throw new IllegalArgumentException("Could not reload variable " + name);
        }
      }
    }

    return workItem;
  }
コード例 #8
0
  @Ignore
  @Test // FIX UserGROUP CALLBACK
  public void testTaskGroupActors() throws Exception {

    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("GroupId", "Crusaders");
    getHandler().executeWorkItem(workItem, manager);

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Luke", "en-UK");
    assertEquals(1, tasks.size());
    TaskSummary taskSummary = tasks.get(0);
    assertEquals("TaskName", taskSummary.getName());
    assertEquals(10, taskSummary.getPriority());
    assertEquals("Comment", taskSummary.getDescription());
    assertEquals(Status.Ready, taskSummary.getStatus());

    PermissionDeniedException denied = null;
    try {
      taskService.claim(taskSummary.getId(), "Darth Vader");
    } catch (PermissionDeniedException e) {
      denied = e;
    }

    assertNotNull("Should get permissed denied exception", denied);

    // Check if the parent task is InProgress

    Task task = taskService.getTaskById(taskSummary.getId());
    assertEquals(Status.Ready, task.getTaskData().getStatus());
  }
コード例 #9
0
  public void executeEmailNotification(
      EmailNotification notification, Task task, EntityManager em) {
    Map<String, EmailNotificationHeader> headers = notification.getEmailHeaders();

    // group users into languages
    Map<String, List<User>> users = new HashMap<String, List<User>>();
    for (OrganizationalEntity entity : notification.getBusinessAdministrators()) {
      if (entity instanceof Group) {
        buildMapByLanguage(users, (Group) entity);
      } else {
        buildMapByLanguage(users, (User) entity);
      }
    }

    for (OrganizationalEntity entity : notification.getRecipients()) {
      if (entity instanceof Group) {
        buildMapByLanguage(users, (Group) entity);
      } else {
        buildMapByLanguage(users, (User) entity);
      }
    }

    TaskData taskData = task.getTaskData();
    Map<String, Object> doc = null;
    if (taskData != null) {
      Content content = em.find(Content.class, taskData.getDocumentContentId());
      if (content != null) {
        ExpressionCompiler compiler = new ExpressionCompiler(new String(content.getContent()));
        doc = (Map<String, Object>) MVEL.executeExpression(compiler.compile());
      } else {
        doc = Collections.emptyMap();
      }
    }

    for (Iterator<Entry<String, List<User>>> it = users.entrySet().iterator(); it.hasNext(); ) {
      Entry<String, List<User>> entry = it.next();
      EmailNotificationHeader header = headers.get(entry.getKey());

      Map<String, Object> email = new HashMap<String, Object>();
      StringBuilder to = new StringBuilder();
      boolean first = true;
      for (User user : entry.getValue()) {
        if (!first) {
          to.append(';');
        }
        String emailAddress = userInfo.getEmailForEntity(user);
        to.append(emailAddress);
        first = false;
      }
      email.put("To", to.toString());

      if (header.getFrom() != null && header.getFrom().trim().length() > 0) {
        email.put("From", header.getFrom());
      } else {
        email.put("From", from);
      }

      if (header.getReplyTo() != null && header.getReplyTo().trim().length() > 0) {
        email.put("Reply-To", header.getReplyTo());
      } else {
        email.put("Reply-To", replyTo);
      }

      Map<String, Object> vars = new HashMap<String, Object>();
      vars.put("doc", doc);
      String subject = (String) TemplateRuntime.eval(header.getSubject(), vars);
      String body = (String) TemplateRuntime.eval(header.getBody(), vars);

      email.put("Subject", subject);
      email.put("Body", body);

      WorkItemImpl workItem = new WorkItemImpl();
      workItem.setParameters(email);

      handler.executeWorkItem(workItem, manager);
    }
  }
コード例 #10
0
  @Test
  @Ignore // FIX USER GROUP CALLBACK STUFF
  public void testTaskSingleAndGroupActors() throws Exception {
    //    	Properties userGroups = new Properties();
    //        userGroups.setProperty("Darth Vader", "Crusaders");
    //
    //        UserGroupCallbackManager.getInstance().setCallback(new
    // DefaultUserGroupCallbackImpl(userGroups));
    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task One");
    workItem.setParameter("TaskName", "TaskNameOne");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("GroupId", "Crusaders");
    getHandler().executeWorkItem(workItem, manager);

    workItem = new WorkItemImpl();
    workItem.setName("Human Task Two");
    workItem.setParameter("TaskName", "TaskNameTwo");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    getHandler().executeWorkItem(workItem, manager);

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(2, tasks.size());
  }
コード例 #11
0
  @Test
  public void testTaskDataWithVPSandMAPWithDeadline() throws Exception {

    taskService.setEscalatedDeadlineHandler(buildDeadlineHandler(env));
    // JPA Entity
    EntityManager em = domainEmf.createEntityManager();
    em.getTransaction().begin();
    MyEntity myEntity = new MyEntity("This is a JPA Entity");
    em.persist(myEntity);
    em.getTransaction().commit();

    // Serializable Object
    MyObject myObject = new MyObject("This is a Serializable Object");

    Map<String, Object> content = new HashMap<String, Object>();
    content.put("myJPAEntity", myEntity);
    content.put("mySerializableObject", myObject);

    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    workItem.setParameter("Content", content);
    workItem.setParameter(
        "NotStartedNotify",
        "[tousers:john|subject:${doc['myJPAEntity'].test}|body:${doc['mySerializableObject'].value}]@[2s]");
    getHandler().executeWorkItem(workItem, manager);

    BlockingTaskSummaryResponseHandler taskSummaryResponseHandler =
        new BlockingTaskSummaryResponseHandler();
    getClient()
        .getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK", taskSummaryResponseHandler);
    List<TaskSummary> tasks = taskSummaryResponseHandler.getResults();
    assertEquals(1, tasks.size());
    TaskSummary taskSummary = tasks.get(0);
    assertEquals("TaskName", taskSummary.getName());
    assertEquals(10, taskSummary.getPriority());
    assertEquals("Comment", taskSummary.getDescription());
    assertEquals(Status.Reserved, taskSummary.getStatus());
    assertEquals("Darth Vader", taskSummary.getActualOwner().getId());

    BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
    getClient().getTask(taskSummary.getId(), getTaskResponseHandler);
    Task task = getTaskResponseHandler.getTask();
    assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType());
    assertEquals(task.getTaskData().getProcessSessionId(), ksession.getId());
    long contentId = task.getTaskData().getDocumentContentId();
    assertTrue(contentId != -1);

    BlockingGetContentResponseHandler getContentResponseHandler =
        new BlockingGetContentResponseHandler();
    getClient().getContent(contentId, getContentResponseHandler);
    Object data =
        ContentMarshallerHelper.unmarshall(
            getContentResponseHandler.getContent().getContent(), ksession.getEnvironment());
    Map<String, Object> dataMap = (Map<String, Object>) data;

    assertEquals(myEntity.getTest(), ((MyEntity) dataMap.get("myJPAEntity")).getTest());
    assertEquals(myObject.getValue(), ((MyObject) dataMap.get("mySerializableObject")).getValue());

    Thread.sleep(5000);
    assertEquals(2, wiser.getMessages().size());
    assertEquals("*****@*****.**", wiser.getMessages().get(0).getEnvelopeReceiver());
    assertEquals("*****@*****.**", wiser.getMessages().get(1).getEnvelopeReceiver());
    assertEquals(myEntity.getTest(), wiser.getMessages().get(0).getMimeMessage().getSubject());
    assertEquals(myObject.getValue(), wiser.getMessages().get(0).getMimeMessage().getContent());

    BlockingTaskOperationResponseHandler startResponseHandler =
        new BlockingTaskOperationResponseHandler();
    getClient().start(task.getId(), "Darth Vader", startResponseHandler);

    Map<String, Object> results = new HashMap<String, Object>();
    em.getTransaction().begin();
    MyEntity myEntity2 = new MyEntity("This is a JPA Entity 2");
    em.persist(myEntity2);
    em.getTransaction().commit();
    results.put("myEntity2", myEntity2);
    MyObject myObject2 = new MyObject("This is a Serializable Object 2");
    results.put("myObject2", myObject2);

    ContentData result = ContentMarshallerHelper.marshal(results, ksession.getEnvironment());

    BlockingTaskOperationResponseHandler completeResponseHandler =
        new BlockingTaskOperationResponseHandler();
    getClient().complete(task.getId(), "Darth Vader", result, completeResponseHandler);

    assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
    Map<String, Object> managerResults = manager.getResults();
    assertNotNull(managerResults);
    assertEquals("Darth Vader", managerResults.get("ActorId"));
    assertEquals(
        myEntity2.getTest(),
        ((MyEntity) ((Map) managerResults.get("Result")).get("myEntity2")).getTest());
    assertEquals(myEntity2.getTest(), ((MyEntity) managerResults.get("myEntity2")).getTest());
    assertEquals(
        myObject2.getValue(),
        ((MyObject) ((Map) managerResults.get("Result")).get("myObject2")).getValue());
    assertEquals(myObject2.getValue(), ((MyObject) managerResults.get("myObject2")).getValue());
  }
コード例 #12
0
  @Test
  public void testTaskDataWithVPSSerializableObjectWithMarshal() throws Exception {
    // Serializable Object
    MyObject myObject = new MyObject("This is a Serializable Object");

    TestWorkItemManager manager = new TestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    workItem.setParameter("Content", myObject);
    getHandler().executeWorkItem(workItem, manager);

    BlockingTaskSummaryResponseHandler taskSummaryResponseHandler =
        new BlockingTaskSummaryResponseHandler();
    getClient()
        .getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK", taskSummaryResponseHandler);
    List<TaskSummary> tasks = taskSummaryResponseHandler.getResults();
    assertEquals(1, tasks.size());
    TaskSummary taskSummary = tasks.get(0);
    assertEquals("TaskName", taskSummary.getName());
    assertEquals(10, taskSummary.getPriority());
    assertEquals("Comment", taskSummary.getDescription());
    assertEquals(Status.Reserved, taskSummary.getStatus());
    assertEquals("Darth Vader", taskSummary.getActualOwner().getId());

    BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
    getClient().getTask(taskSummary.getId(), getTaskResponseHandler);
    Task task = getTaskResponseHandler.getTask();
    assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType());

    assertEquals(task.getTaskData().getProcessSessionId(), ksession.getId());
    long contentId = task.getTaskData().getDocumentContentId();
    assertTrue(contentId != -1);

    BlockingGetContentResponseHandler getContentResponseHandler =
        new BlockingGetContentResponseHandler();
    getClient().getContent(contentId, getContentResponseHandler);
    Object data =
        ContentMarshallerHelper.unmarshall(
            getContentResponseHandler.getContent().getContent(), ksession.getEnvironment());
    assertEquals(myObject.getValue(), ((MyObject) data).getValue());

    BlockingTaskOperationResponseHandler startResponseHandler =
        new BlockingTaskOperationResponseHandler();
    getClient().start(task.getId(), "Darth Vader", startResponseHandler);

    MyObject myObject2 = new MyObject("This is a Serializable Object 2");

    ContentData result = ContentMarshallerHelper.marshal(myObject2, ksession.getEnvironment());
    BlockingTaskOperationResponseHandler completeResponseHandler =
        new BlockingTaskOperationResponseHandler();
    getClient().complete(task.getId(), "Darth Vader", result, completeResponseHandler);

    assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
    Map<String, Object> results = manager.getResults();
    assertNotNull(results);
    assertEquals("Darth Vader", results.get("ActorId"));
    assertEquals(myObject2.getValue(), ((MyObject) results.get("Result")).getValue());
  }
コード例 #13
0
  @Test
  public void testCompleteTaskMultipleSessionsSync() throws Exception {
    TestStatefulKnowledgeSession ksession = new TestStatefulKnowledgeSession();

    HornetQHTWorkItemHandler handler = new HornetQHTWorkItemHandler(ksession, true);

    client = handler.getClient();
    HornetQTestWorkItemManager manager = new HornetQTestWorkItemManager();
    ksession.setWorkItemManager(manager);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Human Task");
    workItem.setParameter("TaskName", "TaskName");
    workItem.setParameter("Comment", "Comment");
    workItem.setParameter("Priority", "10");
    workItem.setParameter("ActorId", "Darth Vader");
    workItem.setProcessInstanceId(10);
    handler.executeWorkItem(workItem, manager);

    TestStatefulKnowledgeSession ksession2 = new TestStatefulKnowledgeSession(10);
    HornetQHTWorkItemHandler handler2 =
        new HornetQHTWorkItemHandler("testConnector", null, ksession2, OnErrorAction.LOG);
    handler2.setOwningSessionOnly(true);

    HornetQTestWorkItemManager manager2 = new HornetQTestWorkItemManager();
    ksession2.setWorkItemManager(manager2);
    WorkItemImpl workItem2 = new WorkItemImpl();
    workItem2.setName("Human Task");
    workItem2.setParameter("TaskName", "TaskName");
    workItem2.setParameter("Comment", "Comment");
    workItem2.setParameter("Priority", "10");
    workItem2.setParameter("ActorId", "Darth Vader");
    workItem2.setProcessInstanceId(10);
    handler2.executeWorkItem(workItem2, manager2);

    List<TaskSummary> tasks = client.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(2, tasks.size());
    TaskSummary task = tasks.get(0);
    // ensure we get first task
    if (task.getProcessSessionId() == 10) {
      task = tasks.get(1);
    }
    assertEquals("TaskName", task.getName());
    assertEquals(10, task.getPriority());
    assertEquals("Comment", task.getDescription());
    assertEquals(Status.Reserved, task.getStatus());
    assertEquals("Darth Vader", task.getActualOwner().getId());
    assertEquals(10, task.getProcessInstanceId());

    client.start(task.getId(), "Darth Vader");
    client.complete(task.getId(), "Darth Vader", null);

    Thread.sleep(1000);

    assertEquals(1, manager.getCompleteCounter());
    assertEquals(0, manager2.getCompleteCounter());

    handler.dispose();
    handler2.dispose();
  }