public class MockRequestContext extends java.lang.Object implements RequestContext
RequestContext interface to facilitate standalone flow artifact (e.g. action)
unit tests.RequestContext,
Action| Constructor and Description |
|---|
MockRequestContext()
Convenience constructor that creates a new mock request context with the following defaults:
A mock flow execution context with a active session of flow "mockFlow" in state "mockState".
|
MockRequestContext(Flow flow)
Convenience constructor that creates a new mock request context with the following defaults:
A mock flow execution context with an active session for the specified flow.
|
MockRequestContext(FlowExecutionContext flowExecutionContext)
Creates a new mock request context with the provided flow execution context.
|
MockRequestContext(ParameterMap requestParameterMap)
Convenience constructor that creates a new mock request context with the following defaults:
A mock flow execution context with a active session of flow "mockFlow" in state "mockState".
|
| Modifier and Type | Method and Description |
|---|---|
FlowDefinition |
getActiveFlow()
Returns the definition of the flow that is currently executing.
|
MutableAttributeMap<java.lang.Object> |
getAttributeMap()
Returns the contained mutable context
attribute map allowing setting of mock context
attributes. |
MutableAttributeMap<java.lang.Object> |
getAttributes()
Returns a context map for accessing attributes about the state of the current request.
|
MutableAttributeMap<java.lang.Object> |
getConversationScope()
Returns a mutable accessor for accessing and/or setting attributes in conversation scope.
|
Event |
getCurrentEvent()
Returns the current event being processed by this flow.
|
StateDefinition |
getCurrentState()
Returns the current state of the executing flow.
|
TransitionDefinition |
getCurrentTransition()
Returns the current transition executing in this request.
|
View |
getCurrentView()
Returns the current view in use; if not null, the view returned is about to be rendered, is rendering, is
processing a user event, or has finished user event processing and the current ViewState is exiting due to a
state transition.
|
ExternalContext |
getExternalContext()
Returns the external client context that originated (or triggered) this request.
|
MutableAttributeMap<java.lang.Object> |
getFlashScope()
Returns a mutable map for accessing and/or setting attributes in flash scope.
|
FlowExecutionContext |
getFlowExecutionContext()
Returns contextual information about the flow execution itself.
|
java.lang.String |
getFlowExecutionUrl()
Returns the URL of this flow execution.
|
MutableAttributeMap<java.lang.Object> |
getFlowScope()
Returns a mutable map for accessing and/or setting attributes in flow scope.
|
TransitionDefinition |
getMatchingTransition(java.lang.String eventId)
Returns the transition that would execute on the occurrence of the given event.
|
MessageContext |
getMessageContext()
Returns the message context of this request.
|
MockExternalContext |
getMockExternalContext()
Returns the external context as a
MockExternalContext. |
MockFlowExecutionContext |
getMockFlowExecutionContext()
Returns the flow execution context as a
MockFlowExecutionContext. |
ParameterMap |
getRequestParameters()
Returns the immutable input parameters associated with this request into Spring Web Flow.
|
MutableAttributeMap<java.lang.Object> |
getRequestScope()
Returns a mutable map for accessing and/or setting attributes in request scope.
|
Flow |
getRootFlow()
Returns the root flow definition for this request context.
|
MutableAttributeMap<java.lang.Object> |
getViewScope()
Returns a mutable map for accessing and/or setting attributes in view scope.
|
boolean |
inViewState()
Returns true if the flow is currently active and in a view state.
|
void |
putRequestParameter(java.lang.String parameterName,
java.util.List<org.springframework.web.multipart.MultipartFile> parameterValue)
Puts a multi-valued MultipartFile request parameter into the mock parameter map.
|
void |
putRequestParameter(java.lang.String parameterName,
org.springframework.web.multipart.MultipartFile parameterValue)
Puts a MultipartFile request parameter into the mock parameter map.
|
void |
putRequestParameter(java.lang.String parameterName,
java.lang.String parameterValue)
Adds a request parameter to the configured external context.
|
void |
putRequestParameter(java.lang.String parameterName,
java.lang.String[] parameterValues)
Adds a multi-valued request parameter to the configured external context.
|
void |
removeAttribute(java.lang.String attributeName)
Remove a request context attribute.
|
void |
sendFlowExecutionRedirect() |
void |
setActiveSession(FlowSession flowSession)
Sets the active flow session of the executing flow associated with this request.
|
void |
setAttribute(java.lang.String attributeName,
java.lang.Object attributeValue)
Set a request context attribute.
|
void |
setCurrentEvent(Event event)
Set the current event being processed by this flow.
|
void |
setCurrentTransition(Transition transition)
Set the current transition executing in this request context.
|
void |
setCurrentView(View currentView)
Set the current view in this request context.
|
void |
setExternalContext(ExternalContext externalContext)
Sets the external context.
|
void |
setFlowExecutionContext(FlowExecutionContext flowExecutionContext)
Sets the flow execution context.
|
public MockRequestContext()
putRequestParameter(String, String) method.public MockRequestContext(Flow flow)
putRequestParameter(String, String) method.flow - the flow definitionpublic MockRequestContext(ParameterMap requestParameterMap)
public MockRequestContext(FlowExecutionContext flowExecutionContext)
putRequestParameter(String, String) method.flowExecutionContext - the flow execution contextpublic FlowDefinition getActiveFlow()
RequestContextgetActiveFlow in interface RequestContextFlowExecutionContext.isActive()public StateDefinition getCurrentState()
RequestContextnull if the active flow's start state has
not yet been entered.getCurrentState in interface RequestContextnull if in the process of startingFlowExecutionContext.isActive()public TransitionDefinition getMatchingTransition(java.lang.String eventId) throws java.lang.IllegalStateException
RequestContextgetMatchingTransition in interface RequestContexteventId - the id of the user eventnull if no transition matchesjava.lang.IllegalStateException - if this flow execution is not activeFlowExecutionContext.isActive()public boolean inViewState()
RequestContextRequestContext.getViewScope(),
can be safely called.inViewState in interface RequestContextRequestContext.getViewScope()public MutableAttributeMap<java.lang.Object> getRequestScope()
RequestContextgetRequestScope in interface RequestContextpublic MutableAttributeMap<java.lang.Object> getFlashScope()
RequestContextgetFlashScope in interface RequestContextpublic MutableAttributeMap<java.lang.Object> getViewScope() throws java.lang.IllegalStateException
RequestContextgetViewScope in interface RequestContextjava.lang.IllegalStateException - if this flow is not in a view-state or the flow execution is not activeRequestContext.inViewState(),
FlowExecutionContext.isActive()public MutableAttributeMap<java.lang.Object> getFlowScope()
RequestContextgetFlowScope in interface RequestContextFlowSession,
FlowExecutionContext.isActive()public MutableAttributeMap<java.lang.Object> getConversationScope()
RequestContextgetConversationScope in interface RequestContextFlowExecutionContextpublic ParameterMap getRequestParameters()
RequestContext
This is typically a convenient shortcut for accessing the ExternalContext.getRequestParameterMap()
directly.
getRequestParameters in interface RequestContextRequestContext.getExternalContext()public MessageContext getMessageContext()
RequestContextgetMessageContext in interface RequestContextpublic ExternalContext getExternalContext()
RequestContextActing as a facade, the returned context object provides a single point of access to the calling client's environment. It provides normalized access to attributes of the client environment without tying you to specific constructs within that environment.
In addition, this context may be downcastable to a specific context type for a specific client environment, such as Servlets or Portlets. Such downcasting will give you full access to a native HttpServletRequest, for example. With that said, for portability reasons you should avoid coupling your flow artifacts to a specific deployment environment when possible.
getExternalContext in interface RequestContextpublic FlowExecutionContext getFlowExecutionContext()
RequestContextgetFlowExecutionContext in interface RequestContextpublic Event getCurrentEvent()
RequestContextgetCurrentEvent in interface RequestContextpublic TransitionDefinition getCurrentTransition()
RequestContextgetCurrentTransition in interface RequestContextnull if no transition has occurred yetpublic View getCurrentView()
RequestContextnull if the flow is not in a view state.getCurrentView in interface RequestContextnull if the flow is not in a view statepublic MutableAttributeMap<java.lang.Object> getAttributes()
RequestContextgetAttributes in interface RequestContextpublic java.lang.String getFlowExecutionUrl()
RequestContextgetFlowExecutionUrl in interface RequestContextpublic void sendFlowExecutionRedirect()
public void setActiveSession(FlowSession flowSession)
getActiveFlow() and getCurrentState(), as well as getFlowScope() and
getFlashScope().public void setExternalContext(ExternalContext externalContext)
public void setFlowExecutionContext(FlowExecutionContext flowExecutionContext)
public void setCurrentEvent(Event event)
event - the current eventpublic void setCurrentTransition(Transition transition)
transition - the current transition to setpublic void setCurrentView(View currentView)
currentView - the current viewpublic void setAttribute(java.lang.String attributeName,
java.lang.Object attributeValue)
attributeName - the attribute nameattributeValue - the attribute valuepublic void removeAttribute(java.lang.String attributeName)
attributeName - the attribute namepublic void putRequestParameter(java.lang.String parameterName,
java.lang.String parameterValue)
parameterName - the parameter nameparameterValue - the parameter valuepublic void putRequestParameter(java.lang.String parameterName,
java.lang.String[] parameterValues)
parameterName - the parameter nameparameterValues - the parameter valuespublic void putRequestParameter(java.lang.String parameterName,
org.springframework.web.multipart.MultipartFile parameterValue)
parameterName - the parameter nameparameterValue - the parameter valuepublic void putRequestParameter(java.lang.String parameterName,
java.util.List<org.springframework.web.multipart.MultipartFile> parameterValue)
parameterName - the parameter nameparameterValue - the parameter valuepublic Flow getRootFlow()
Flow implementation.public MutableAttributeMap<java.lang.Object> getAttributeMap()
attribute map allowing setting of mock context
attributes.public MockFlowExecutionContext getMockFlowExecutionContext()
MockFlowExecutionContext.public MockExternalContext getMockExternalContext()
MockExternalContext.