Class MockFlowExecutionContext

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

public class MockFlowExecutionContext extends Object implements FlowExecutionContext
A stub implementation of the flow execution context interface.
Author:
Keith Donald
See Also:
  • Constructor Details

    • 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 Details

    • 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 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:
    • 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:
    • getActiveSession

      public FlowSession getActiveSession() throws 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:
      IllegalStateException - if this flow execution is not active
      See Also:
    • getFlashScope

      public MutableAttributeMap<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<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<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<Object> scope)
      Sets the flow execution flash scope.
    • setConversationScope

      public void setConversationScope(MutableAttributeMap<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<Object> getAttributeMap()
      Returns the mutable execution attribute map.
      Returns:
      the execution attribute map
    • putAttribute

      public void putAttribute(String attributeName, Object attributeValue)
      Puts a execution attribute into the context.
      Parameters:
      attributeName - the attribute name
      attributeValue - the attribute value