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
ConstructorsConstructorDescriptionCreates 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.voidendActiveFlowSession(String outcome, MutableAttributeMap<Object> output) End the active flow session of the current flow execution.booleanexecute(Transition transition) Execute this transition out of the current source state.booleanReturns true if the flow current flow execution was launched in embedded page mode.booleanReturns the value of the 'redirect in same state' flow execution attribute if set or otherwise it falls back on the value returned byRequestControlContext.getRedirectOnPause().booleanReturns true if the 'redirect on pause' flow execution attribute is set to true, false otherwise.booleanhandleEvent(Event event) Signals the occurrence of an event in the current state of this flow execution request context.voidRemove all flow execution snapshots associated with the ongoing conversation.voidRemove the current flow execution snapshot to invalidate the current state.voidsetAlwaysRedirectOnPause(boolean alwaysRedirectOnPause) voidsetCurrentState(State state) Record the current state that has entered in the executing flow.voidvoidsetRedirectInSameState(boolean redirectInSameState) voidstart(Flow flow, MutableAttributeMap<?> input) Spawn a new flow session and activate it in the currently executing flow.voidUpdate the current flow execution snapshot to save the current state.voidviewRendered(View view) Called when the current view has completed rendering in the current view state.voidviewRendering(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, setFlowExecutionContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, inViewStateMethods 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:RequestControlContextRecord 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:
setCurrentStatein interfaceRequestControlContext- Parameters:
state- the current state- See Also:
-
assignFlowExecutionKey
Description copied from interface:RequestControlContextAssign 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:
assignFlowExecutionKeyin interfaceRequestControlContext
-
viewRendering
Description copied from interface:RequestControlContextCalled when the current view is about to be rendered in the current view state.- Specified by:
viewRenderingin interfaceRequestControlContext- Parameters:
view- the view to be rendered
-
viewRendered
Description copied from interface:RequestControlContextCalled when the current view has completed rendering in the current view state.- Specified by:
viewRenderedin interfaceRequestControlContext- Parameters:
view- the view that rendered
-
handleEvent
Description copied from interface:RequestControlContextSignals 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:
handleEventin 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:RequestControlContextExecute this transition out of the current source state. Allows for privileged execution of an arbitrary transition.- Specified by:
executein interfaceRequestControlContext- Parameters:
transition- the transition- See Also:
-
removeAllFlowExecutionSnapshots
public void removeAllFlowExecutionSnapshots()Description copied from interface:RequestControlContextRemove all flow execution snapshots associated with the ongoing conversation. Invalidates previous states.- Specified by:
removeAllFlowExecutionSnapshotsin interfaceRequestControlContext
-
removeCurrentFlowExecutionSnapshot
public void removeCurrentFlowExecutionSnapshot()Description copied from interface:RequestControlContextRemove the current flow execution snapshot to invalidate the current state.- Specified by:
removeCurrentFlowExecutionSnapshotin interfaceRequestControlContext
-
updateCurrentFlowExecutionSnapshot
public void updateCurrentFlowExecutionSnapshot()Description copied from interface:RequestControlContextUpdate the current flow execution snapshot to save the current state.- Specified by:
updateCurrentFlowExecutionSnapshotin interfaceRequestControlContext
-
start
Description copied from interface:RequestControlContextSpawn 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:
startin 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:RequestControlContextEnd 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:
endActiveFlowSessionin 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:RequestControlContextReturns true if the 'redirect on pause' flow execution attribute is set to true, false otherwise.- Specified by:
getRedirectOnPausein interfaceRequestControlContext- Returns:
- true or false
-
getRedirectInSameState
public boolean getRedirectInSameState()Description copied from interface:RequestControlContextReturns 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:
getRedirectInSameStatein interfaceRequestControlContext- Returns:
- true or false
-
getEmbeddedMode
public boolean getEmbeddedMode()Description copied from interface:RequestControlContextReturns 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:
getEmbeddedModein interfaceRequestControlContext
-
setAlwaysRedirectOnPause
public void setAlwaysRedirectOnPause(boolean alwaysRedirectOnPause) -
setRedirectInSameState
public void setRedirectInSameState(boolean redirectInSameState) -
setEmbeddedMode
public void setEmbeddedMode()
-