我试图找到在Spring WebFlow上下文中单元测试决策状态的最佳方法。如何在Spring WebFlow中测试决策状态
<var name="registration" class="*some class path*.Registration"/>
<decision-state id="checkSignedIn">
<if test="*someClass*.isSignedOn(registration)"
then="checkHas*Said*Service"
else="registrationChoice"/>
</decision-state>
<decision-state id="checkHasTCloudService">
<if test="*someClass*Dao.isUserRegisteredFor*saidSvc*(registration)"
then="*svc*Activated"
else="registrationChoice"/>
</decision-state>
<view-state id="registrationChoice" model="registration" view="view.xhtml" >
<on-entry>...
N.B. someClass和someClassDao不在FlowScope或ConversationScope内。
我想通过Mockito测试决策状态表达式,然后验证正确的状态结果。
通常,一个可以简单地
- setCurrentState(someViewState:其中要在过渡流内槽试验)
- 定义输入
- 模拟一个的ExternalContext该上下文中
- SetEvent的
- resumeFlow(给定上下文)
- 验证模拟方法调用& fina LLY
- assertCurrentState(someViewState:在这里你会想到是在给定输入后,影响了决策状态叉,流内)
似乎决定国家不作为操作视图状态(足够公平:它们不是一个流中的给定状态),所以我们如何模拟/测试?
谢谢你的回应。