📄 forkhandlerstest.java
字号:
package org.jbpm.delegation.fork;
import java.util.*;
import org.jbpm.*;
import org.jbpm.delegation.*;
import org.jbpm.util.log.*;
import org.jbpm.model.definition.*;
import org.jbpm.model.definition.impl.*;
import org.jbpm.model.execution.*;
import org.jbpm.model.execution.impl.*;
import junit.framework.*;
public class ForkHandlersTest extends TestCase {
private static NodeImpl nodeWithTirtheenTransitions = null;
static {
TestHelper.initLogging();
nodeWithTirtheenTransitions = new ForkImpl();
for ( int i = 0; i < 13; i++ ) {
nodeWithTirtheenTransitions.addLeavingTransition( new TransitionImpl() );
}
}
private static class TestForkContext implements ForkContext {
public Map forkedTransitions = new HashMap();
public Token createToken(Transition transition, String tokenName) throws ExecutionException {
forkedTransitions.put( tokenName, transition );
return new TokenImpl();
}
public Type findTypeByJavaType(String javaType) {return null;}
public Type findTypeByObject(Object value) {return null;}
public Type findTypeByVariableName(String variableName) {return null;}
public void createLocalVariable(Token token, String variableName, Type type, Object value) {}
public Definition getDefinition() {return null;}
public ProcessInstance getProcessInstance() {return null;}
public Token getToken() {
TokenImpl token = new TokenImpl();
token.setChildren( new HashMap() );
return token;
}
public Node getNode() {
return nodeWithTirtheenTransitions;
}
public Object getVariable(String name) {return null;}
public void setVariable(String name, Object value) {}
public void log(String msg) {}
public void log(Level level, String msg) {}
public void cancelEvent(String reference) {}
public SchedulerService getSchedulerService() {return null;}
public ExecutionService getExecutionService() {
return null;
}
}
public void testDefaultForkHandler() throws ExecutionException {
DefaultForkHandler defaultForkHandler = new DefaultForkHandler();
TestForkContext forkContext = new TestForkContext() ;
defaultForkHandler.fork( forkContext );
// transitions should now be a map from default generated token-names to the transitions of the node
Set expectedTokenNames = new HashSet( Arrays.asList( new Object[]{
"first",
"second",
"third",
"fourth",
"fifth",
"sixth",
"seventh",
"eight",
"nineth",
"tenth",
"11",
"12",
"13"
} ) );
assertEquals( expectedTokenNames, new HashSet( forkContext.forkedTransitions.keySet() ) );
assertEquals( new HashSet( nodeWithTirtheenTransitions.getLeavingTransitions() ), new HashSet( forkContext.forkedTransitions.values() ) );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -