gpt4 book ai didi

org.kie.api.runtime.process.WorkItemHandler.executeWorkItem()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 00:43:05 28 4
gpt4 key购买 nike

本文整理了Java中org.kie.api.runtime.process.WorkItemHandler.executeWorkItem()方法的一些代码示例,展示了WorkItemHandler.executeWorkItem()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkItemHandler.executeWorkItem()方法的具体详情如下:
包路径:org.kie.api.runtime.process.WorkItemHandler
类名称:WorkItemHandler
方法名:executeWorkItem

WorkItemHandler.executeWorkItem介绍

[英]The given work item should be executed.
[中]应该执行给定的工作项。

代码示例

代码示例来源:origin: kiegroup/jbpm

@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
  try {
    originalTaskHandler.executeWorkItem(workItem, manager);
  } catch( Throwable cause ) { 
    handleExecuteException(cause, workItem, manager);
  }
}

代码示例来源:origin: kiegroup/jbpm

@Test(timeout = 10000)
public void testTaskWithVariablesRecurse() {
  final TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  handler.executeWorkItem(prepareWorkItemWithTaskVariables("Comment for task ${task.description}"), manager);
  final List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
  assertEquals(1, tasks.size());
  final Task task = taskService.getTaskById(tasks.get(0).getId());
  testTaskWithExpectedDescription(task, task.getDescription());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
  final String actualOwner = (String) manager.getResults().get("ActorId");
  assertNotNull(actualOwner);
  assertEquals("Darth Vader", actualOwner);
}

代码示例来源:origin: kiegroup/jbpm

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

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskAbortNotSkippable() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setParameter("Skippable", "false");
  workItem.setProcessInstanceId(10);
  getHandler().executeWorkItem(workItem, manager);
  
  List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
  assertEquals(1, tasks.size());
  getHandler().abortWorkItem(workItem, manager);
  // aborting work item will exit task and not skip it
  tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
  assertEquals(0, tasks.size());
}
@Test

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskExit() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setProcessInstanceId(10);
  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().intValue());
  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());
}
@Test

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskWithVariables() throws Exception {
  final TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  final String taskDescriptionParam =
      "Comment for task "
        + "${task.id} "
        + "${task.taskData.processSessionId} "
        + "${task.taskData.actualOwner.id} "
        + "${task.taskData.parentId}";
  handler.executeWorkItem(prepareWorkItemWithTaskVariables(taskDescriptionParam), manager);
  final List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
  assertEquals(1, tasks.size());
  final Task task = taskService.getTaskById(tasks.get(0).getId());
  testTaskWithExpectedDescription(task,
      "Comment for task "
          + task.getId() + " "
          + task.getTaskData().getProcessSessionId() + " "
          + task.getTaskData().getActualOwner().getId() + " "
          + task.getTaskData().getParentId());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
  
  final String actualOwner = (String) manager.getResults().get("ActorId");
  assertNotNull(actualOwner);
  assertEquals("Darth Vader", actualOwner);
  
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskExitByCustomBusinessAdmin() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setParameter("BusinessAdministratorId", "Luke Cage");
  workItem.setProcessInstanceId(10);
  getHandler().executeWorkItem(workItem, manager);
  
  Task task = taskService.getTaskByWorkItemId(workItem.getId());
  assertNotNull(task);
  
  getHandler().abortWorkItem(workItem, manager);
  
  task = taskService.getTaskByWorkItemId(workItem.getId());
  assertEquals("TaskName", task.getNames().get(0).getText());
  assertEquals(10, task.getPriority().intValue());
  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());
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskWithDisableAutoClaimTaskWithGroupOnly() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  env.set("Autoclaim", "false");
  ksession.setEnvironment(env);
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("GroupId", "Crusaders");
  workItem.setParameter("SwimlaneActorId", "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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Ready, task.getStatus());
  assertEquals(10, task.getProcessInstanceId().intValue());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskWithAutoClaimTaskWithGroupOnly() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("GroupId", "Crusaders");
  workItem.setParameter("SwimlaneActorId", "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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Reserved, task.getStatus());
  assertEquals("Darth Vader", task.getActualOwner().getId());
  assertEquals(10, task.getProcessInstanceId().intValue());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskSkip() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setProcessInstanceId(10);
  getHandler().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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Reserved, task.getStatus());
  assertEquals("Darth Vader", task.getActualOwner().getId());
  taskService.skip(task.getId(), "Darth Vader");
  
  assertTrue(manager.waitTillAborted(MANAGER_ABORT_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskWithDisableAutoClaimTaskWithActorAndGroup() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  env.set("Autoclaim", "false");
  ksession.setEnvironment(env);
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("GroupId", "Crusaders");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setParameter("SwimlaneActorId", "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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Ready, task.getStatus());
  assertEquals(10, task.getProcessInstanceId().intValue());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskWithAutoClaimTaskWithActorAndGroup() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("GroupId", "Crusaders");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setParameter("SwimlaneActorId", "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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Reserved, task.getStatus());
  assertEquals("Darth Vader", task.getActualOwner().getId());
  assertEquals(10, task.getProcessInstanceId().intValue());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskMultipleActors() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "Darth Vader, Dalai Lama");
  workItem.setProcessInstanceId(10);
  getHandler().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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Ready, task.getStatus());
  taskService.claim(task.getId(), "Darth Vader");
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskWithoutCreatedBy() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Reserved, task.getStatus());
  assertEquals("Darth Vader", task.getActualOwner().getId());
  assertEquals("Darth Vader", task.getCreatedBy().getId());
  assertEquals(10, task.getProcessInstanceId().intValue());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskWithEnableAutoClaimTaskWithGroupOnly() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  env.set("Autoclaim", "true");
  ksession.setEnvironment(env);
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("GroupId", "Crusaders");
  workItem.setParameter("SwimlaneActorId", "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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Reserved, task.getStatus());
  assertEquals("Darth Vader", task.getActualOwner().getId());
  assertEquals(10, task.getProcessInstanceId().intValue());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskWithCreatedBy() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setParameter("CreatedBy", "john");
  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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Reserved, task.getStatus());
  assertEquals("Darth Vader", task.getActualOwner().getId());
  assertEquals("john", task.getCreatedBy().getId());
  assertEquals(10, task.getProcessInstanceId().intValue());
  taskService.start(task.getId(), "Darth Vader");
  taskService.complete(task.getId(), "Darth Vader", null);
  assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskFail() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setProcessInstanceId(10);
  getHandler().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().intValue());
  assertEquals("Comment", task.getDescription());
  assertEquals(Status.Reserved, task.getStatus());
  assertEquals("Darth Vader", task.getActualOwner().getId());
  taskService.start(task.getId(), "Darth Vader");
  
  taskService.fail(task.getId(), "Darth Vader", null);
  
  assertTrue(manager.waitTillAborted(MANAGER_ABORT_WAIT_TIME));
}
@Test

代码示例来源:origin: kiegroup/jbpm

@SuppressWarnings("unchecked")
@Test
public void testTaskCreateFailedWithRethrow() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  TaskLifeCycleEventListener listener = new AddedTaskListener(true);
  ((EventService<TaskLifeCycleEventListener>) taskService).registerTaskEventListener(listener);
  
  ((AbstractHTWorkItemHandler)handler).setAction(OnErrorAction.RETHROW);
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "DoesNotExist");
  workItem.setProcessInstanceId(10);
  
  try {
    handler.executeWorkItem(workItem, manager);
    fail("Should fail due to OnErroAction set to rethrow");
  } catch (Exception e) {
    // do nothing
    
  }
  ((EventService<TaskLifeCycleEventListener>) taskService).removeTaskEventListener(listener);
}

代码示例来源:origin: kiegroup/jbpm

@SuppressWarnings("unchecked")
@Test
public void testTaskCreateFailedWithLog() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ((AbstractHTWorkItemHandler)handler).setAction(OnErrorAction.LOG);
  TaskLifeCycleEventListener listener = new AddedTaskListener(true);
  ((EventService<TaskLifeCycleEventListener>) taskService).registerTaskEventListener(listener);
  
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "DoesNotExist");
  workItem.setProcessInstanceId(10);
  
  
  handler.executeWorkItem(workItem, manager);
  assertFalse(manager.isAborted());
  ((EventService<TaskLifeCycleEventListener>) taskService).removeTaskEventListener(listener);
}
@SuppressWarnings("unchecked")

代码示例来源:origin: kiegroup/jbpm

@SuppressWarnings("unchecked")
@Test
public void testTaskCreateFailedWithAbort() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  TaskLifeCycleEventListener listener = new AddedTaskListener(true);
  ((EventService<TaskLifeCycleEventListener>) taskService).registerTaskEventListener(listener);
  
  ((AbstractHTWorkItemHandler)handler).setAction(OnErrorAction.ABORT);
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "DoesNotExist");
  workItem.setProcessInstanceId(10);
  
  
  handler.executeWorkItem(workItem, manager);
  assertTrue(manager.isAborted());
  ((EventService<TaskLifeCycleEventListener>) taskService).removeTaskEventListener(listener);
}
@SuppressWarnings("unchecked")

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com