Question

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

I've used the solution listed in that question to solve a conversationScope issue, but have been hitting a wall trying to do the same for FlowScope. For some reason, FlowExecution does not have a getFlowScope() method.

Any helps or general pointing in the right direction will be very much appreciated. Thanks!

Update:

To give more context, this is the line in the webflow I'm trying to test:

<evaluate expression="serviceFactory.getInstance(flowScope.config.country).startTransaction(flowScope.SomeList.get(0), 0)" />

and the relavant test statement is:

EasyMock.expect(serviceObjectMock.startTransaction(someObjectMock, 0)).andReturn(true);

and it fails silently. When I walk through the code in the debugger, I see that there was an IndexOutOfBoundsException on this call, which led to my assumption that I have to have the list somehow in flowScope.

Was it helpful?

Solution 2

For anybody who's interested, I learnt that I did not have to explicitly set the attribute in the flowScope, as EasyMock handles that while it goes through the list of "expects".

My problem was that "flowScope.SomeList.get(0)" refers to an attribute that was set in the previous line, and I used "new ArrayList()" as a return value in the "expect" statement for that line.

And also, the "failing silently" part was due to me not enabling DEBUG level info in the test profile for Spring.

This in the test log4j.xml file solved the problem:

    <logger name="org.springframework">
    <level value="DEBUG" />
</logger>

OTHER TIPS

in FlowExecution, you can use getActiveSession().getScope()
that will give you the FlowScope where you can then put your attributes (after the flow started)

What you are trying to do doesn't really make sense because Flow scoped attributes exist for the life of the active flow session. You cannot set them before the flow starts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top