⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subprocesstest.java

📁 一个java工作流引擎
💻 JAVA
字号:
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 SubProcessTest extends TestCase {
  
  public static TestHelper helper = new TestHelper();
  private ExecutionService executionService = helper.getExecutionService();
  
  static {
    helper.deployProcess( "process/superprocess.xml" );
    helper.deployProcess( "process/subprocess.xml" );
  }

  public void testSubProcessing() throws Exception {
    // retrieve the definition
    Definition definition = executionService.getLatestDefinition( "the super process" );
    
    // start a process instance
    Map variables = new HashMap();
    variables.put( "a", new Long(2) );
    variables.put( "b", new Long(3) );
    
    InvocationLog invocationLog = executionService.startProcessInstance( "testrunner", definition.getId(), variables );
    ProcessInstanceImpl pi = (ProcessInstanceImpl) invocationLog.getProcessInstance();
    
    Assembler assembler = new PropertyAssembler( "root.subProcessInstance.root" );
    executionService.getProcessInstance( pi.getId(), assembler );

    TokenImpl superRoot = (TokenImpl) pi.getRoot();
    assertNull( superRoot.getActorId() );
    assertEquals( "sub process state", superRoot.getState().getName() );
    assertEquals( new Long(2), superRoot.getVariable( "a" ) );
    assertEquals( new Long(3), superRoot.getVariable( "b" ) );
    assertNull( superRoot.getVariable( "s" ) );
    
    Token subProcessToken = pi.getRoot().getSubProcessInstance().getRoot();
    assertNotNull(subProcessToken);
    assertEquals( "testrunner", subProcessToken.getActorId() );
    assertEquals( "enter third term", subProcessToken.getState().getName() );
    
    variables = new HashMap();
    variables.put( "cc", new Long(33) );
    executionService.endOfState( "testrunner", subProcessToken.getId(), variables );

    assembler = new PropertyAssembler( "root.variables" );
    pi = (ProcessInstanceImpl) executionService.getProcessInstance( pi.getId(), assembler );
    superRoot = (TokenImpl) pi.getRoot();
    assertEquals( new Long(2), superRoot.getVariable( "a" ) );
    assertEquals( new Long(3), superRoot.getVariable( "b" ) );
    assertEquals( new Long(38), superRoot.getVariable( "s" ) );
  }
}

⌨️ 快捷键说明

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