这不明显,但我想到了这个:
public void testFoo() {
FlowExecution flowExecution = getFlowExecutionFactory().createFlowExecution(getFlowDefinition());
updateFlowExecution(flowExecution);
flowExecution.getConversationScope().put("fooBar", "goo");
flowExecution.start(null, new MockExternalContext());
assertCurrentStateEquals("fooView");
}
AbstractXmlFlowExecutionTests.startFlow()
查看它是如何实例化
FlowExecution
,并将其中的一部分复制并粘贴到单元测试中。
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<action-state id="decideFoo">
<evaluate expression="conversationScope.fooBar" />
<transition on="goo" to="fooView" />
<transition on="gar" to="barView" />
</action-state>
<view-state id="fooView" />
<view-state id="barView" />
</flow>