Spring Web Flow - How can I set up unit test with values already in conversationScope?

后端 未结 1 1370
南旧
南旧 2021-02-10 01:09

I am working on a project using Spring Web Flow 2.0.

I am trying to unit test a flow that begins with a decision state. The decision state checks the value of an object

1条回答
  •  无人共我
    2021-02-10 01:39

    It's not obvious, but I came up with this:

    public void testFoo() {
        FlowExecution flowExecution = getFlowExecutionFactory().createFlowExecution(getFlowDefinition());
        updateFlowExecution(flowExecution);
        flowExecution.getConversationScope().put("fooBar", "goo");
        flowExecution.start(null, new MockExternalContext());        
        assertCurrentStateEquals("fooView");
    }
    

    I had to dig into the underlying AbstractXmlFlowExecutionTests.startFlow() to see how it was instantiating the FlowExecution, and copy and paste some of that into the unit test.

    Here's the test web flow.

    
    
    
        
            
            
            
        
    
        
    
        
    
    
    

    0 讨论(0)
提交回复
热议问题