forkinlooptest.java

来自「一个java工作流引擎」· Java 代码 · 共 44 行

JAVA
44
字号
package org.jbpm.service;

import java.util.*;
import junit.framework.*;
import org.jbpm.*;
import org.jbpm.model.definition.*;
import org.jbpm.model.execution.*;
import org.jbpm.model.execution.impl.*;
import org.jbpm.model.log.*;

public class ForkInLoopTest extends TestCase {
  
  public static TestHelper helper = new TestHelper();
  private ExecutionService executionService = helper.getExecutionService();
  
  static {
    helper.deployProcess( "process/forkinloopprocess.xml" );
  }
  
  public void testForkInLoop() throws Exception {
    // retrieve the definition
    Definition definition = executionService.getLatestDefinition( "the fork-in-loop process" );
    
    Collection tasks = executionService.getTaskList( "testrunner", null );
    int origTaskListSize = tasks.size();

    // start a process instance
    InvocationLog invocationLog = executionService.startProcessInstance( "testrunner", definition.getId() );
    ProcessInstanceImpl pi = (ProcessInstanceImpl) invocationLog.getProcessInstance();
    
    tasks = executionService.getTaskList( "testrunner", null );
    assertEquals( origTaskListSize+1, tasks.size() );

    for ( int i = 0; i < 15; i++ ) {
      Token token = (Token) tasks.iterator().next();
      if ( token.getProcessInstance() == pi ) {
        executionService.endOfState( "testrunner", token.getId() );
        tasks = executionService.getTaskList( "testrunner", null );
        assertEquals( origTaskListSize+1, tasks.size() );
      }
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?