Пример #1
0
  @Test
  public void testHumanTaskFlow_shouldWorkWithGivenProcessBag() throws Exception {
    authenticateAsAdmin();
    addWorkflow("TaskDemoWorkflow");

    ProcessBag processBag = new ProcessBag();
    processBag.addProperty("test", "test");
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("processBag", processBag);

    assertThat(taskboxService.getOpenTasks().size(), is(0));

    workflowService.startFlow("TaskDemoWorkflow", parameterMap);
    System.out.println("workflow started, getting processId");
    assertNotNull(processBag.getProcessId());
    System.out.println("got processId");
    assertThat(taskboxService.getOpenTasks().size(), is(1));
    System.out.println("opentasks is 1");

    Task task = taskboxService.getOpenTasks().get(0);
    System.out.println("got task");
    assertEquals(task.getProcessId(), processBag.getProcessId());
    assertEquals(task.getProperty("test"), "test");
    assertEquals(task.getTaskType(), "demo");
    assertNotNull(task.getTaskId());
    System.out.println("task correct, finishing");
    taskboxService.finishTask(task);
    assertTrue(taskboxService.getOpenTasks().size() == 0);
  }
Пример #2
0
  @Test
  public void testHumanTaskFlow_shouldCreateOwnProcessBag() throws Exception {
    addWorkflow("TaskDemoWorkflow");

    assertThat(taskboxService.getOpenTasks().size(), is(0));

    authenticateAsAdmin();
    workflowService.startFlow("TaskDemoWorkflow");
    assertThat(taskboxService.getOpenTasks().size(), is(1));

    Task task = taskboxService.getOpenTasks().get(0);
    assertNotNull(task.getProcessId());
    assertNotNull(task.getTaskId());

    taskboxService.finishTask(task);
    assertThat(taskboxService.getOpenTasks().size(), is(0));
  }
Пример #3
0
  @Test
  public void testCompleteWorkflow_humanInteractionShouldReplaceValues() throws Exception {
    addWorkflow("HIDemoWorkflow");
    authenticateAsAdmin();
    workflowService.startFlow("HIDemoWorkflow");
    Task task = taskboxService.getOpenTasks().get(0);
    Date date = new Date();
    task.addOrReplaceProperty("test", date);
    assertEquals("step1", task.getTaskType());

    task.setName("test");
    taskboxService.updateTask(task);
    task = taskboxService.getOpenTasks().get(0);
    assertEquals("test", task.getName());

    taskboxService.finishTask(task);

    task = taskboxService.getOpenTasks().get(0);
    assertEquals(date, task.getProperty("test"));
    assertEquals("step2", task.getTaskType());

    taskboxService.finishTask(task);
    assertThat(taskboxService.getOpenTasks().size(), is(0));
  }
Пример #4
0
  @Test
  public void testHumanTaskFlow_shouldHandleMultipleTasks() throws Exception {
    addWorkflow("TaskDemoWorkflow");

    assertThat(taskboxService.getOpenTasks().size(), is(0));

    authenticateAsAdmin();

    long id = workflowService.startFlow("TaskDemoWorkflow");
    long id2 = workflowService.startFlow("TaskDemoWorkflow");

    assertThat(taskboxService.getOpenTasks().size(), is(2));

    assertEquals(taskboxService.getTasksForProcessId(String.valueOf(id)).size(), 1);
    assertEquals(taskboxService.getTasksForProcessId(String.valueOf(id2)).size(), 1);

    Task task1 = taskboxService.getTasksForProcessId(String.valueOf(id)).get(0);
    Task task2 = taskboxService.getTasksForProcessId(String.valueOf(id2)).get(0);

    taskboxService.finishTask(task1);
    assertThat(taskboxService.getOpenTasks().size(), is(1));
    assertEquals(taskboxService.getTasksForProcessId(String.valueOf(id)).size(), 0);
    assertEquals(taskboxService.getTasksForProcessId(String.valueOf(id2)).size(), 1);

    taskboxService.finishTask(task2);
    assertThat(taskboxService.getOpenTasks().size(), is(0));
    assertEquals(taskboxService.getTasksForProcessId(String.valueOf(id2)).size(), 0);
  }