コード例 #1
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());
  }
コード例 #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());
  }