Package org.springframework.webflow.test
Class MockFlowExecutionContext
java.lang.Object
org.springframework.webflow.test.MockFlowExecutionContext
- All Implemented Interfaces:
FlowExecutionContext
A stub implementation of the flow execution context interface.
- Author:
- Keith Donald
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates a new mock flow execution context -- automatically installs a root flow definition and active flow session.MockFlowExecutionContext
(Flow flow) Creates a new mock flow execution context for the specified root flow definition.MockFlowExecutionContext
(FlowSession flowSession) Creates a new mock flow execution context for the specified active flow session. -
Method Summary
Modifier and TypeMethodDescriptionReturns the active flow session of this flow execution.Returns the mutable execution attribute map.Returns runtime execution attributes that may influence the behavior of flow artifacts, such as states and actions.Returns a mutable map for data held in "conversation scope".Returns the root flow definition associated with this executing flow.Returns a mutable map for data held in "flash scope".getKey()
Returns the key assigned to this flow execution.Returns the mock active flow session.Returns the outcome reached by this execution, or null if this execution has not yet ended.boolean
hasEnded()
Returns a flag indicating if this execution has ended.boolean
Returns a flag indicating if this execution has been started.boolean
isActive()
Is the flow execution active? A flow execution is active once it has anactive session
and remains active until it has ended.void
putAttribute
(String attributeName, Object attributeValue) Puts a execution attribute into the context.void
setActiveSession
(FlowSession activeSession) Sets the mock session to be the active session.void
Sets the flow execution conversation scope.void
setFlashScope
(MutableAttributeMap<Object> scope) Sets the flow execution flash scope.void
setFlow
(FlowDefinition rootFlow) Sets the top-level flow definition.void
setKey
(FlowExecutionKey key) Sets the flow execution keyvoid
setOutcome
(FlowExecutionOutcome outcome) Sets the result of this flow ending.
-
Constructor Details
-
MockFlowExecutionContext
public MockFlowExecutionContext()Creates a new mock flow execution context -- automatically installs a root flow definition and active flow session. -
MockFlowExecutionContext
Creates a new mock flow execution context for the specified root flow definition. -
MockFlowExecutionContext
Creates a new mock flow execution context for the specified active flow session.
-
-
Method Details
-
getKey
Description copied from interface:FlowExecutionContext
Returns the key assigned to this flow execution. The flow execution key is the flow execution's persistent identity.- Specified by:
getKey
in interfaceFlowExecutionContext
- Returns:
- the flow execution key; may be
null
if a key has not yet been assigned.
-
getCaption
-
getDefinition
Description copied from interface:FlowExecutionContext
Returns the root flow definition associated with this executing flow.A call to this method always returns the same flow definition -- the top-level "root" -- no matter what flow may actually be active (for example, if subflows have been spawned).
- Specified by:
getDefinition
in interfaceFlowExecutionContext
- Returns:
- the root flow definition
-
hasStarted
public boolean hasStarted()Description copied from interface:FlowExecutionContext
Returns a flag indicating if this execution has been started. A flow execution that has started and is active is currently in progress. A flow execution that has started and is not active has ended.- Specified by:
hasStarted
in interfaceFlowExecutionContext
- Returns:
- true if started, false if not started
- See Also:
-
isActive
public boolean isActive()Description copied from interface:FlowExecutionContext
Is the flow execution active? A flow execution is active once it has anactive session
and remains active until it has ended.- Specified by:
isActive
in interfaceFlowExecutionContext
- Returns:
- true if active, false if the flow execution has terminated or has not yet been started
-
hasEnded
public boolean hasEnded()Description copied from interface:FlowExecutionContext
Returns a flag indicating if this execution has ended. A flow execution that has ended has been started but is no longer active.- Specified by:
hasEnded
in interfaceFlowExecutionContext
- Returns:
- true if ended, false if not started or still active
- See Also:
-
getActiveSession
Description copied from interface:FlowExecutionContext
Returns the active flow session of this flow execution. The active flow session is the currently executing session. It may be the "root flow" session, or it may be a subflow session if this flow execution has spawned a subflow.- Specified by:
getActiveSession
in interfaceFlowExecutionContext
- Returns:
- the active flow session
- Throws:
IllegalStateException
- if this flow execution is not active- See Also:
-
getFlashScope
Description copied from interface:FlowExecutionContext
Returns a mutable map for data held in "flash scope". Attributes in this map are cleared out on the next view rendering. Flash attributes survive flow execution refresh operations.- Specified by:
getFlashScope
in interfaceFlowExecutionContext
- Returns:
- flash scope
-
getConversationScope
Description copied from interface:FlowExecutionContext
Returns a mutable map for data held in "conversation scope". Conversation scope is a data structure that exists for the life of this flow execution and is accessible to all flow sessions.- Specified by:
getConversationScope
in interfaceFlowExecutionContext
- Returns:
- conversation scope
-
getAttributes
Description copied from interface:FlowExecutionContext
Returns runtime execution attributes that may influence the behavior of flow artifacts, such as states and actions.- Specified by:
getAttributes
in interfaceFlowExecutionContext
- Returns:
- execution attributes
-
getOutcome
Description copied from interface:FlowExecutionContext
Returns the outcome reached by this execution, or null if this execution has not yet ended.- Specified by:
getOutcome
in interfaceFlowExecutionContext
- Returns:
- the outcome, or
null
if this execution has not yet ended
-
getDefinitionInternal
-
setFlow
Sets the top-level flow definition. -
setKey
Sets the flow execution key -
setActiveSession
Sets the mock session to be the active session. -
setFlashScope
Sets the flow execution flash scope. -
setConversationScope
Sets the flow execution conversation scope. -
setOutcome
Sets the result of this flow ending.- Parameters:
outcome
- the ended outcome
-
getMockActiveSession
Returns the mock active flow session. -
getAttributeMap
Returns the mutable execution attribute map.- Returns:
- the execution attribute map
-
putAttribute
Puts a execution attribute into the context.- Parameters:
attributeName
- the attribute nameattributeValue
- the attribute value
-