@Deployment(
      resources = {
        "org/activiti/examples/bpmn/event/timer/BoundaryTimerEventTest.testInterruptingTimerDuration.bpmn"
      })
  @Test
  public void testInterruptingTimerDuration() {

    // Start process instance
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("escalationExample");

    // There should be one task, with a timer : first line support
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("First line support", task.getName());

    // Manually execute the job
    ManagementService managementService = activitiRule.getManagementService();
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());

    // The timer has fired, and the second task (secondlinesupport) now exists
    task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Second line support", task.getName());
  }
Exemple #2
0
  @Test
  @Deployment(resources = {PROCESS_RESOURCE})
  public void processRejected() throws InterruptedException {
    Map<String, Object> procVars = createStartFormVariables();

    ProcessInstance pi =
        activitiRule
            .getProcessEngine()
            .getRuntimeService()
            .startProcessInstanceByKey(PROCESS_KEY, procVars);

    //		assertNotNull(pi);

    Task task = activitiRule.getTaskService().createTaskQuery().singleResult();
    //		assertNotNull(task);

    Map<String, Object> taskVars = new HashMap<String, Object>();
    taskVars.put("decide", "reject");
    activitiRule.getProcessEngine().getTaskService().complete(task.getId(), taskVars);

    HistoryService historyService = activitiRule.getHistoryService();

    HistoricProcessInstance historicProcessInstance =
        historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceId(pi.getProcessInstanceId())
            .singleResult();

    //		assertNotNull(historicProcessInstance);
    // check that only one process running
    //		assertEquals(pi.getProcessInstanceId(), historicProcessInstance.getId());

    List<HistoricActivityInstance> activityList =
        historyService
            .createHistoricActivityInstanceQuery()
            .processInstanceId(pi.getProcessInstanceId())
            .list();

    JobQuery jquery = activitiRule.getManagementService().createJobQuery();

    // check how many tasks must be done
    //		assertEquals("done task count", 6, activityList.size());

    // and the job is done
    //		assertEquals("job is done", 0, jquery.count());

    //		assertEquals(0, activitiRule.getProcessEngine().getRuntimeService()
    //				.createProcessInstanceQuery().count());

  }