Package org.springframework.webflow.test
Class MockRequestControlContext
java.lang.Object
org.springframework.webflow.test.MockRequestContext
org.springframework.webflow.test.MockRequestControlContext
- All Implemented Interfaces:
RequestControlContext
,RequestContext
Mock implementation of the
RequestControlContext
interface to facilitate standalone Flow and State unit
tests.- Author:
- Keith Donald
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates a new mock request control context.Creates a new mock request control context for controlling a mock execution of the provided flow definition.MockRequestControlContext
(FlowExecutionContext flowExecutionContext) Creates a new mock request control context for controlling a flow execution. -
Method Summary
Modifier and TypeMethodDescriptionAssign the ongoing flow execution its flow execution key.void
endActiveFlowSession
(String outcome, MutableAttributeMap<Object> output) End the active flow session of the current flow execution.boolean
execute
(Transition transition) Execute this transition out of the current source state.boolean
Returns true if the flow current flow execution was launched in embedded page mode.boolean
Returns the value of the 'redirect in same state' flow execution attribute if set or otherwise it falls back on the value returned byRequestControlContext.getRedirectOnPause()
.boolean
Returns true if the 'redirect on pause' flow execution attribute is set to true, false otherwise.boolean
handleEvent
(Event event) Signals the occurrence of an event in the current state of this flow execution request context.void
Remove all flow execution snapshots associated with the ongoing conversation.void
Remove the current flow execution snapshot to invalidate the current state.void
setAlwaysRedirectOnPause
(boolean alwaysRedirectOnPause) void
setCurrentState
(State state) Record the current state that has entered in the executing flow.void
void
setRedirectInSameState
(boolean redirectInSameState) void
start
(Flow flow, MutableAttributeMap<?> input) Spawn a new flow session and activate it in the currently executing flow.void
Update the current flow execution snapshot to save the current state.void
viewRendered
(View view) Called when the current view has completed rendering in the current view state.void
viewRendering
(View view) Called when the current view is about to be rendered in the current view state.Methods inherited from class org.springframework.webflow.test.MockRequestContext
getActiveFlow, getAttributeMap, getAttributes, getConversationScope, getCurrentEvent, getCurrentState, getCurrentTransition, getCurrentView, getExternalContext, getFlashScope, getFlowExecutionContext, getFlowExecutionUrl, getFlowScope, getMatchingTransition, getMessageContext, getMockExternalContext, getMockFlowExecutionContext, getRequestParameters, getRequestScope, getRootFlow, getViewScope, inViewState, putRequestParameter, putRequestParameter, putRequestParameter, putRequestParameter, removeAttribute, sendFlowExecutionRedirect, setActiveSession, setAttribute, setCurrentEvent, setCurrentTransition, setCurrentView, setExternalContext, setFlowExecutionContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.webflow.execution.RequestContext
getActiveFlow, getAttributes, getConversationScope, getCurrentEvent, getCurrentState, getCurrentTransition, getCurrentView, getExternalContext, getFlashScope, getFlowExecutionContext, getFlowExecutionUrl, getFlowScope, getMatchingTransition, getMessageContext, getRequestParameters, getRequestScope, getViewScope, inViewState
Methods inherited from interface org.springframework.webflow.engine.RequestControlContext
setCurrentTransition, setCurrentView
-
Constructor Details
-
MockRequestControlContext
public MockRequestControlContext()Creates a new mock request control context. -
MockRequestControlContext
Creates a new mock request control context for controlling a mock execution of the provided flow definition.- Parameters:
flow
- the flow definition
-
MockRequestControlContext
Creates a new mock request control context for controlling a flow execution.- Parameters:
flowExecutionContext
- the flow execution context
-
-
Method Details
-
setCurrentState
Description copied from interface:RequestControlContext
Record the current state that has entered in the executing flow. This method will be called as part of entering a new state by the State type itself.- Specified by:
setCurrentState
in interfaceRequestControlContext
- Parameters:
state
- the current state- See Also:
-
assignFlowExecutionKey
Description copied from interface:RequestControlContext
Assign the ongoing flow execution its flow execution key. This method will be called before a state is about to render a view and pause the flow execution.- Specified by:
assignFlowExecutionKey
in interfaceRequestControlContext
-
viewRendering
Description copied from interface:RequestControlContext
Called when the current view is about to be rendered in the current view state.- Specified by:
viewRendering
in interfaceRequestControlContext
- Parameters:
view
- the view to be rendered
-
viewRendered
Description copied from interface:RequestControlContext
Called when the current view has completed rendering in the current view state.- Specified by:
viewRendered
in interfaceRequestControlContext
- Parameters:
view
- the view that rendered
-
handleEvent
Description copied from interface:RequestControlContext
Signals the occurrence of an event in the current state of this flow execution request context. This method should be called by clients that report internal event occurrences, such as action states. TheonEvent()
method of the flow involved in the flow execution will be called.- Specified by:
handleEvent
in interfaceRequestControlContext
- Parameters:
event
- the event that occurred- Returns:
- a boolean indicating if handling this event caused the current state to exit and a new state to enter
- See Also:
-
execute
Description copied from interface:RequestControlContext
Execute this transition out of the current source state. Allows for privileged execution of an arbitrary transition.- Specified by:
execute
in interfaceRequestControlContext
- Parameters:
transition
- the transition- See Also:
-
removeAllFlowExecutionSnapshots
public void removeAllFlowExecutionSnapshots()Description copied from interface:RequestControlContext
Remove all flow execution snapshots associated with the ongoing conversation. Invalidates previous states.- Specified by:
removeAllFlowExecutionSnapshots
in interfaceRequestControlContext
-
removeCurrentFlowExecutionSnapshot
public void removeCurrentFlowExecutionSnapshot()Description copied from interface:RequestControlContext
Remove the current flow execution snapshot to invalidate the current state.- Specified by:
removeCurrentFlowExecutionSnapshot
in interfaceRequestControlContext
-
updateCurrentFlowExecutionSnapshot
public void updateCurrentFlowExecutionSnapshot()Description copied from interface:RequestControlContext
Update the current flow execution snapshot to save the current state.- Specified by:
updateCurrentFlowExecutionSnapshot
in interfaceRequestControlContext
-
start
Description copied from interface:RequestControlContext
Spawn a new flow session and activate it in the currently executing flow. Also transitions the spawned flow to its start state. This method should be called by clients that wish to spawn new flows, such as subflow states.This will start a new flow session in the current flow execution, which is already active.
- Specified by:
start
in interfaceRequestControlContext
- Parameters:
flow
- the flow to start, itsstart()
method will be calledinput
- initial contents of the newly created flow session (may benull
, e.g. empty)- Throws:
IllegalStateException
- See Also:
-
endActiveFlowSession
public void endActiveFlowSession(String outcome, MutableAttributeMap<Object> output) throws IllegalStateException Description copied from interface:RequestControlContext
End the active flow session of the current flow execution. This method should be called by clients that terminate flows, such as end states. Theend()
method of the flow involved in the flow execution will be called.- Specified by:
endActiveFlowSession
in interfaceRequestControlContext
- Parameters:
outcome
- the logical outcome the ending session should returnoutput
- output the ending session should return- Throws:
IllegalStateException
- when the flow execution is not active- See Also:
-
getRedirectOnPause
public boolean getRedirectOnPause()Description copied from interface:RequestControlContext
Returns true if the 'redirect on pause' flow execution attribute is set to true, false otherwise.- Specified by:
getRedirectOnPause
in interfaceRequestControlContext
- Returns:
- true or false
-
getRedirectInSameState
public boolean getRedirectInSameState()Description copied from interface:RequestControlContext
Returns the value of the 'redirect in same state' flow execution attribute if set or otherwise it falls back on the value returned byRequestControlContext.getRedirectOnPause()
.- Specified by:
getRedirectInSameState
in interfaceRequestControlContext
- Returns:
- true or false
-
getEmbeddedMode
public boolean getEmbeddedMode()Description copied from interface:RequestControlContext
Returns true if the flow current flow execution was launched in embedded page mode. When a flow is embedded on a page it can make different assumptions with regards to whether redirect after post is necessary.- Specified by:
getEmbeddedMode
in interfaceRequestControlContext
-
setAlwaysRedirectOnPause
public void setAlwaysRedirectOnPause(boolean alwaysRedirectOnPause) -
setRedirectInSameState
public void setRedirectInSameState(boolean redirectInSameState) -
setEmbeddedMode
public void setEmbeddedMode()
-