@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"));
  }
 public long addTask(Task task, Map<String, Object> params) {
   doCallbackOperationForPeopleAssignments(task.getPeopleAssignments());
   doCallbackOperationForTaskData(task.getTaskData());
   doCallbackOperationForTaskDeadlines(task.getDeadlines());
   if (params != null) {
     ContentData contentData = ContentMarshallerHelper.marshal(params, null);
     Content content = new Content(contentData.getContent());
     em.persist(content);
     task.getTaskData().setDocument(content.getId(), contentData);
   }
   em.persist(task);
   return task.getId();
 }
  public long newTask(String name, Map<String, Object> params) {
    TaskDef taskDef = taskDefService.getTaskDefById(name);

    Task task = TaskFactory.newTask(taskDef);
    em.persist(task);
    if (params != null) {
      ContentData contentData = ContentMarshallerHelper.marshal(params, null);
      Content content = new Content(contentData.getContent());
      em.persist(content);
      task.getTaskData().setDocument(content.getId(), contentData);
    }

    return task.getId();
  }
  public Map<String, Object> getTaskContent(long taskId) {
    Task taskById = taskQueryService.getTaskInstanceById(taskId);
    Content contentById =
        taskContentService.getContentById(taskById.getTaskData().getDocumentContentId());

    Object unmarshalledObject = ContentMarshallerHelper.unmarshall(contentById.getContent(), null);
    if (!(unmarshalledObject instanceof Map)) {
      throw new IllegalStateException(
          " The Task Content Needs to be a Map in order to use this method and it was: "
              + unmarshalledObject.getClass());
    }
    Map<String, Object> content = (Map<String, Object>) unmarshalledObject;

    return content;
  }
  @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"));
  }
 public void execute(Content content) {
   Object result =
       ContentMarshallerHelper.unmarshall(
           content.getContent(), session.getEnvironment(), classLoader);
   results.put("Result", result);
   if (result instanceof Map) {
     @SuppressWarnings("rawtypes")
     Map<?, ?> map = (Map) result;
     for (Map.Entry<?, ?> entry : map.entrySet()) {
       if (entry.getKey() instanceof String) {
         results.put((String) entry.getKey(), entry.getValue());
       }
     }
   }
   session.getWorkItemManager().completeWorkItem(task.getTaskData().getWorkItemId(), results);
 }
  public long newTask(TaskDef taskDef, Map<String, Object> params, boolean deploy) {
    // TODO: need to deal with the params for the content
    if (deploy) {
      taskDefService.deployTaskDef(taskDef);
    }
    Task task = TaskFactory.newTask(taskDef);
    em.persist(task);
    if (params != null) {
      ContentData contentData = ContentMarshallerHelper.marshal(params, null);
      Content content = new Content(contentData.getContent());
      em.persist(content);
      task.getTaskData().setDocument(content.getId(), contentData);
    }

    return task.getId();
  }
  @Override
  public Task convert(org.jbpm.task.query.TaskSummary source) {

    Task target = new Task();

    target.setDescription(source.getDescription());

    if (source.getActualOwner() != null) {
      target.setAssignee(source.getActualOwner().getId());
    }

    if (source.getCreatedOn() != null) {
      target.setCreateTime(convert(source.getCreatedOn(), XMLGregorianCalendar.class));
    }

    if (source.getExpirationTime() != null) {
      target.setDueDate(convert(source.getExpirationTime(), XMLGregorianCalendar.class));
    }
    target.setId(String.valueOf(source.getId()));

    if (source.getName() != null) {
      String[] parts = source.getName().split("/");
      target.setActivityName(parts[0]);
      target.setName(parts[1]);
    }

    target.setState(source.getStatus().name());

    target.setPriority(new Integer(source.getPriority()));
    target.setProcessInstanceId(
        source.getProcessId() + "." + Long.toString(source.getProcessInstanceId()));

    BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
    taskClient.getTask(source.getId(), getTaskResponseHandler);
    org.jbpm.task.Task task = getTaskResponseHandler.getTask();

    BlockingGetContentResponseHandler getContentResponseHandler =
        new BlockingGetContentResponseHandler();
    taskClient.getContent(task.getTaskData().getDocumentContentId(), getContentResponseHandler);
    Content content = getContentResponseHandler.getContent();

    Map<String, Object> map =
        (Map<String, Object>) ContentMarshallerHelper.unmarshall(content.getContent(), null);

    for (String key : map.keySet()) {
      log.debug("Key: " + key);
    }

    // add task outcomes using the "Options" variable from the task
    String optionsString = (String) map.get("Options");
    if (optionsString != null) {
      String[] options = ((String) map.get("Options")).split(",");
      target.getOutcomes().addAll(Arrays.asList(options));
    }

    // get ad-hoc variables map

    Map<String, Object> contentMap =
        (Map<String, Object>) map.get(Bpmn20UserTaskNodeBuilder.TASK_INPUT_VARIABLES_NAME);
    if (contentMap != null) {
      for (Entry<String, Object> entry : contentMap.entrySet()) {
        log.debug(entry.getKey() + "=" + entry.getValue());
        addVariable(target, entry.getKey(), entry.getValue());
      }
    } else {
      log.debug("No Content found for task");
    }

    // add variables
    /*Set<String> names = taskService.getVariableNames(source.getId());
    Map<String, Object> variables = taskService.getVariables(source.getId(), names);
    // remove process name var
    variables.remove("_name");
    for (String key : variables.keySet()) {
        Variable var = new Variable();
        var.setName(key);
        // Support strings only.  Other types will cause ClassCastException
        try {
            var.setValue((String) variables.get(key));
        } catch (ClassCastException e) {
            var.setValue("Variable type " + variables.get(key).getClass().getName() + " is not supported");
        }
        addVariable(target, var);
    }

    // Do this only if the task is not an ad-hoc task (as indicated by null executionId)
    if (source.getExecutionId() != null) {

        // name is the 'form' attribute in JPDL
        // this is used in the COW schema to store the display name, as distinct from the system-generated name
        target.setName(source.getFormResourceName());

        // activityName is the 'name' from JPDL
        target.setActivityName(source.getActivityName());

        Execution ex = executionService.findExecutionById(source.getExecutionId());
        target.setProcessInstanceId(ex.getProcessInstance().getId());

        // outcomes
        Set<String> outcomes = taskService.getOutcomes(source.getId());
        for (String outcome : outcomes) {
            target.getOutcomes().add(outcome);
        }

        // Workaround to the fact that we cannot use autowiring here
        if (this.cowTaskService == null) {
            this.cowTaskService = (org.wiredwidgets.cow.server.service.TaskService) this.factory.getBean("taskService");
        }

        // add process level task varibles (
        String executionId = getTopLevelExecutionId(source.getExecutionId());
        org.wiredwidgets.cow.server.api.model.v2.Activity activity = cowTaskService.getWorkflowActivity(executionId, source.getActivityName());
        if (activity != null && activity instanceof org.wiredwidgets.cow.server.api.model.v2.Task) {
            org.wiredwidgets.cow.server.api.model.v2.Task cowTask = (org.wiredwidgets.cow.server.api.model.v2.Task) activity;
            if (cowTask.getVariables() != null) {
                for (org.wiredwidgets.cow.server.api.model.v2.Variable var : cowTask.getVariables().getVariables()) {
                    Variable newVar = new Variable();
                    newVar.setName(var.getName());
                    newVar.setValue(var.getValue());
                    addVariable(target, newVar);
                }
            }
        }
    } else {
        // for ad-hoc tasks
        target.setName(source.getName());
    }*/

    return target;
  }
  @Override
  public void completeTask(
      Long id, String assignee, String outcome, Map<String, Object> variables) {
    // should be handled upstream in controller
    assert (assignee != null);

    log.debug(assignee + " starting task with ID: " + id);

    BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
    taskClient.getTask(id, getTaskResponseHandler);
    org.jbpm.task.Task task = getTaskResponseHandler.getTask();

    // convert to COW task so we can verify the decision
    Task cowTask = converter.convert(task, Task.class);

    if (cowTask.getOutcomes() != null && cowTask.getOutcomes().size() > 0) {
      // This is a decision task!
      if (outcome == null) {
        throw new RuntimeException("ERROR: no decision provided for a Decision task");
      }
      if (!cowTask.getOutcomes().contains(outcome)) {
        throw new RuntimeException("ERROR: decision value " + outcome + " is not a valid choice.");
      }
    }

    BlockingGetContentResponseHandler getContentResponseHandler =
        new BlockingGetContentResponseHandler();
    taskClient.getContent(task.getTaskData().getDocumentContentId(), getContentResponseHandler);
    Content inputContent = getContentResponseHandler.getContent();

    Map<String, Object> inputMap =
        (Map<String, Object>) ContentMarshallerHelper.unmarshall(inputContent.getContent(), null);

    for (Map.Entry<String, Object> entry : inputMap.entrySet()) {
      log.debug(entry.getKey() + " = " + entry.getValue());
    }

    Map<String, Object> outputMap = new HashMap<String, Object>();

    // put Outcome into the outputMap
    // The InputMap contains a variable that tells us what key to use
    if (inputMap.get(DECISION_VAR_NAME) != null) {
      log.debug("Decision outcome: " + outcome);
      outputMap.put((String) inputMap.get(DECISION_VAR_NAME), outcome);
    }

    Map<String, Object> outputVarsMap = new HashMap<String, Object>();

    // NOTE: obtaining the map from the Task results in a copy of the map as of the
    // time when the task became available.  It's possible that in the meantime (e.g. due to
    // a parallel task) the map has been altered.
    // Map<String, Object> inputVarsMap = (Map<String, Object>)
    // inputMap.get(TASK_INPUT_VARIABLES_NAME);

    // So, instead, we get the current values directly from the process instance, rather than the
    // values copied into the task

    Long processInstanceId = task.getTaskData().getProcessInstanceId();
    Map<String, Object> inputVarsMap = null;

    try {
      WorkflowProcessInstance pi =
          (WorkflowProcessInstance) kSession.getProcessInstance(processInstanceId);
      inputVarsMap = (Map<String, Object>) pi.getVariable(VARIABLES_PROPERTY);
    } catch (Exception e) {
      // not an active process?  look in the dB.
      log.error(e);
      List<VariableInstanceLog> vars =
          JPAProcessInstanceDbLog.findVariableInstances(processInstanceId, VARIABLES_PROPERTY);
      log.info("variable count: " + vars.size());
      if (vars.size() > 0) {
        // why more than one???
        inputVarsMap = (Map<String, Object>) vars.get(0);
      }
    }

    if (inputVarsMap != null) {
      // initialize the output map with the input values
      log.debug("Copying input map: " + inputVarsMap);
      outputVarsMap.putAll(inputVarsMap);
    }

    if (variables != null && variables.size() > 0) {
      log.debug("Adding variables: " + variables);
      // update with any new or modified values
      outputVarsMap.putAll(variables);
    }

    if (outputVarsMap.size() > 0) {
      log.debug("Adding map to output");
      outputMap.put(TASK_OUTPUT_VARIABLES_NAME, outputVarsMap);
    }

    // start the task
    if (task.getTaskData().getStatus().equals(org.jbpm.task.Status.Reserved)) {
      BlockingTaskOperationResponseHandler operationResponseHandler =
          new BlockingTaskOperationResponseHandler();
      // change status to InProgress
      taskClient.start(id, assignee, operationResponseHandler);
    }

    // kSession.getWorkItemManager().completeWorkItem(task.getTaskData().getWorkItemId(), new
    // HashMap<String,Object>());
    BlockingTaskOperationResponseHandler taskResponseHandler =
        new BlockingTaskOperationResponseHandler();
    // TODO: since we're passing the variables map further down, maybe we don't need to pass it
    // here?  Test this.
    ContentData contentData = ContentMarshallerHelper.marshal(outputMap, null);
    taskClient.complete(id, assignee, contentData, taskResponseHandler);
    taskResponseHandler.waitTillDone(1000);

    // note that we have to pass the variables again.
    kSession.getWorkItemManager().completeWorkItem(task.getTaskData().getWorkItemId(), outputMap);

    // update completed date
    // For some reason this does not get updated by default, and
    // there appears to be no JBPM API way to do this!
    org.jbpm.task.Task t = taskRepo.findOne(task.getId());
    t.getTaskData().setCompletedOn(new Date());
    // update the user
    t.getTaskData().setActualOwner(new User(assignee));

    // note that JPA handles updating of this object automatically

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