コード例 #1
0
  public void testDeleteBoundaryEventTest() throws Exception {
    ProcessDefinition process =
        ProcessBuilder.createProcess("boundaryTimer", "1.1")
            .addHuman(getLogin())
            .addHumanTask("step1", getLogin())
            .addTimerBoundaryEvent("In_a_minute", "5000")
            .addHumanTask("normal", getLogin())
            .addHumanTask("exception", getLogin())
            .addTransition("step1", "normal")
            .addExceptionTransition("step1", "In_a_minute", "exception")
            .done();

    BusinessArchive archive = getBusinessArchive(process);
    process = getManagementAPI().deploy(archive);
    final ProcessDefinitionUUID processUUID = process.getUUID();

    ProcessInstanceUUID instanceUUID = getRuntimeAPI().instantiateProcess(processUUID);
    Set<LightTaskInstance> tasks = getQueryRuntimeAPI().getLightTasks(instanceUUID);
    assertEquals(1, tasks.size());
    LightTaskInstance task = tasks.iterator().next();
    assertEquals("step1", task.getActivityName());
    executeTask(instanceUUID, "step1");

    getManagementAPI().deleteProcess(processUUID);
  }
コード例 #2
0
  public void testCancelAProcessUsingAStartTimerEvent() throws Exception {
    ProcessDefinition process =
        ProcessBuilder.createProcess("CancelitSTime", "1.0")
            .addHuman(getLogin())
            .addTimerTask("every_second", "${new Date(timerLastExecution + 100000)}")
            .addHumanTask("step1", getLogin())
            .addTransition("every_second", "step1")
            .done();

    process = getManagementAPI().deploy(getBusinessArchive(process));
    final ProcessDefinitionUUID processUUID = process.getUUID();

    ProcessInstanceUUID instanceUUID = getRuntimeAPI().instantiateProcess(processUUID);
    Set<LightActivityInstance> activities =
        getQueryRuntimeAPI().getLightActivityInstances(instanceUUID);
    assertEquals(2, activities.size());

    Set<LightTaskInstance> tasks = getQueryRuntimeAPI().getLightTasks(instanceUUID);
    assertEquals(1, tasks.size());
    LightTaskInstance task = tasks.iterator().next();
    assertEquals("step1", task.getActivityName());

    getRuntimeAPI().cancelProcessInstance(instanceUUID);
    assertEquals(
        InstanceState.CANCELLED,
        getQueryRuntimeAPI().getProcessInstance(instanceUUID).getInstanceState());
    getManagementAPI().deleteProcess(processUUID);
  }
コード例 #3
0
  public void testBoundaryEventTest() throws Exception {
    ProcessDefinition process =
        ProcessBuilder.createProcess("boundaryTimer", "1.0")
            .addHuman(getLogin())
            .addHumanTask("step1", getLogin())
            .addTimerBoundaryEvent("In_5_seconds", "5000")
            .addHumanTask("normal", getLogin())
            .addHumanTask("exception", getLogin())
            .addTransition("step1", "normal")
            .addExceptionTransition("step1", "In_5_seconds", "exception")
            .done();

    BusinessArchive archive = getBusinessArchive(process);
    process = getManagementAPI().deploy(archive);
    final ProcessDefinitionUUID processUUID = process.getUUID();

    ProcessInstanceUUID instanceUUID = getRuntimeAPI().instantiateProcess(processUUID);
    Set<LightTaskInstance> tasks = getQueryRuntimeAPI().getLightTasks(instanceUUID);
    assertEquals(1, tasks.size());
    LightTaskInstance task = tasks.iterator().next();
    assertEquals("step1", task.getActivityName());

    Thread.sleep(8000);
    tasks = getQueryRuntimeAPI().getLightTasks(instanceUUID);
    for (LightTaskInstance lightTaskInstance : tasks) {
      System.out.println(lightTaskInstance);
    }

    assertEquals(2, tasks.size());
    //    task = tasks.iterator().next();
    //    assertEquals("exception", task.getActivityName());

    getManagementAPI().deleteProcess(processUUID);
  }
コード例 #4
0
 @Override
 protected void executeConnector() throws Exception {
   final APIAccessor accessor = getApiAccessor();
   final QueryRuntimeAPI queryRuntimeAPI =
       accessor.getQueryRuntimeAPI(AccessorUtil.QUERYLIST_JOURNAL_KEY);
   final Set<LightActivityInstance> activities =
       queryRuntimeAPI.getLightActivityInstances(getProcessInstanceUUID(), taskName);
   LightTaskInstance task;
   if (activities.size() == 0) {
     // No step found.
     author = null;
   } else if (activities.size() == 1) {
     // Only one step has the given name.
     final LightActivityInstance lightActivityInstance = activities.iterator().next();
     if (lightActivityInstance.isTask()) {
       task = lightActivityInstance.getTask();
       author = task.getEndedBy();
     }
   } else {
     // More than one step have the same name.
     // This is possible in case of iterations.
     // Only consider the current iteration / the latest iteration.
     final List<LightTaskInstance> orderedActivities = new ArrayList<LightTaskInstance>();
     for (LightActivityInstance lightActivityInstance : activities) {
       if (lightActivityInstance.isTask()
           && lightActivityInstance.getTask().getEndedBy() != null) {
         orderedActivities.add(lightActivityInstance.getTask());
       }
     }
     Collections.sort(
         orderedActivities,
         new Comparator<LightTaskInstance>() {
           public int compare(LightTaskInstance o1, LightTaskInstance o2) {
             return o1.getEndedDate().compareTo(o2.getEndedDate());
           }
         });
     author = orderedActivities.iterator().next().getEndedBy();
   }
 }
コード例 #5
0
  public void testExecuteTimerBoundaryEventOnASubFlowUsingATimer2() throws Exception {
    ProcessDefinition subflow =
        ProcessBuilder.createProcess("sub", "atomic")
            .addHuman(getLogin())
            .addSystemTask("end")
            .addHumanTask("subStep", getLogin())
            .addTimerBoundaryEvent("In_a_second", "1000")
            .addExceptionTransition("subStep", "In_a_second", "end")
            .done();

    ProcessDefinition mainflow =
        ProcessBuilder.createProcess("main", "frame")
            .addHuman(getLogin())
            .addSubProcess("step1", "sub")
            .addTimerBoundaryEvent("In_5_seconds", "5000")
            .addHumanTask("normalStep", getLogin())
            .addHumanTask("exceptionStep", getLogin())
            .addTransition("step1", "normalStep")
            .addExceptionTransition("step1", "In_5_seconds", "exceptionStep")
            .done();

    subflow = getManagementAPI().deploy(getBusinessArchive(subflow));
    mainflow = getManagementAPI().deploy(getBusinessArchive(mainflow));

    final ProcessInstanceUUID instanceUUID = getRuntimeAPI().instantiateProcess(mainflow.getUUID());
    final ProcessInstanceUUID subflowInstanceUUID =
        getQueryRuntimeAPI()
            .getLightProcessInstances(subflow.getUUID())
            .iterator()
            .next()
            .getUUID();

    final Set<LightActivityInstance> parentActivities =
        getQueryRuntimeAPI().getLightActivityInstances(instanceUUID);
    assertEquals(1, parentActivities.size());
    LightActivityInstance activity = parentActivities.iterator().next();
    assertEquals("step1", activity.getActivityName());
    assertEquals(ActivityState.EXECUTING, activity.getState());

    final Set<LightActivityInstance> subflowActivities =
        getQueryRuntimeAPI().getLightActivityInstances(subflowInstanceUUID);
    assertEquals(1, subflowActivities.size());
    LightActivityInstance subActivity = subflowActivities.iterator().next();
    assertEquals("subStep", subActivity.getActivityName());
    assertEquals(ActivityState.READY, subActivity.getState());

    Thread.sleep(6000);
    Set<LightTaskInstance> tasks = getQueryRuntimeAPI().getLightTasks(instanceUUID);
    assertEquals(1, tasks.size());
    LightTaskInstance task = tasks.iterator().next();
    assertEquals("normalStep", task.getActivityName());

    assertEquals(
        0, getQueryRuntimeAPI().getLightTaskList(subflowInstanceUUID, ActivityState.READY).size());
    assertEquals(
        ActivityState.FINISHED,
        getQueryRuntimeAPI()
            .getLightActivityInstances(instanceUUID, "step1")
            .iterator()
            .next()
            .getState());
    assertEquals(
        InstanceState.FINISHED,
        getQueryRuntimeAPI().getLightProcessInstance(subflowInstanceUUID).getInstanceState());
    assertEquals(
        ActivityState.ABORTED,
        getQueryRuntimeAPI()
            .getLightActivityInstances(subflowInstanceUUID, "subStep")
            .iterator()
            .next()
            .getState());

    getManagementAPI().deleteProcess(mainflow.getUUID());
    getManagementAPI().deleteProcess(subflow.getUUID());
  }