Spring Web Flow

org.springframework.webflow.test
Class MockFlowExecutionContext

java.lang.Object
  extended by org.springframework.webflow.test.MockFlowExecutionContext
All Implemented Interfaces:
FlowExecutionContext

public class MockFlowExecutionContext
extends java.lang.Object
implements FlowExecutionContext

A stub implementation of the flow execution context interface.

Author:
Keith Donald
See Also:
FlowExecutionContext

Constructor Summary
MockFlowExecutionContext()
          Creates 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
 FlowSession getActiveSession()
          Returns the active flow session of this flow execution.
 MutableAttributeMap<java.lang.Object> getAttributeMap()
          Returns the mutable execution attribute map.
 AttributeMap<java.lang.Object> getAttributes()
          Returns runtime execution attributes that may influence the behavior of flow artifacts, such as states and actions.
 java.lang.String getCaption()
           
 MutableAttributeMap<java.lang.Object> getConversationScope()
          Returns a mutable map for data held in "conversation scope".
 FlowDefinition getDefinition()
          Returns the root flow definition associated with this executing flow.
 Flow getDefinitionInternal()
           
 MutableAttributeMap<java.lang.Object> getFlashScope()
          Returns a mutable map for data held in "flash scope".
 FlowExecutionKey getKey()
          Returns the key assigned to this flow execution.
 MockFlowSession getMockActiveSession()
          Returns the mock active flow session.
 FlowExecutionOutcome getOutcome()
          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 hasStarted()
          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 an active session and remains active until it has ended.
 void putAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
          Puts a execution attribute into the context.
 void setActiveSession(FlowSession activeSession)
          Sets the mock session to be the active session.
 void setConversationScope(MutableAttributeMap<java.lang.Object> scope)
          Sets the flow execution conversation scope.
 void setFlashScope(MutableAttributeMap<java.lang.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 key
 void setOutcome(FlowExecutionOutcome outcome)
          Sets the result of this flow ending.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockFlowExecutionContext

public MockFlowExecutionContext()
Creates a new mock flow execution context -- automatically installs a root flow definition and active flow session.


MockFlowExecutionContext

public MockFlowExecutionContext(Flow flow)
Creates a new mock flow execution context for the specified root flow definition.


MockFlowExecutionContext

public MockFlowExecutionContext(FlowSession flowSession)
Creates a new mock flow execution context for the specified active flow session.

Method Detail

getKey

public FlowExecutionKey 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 interface FlowExecutionContext
Returns:
the flow execution key; may be null if a key has not yet been assigned.

getCaption

public java.lang.String getCaption()

getDefinition

public FlowDefinition 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 interface FlowExecutionContext
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 interface FlowExecutionContext
Returns:
true if started, false if not started
See Also:
FlowExecutionContext.isActive()

isActive

public boolean isActive()
Description copied from interface: FlowExecutionContext
Is the flow execution active? A flow execution is active once it has an active session and remains active until it has ended.

Specified by:
isActive in interface FlowExecutionContext
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 interface FlowExecutionContext
Returns:
true if ended, false if not started or still active
See Also:
FlowExecutionContext.hasStarted(), FlowExecutionContext.isActive()

getActiveSession

public FlowSession getActiveSession()
                             throws java.lang.IllegalStateException
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 interface FlowExecutionContext
Returns:
the active flow session
Throws:
java.lang.IllegalStateException - if this flow execution is not active
See Also:
FlowExecutionContext.isActive()

getFlashScope

public MutableAttributeMap<java.lang.Object> 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 interface FlowExecutionContext
Returns:
flash scope

getConversationScope

public MutableAttributeMap<java.lang.Object> 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 interface FlowExecutionContext
Returns:
conversation scope

getAttributes

public AttributeMap<java.lang.Object> 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 interface FlowExecutionContext
Returns:
execution attributes

getOutcome

public FlowExecutionOutcome 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 interface FlowExecutionContext
Returns:
the outcome, or null if this execution has not yet ended

getDefinitionInternal

public Flow getDefinitionInternal()

setFlow

public void setFlow(FlowDefinition rootFlow)
Sets the top-level flow definition.


setKey

public void setKey(FlowExecutionKey key)
Sets the flow execution key


setActiveSession

public void setActiveSession(FlowSession activeSession)
Sets the mock session to be the active session.


setFlashScope

public void setFlashScope(MutableAttributeMap<java.lang.Object> scope)
Sets the flow execution flash scope.


setConversationScope

public void setConversationScope(MutableAttributeMap<java.lang.Object> scope)
Sets the flow execution conversation scope.


setOutcome

public void setOutcome(FlowExecutionOutcome outcome)
Sets the result of this flow ending.

Parameters:
outcome - the ended outcome

getMockActiveSession

public MockFlowSession getMockActiveSession()
Returns the mock active flow session.


getAttributeMap

public MutableAttributeMap<java.lang.Object> getAttributeMap()
Returns the mutable execution attribute map.

Returns:
the execution attribute map

putAttribute

public void putAttribute(java.lang.String attributeName,
                         java.lang.Object attributeValue)
Puts a execution attribute into the context.

Parameters:
attributeName - the attribute name
attributeValue - the attribute value

Spring Web Flow