/** * Convenience constructor that creates a new mock request context with the following defaults: * <ul> * <li>A mock flow execution context with an active session for the specified flow. * <li>A mock external context with no request parameters set. * </ul> * To add request parameters to this request, use the {@link #putRequestParameter(String, String)} method. * @param flow the flow definition */ public MockRequestContext(Flow flow) { this(new MockFlowExecutionContext(flow)); }
public void endActiveFlowSession(String outcome, MutableAttributeMap<Object> output) throws IllegalStateException { MockFlowSession endingSession = getMockFlowExecutionContext().getMockActiveSession(); endingSession.getDefinitionInternal().end(this, outcome, output); getMockFlowExecutionContext().setActiveSession(endingSession.getParent()); if (!getMockFlowExecutionContext().hasEnded()) { handleEvent(new Event(endingSession.getState(), outcome, output)); } }
public MutableAttributeMap<Object> getViewScope() throws IllegalStateException { return getMockFlowExecutionContext().getActiveSession().getViewScope(); }
public FlowExecutionKey assignFlowExecutionKey() { GeneratedFlowExecutionKey key = new GeneratedFlowExecutionKey(); getMockFlowExecutionContext().setKey(key); return key; }
public void setEmbeddedMode() { getMockFlowExecutionContext().getMockActiveSession().setEmbeddedMode(); } }
/** * Sets the active flow session of the executing flow associated with this request. This will influence * {@link #getActiveFlow()} and {@link #getCurrentState()}, as well as {@link #getFlowScope()} and * {@link #getFlashScope()}. */ public void setActiveSession(FlowSession flowSession) { getMockFlowExecutionContext().setActiveSession(flowSession); }
public ViewSelection start(Flow flow, MutableAttributeMap input) throws IllegalStateException { getMockFlowExecutionContext().setActiveSession(new MockFlowSession(flow, input)); getMockFlowExecutionContext().getMockActiveSession().setStatus(FlowSessionStatus.STARTING); ViewSelection selectedView = flow.start(this, input); return selectedView; }
public MutableAttributeMap<Object> getConversationScope() { return getMockFlowExecutionContext().getConversationScope(); }
public void testResumeEventModelNoValidateOnBindingErrors() { MockRequestContext context = new MockRequestContext(); context.putRequestParameter("_eventId", "submit"); context.putRequestParameter("stringProperty", "foo"); context.putRequestParameter("integerProperty", "bogus"); context.putRequestParameter("dateProperty", "2007-01-01"); BindBean bindBean = new ValidatingBindBean(); StaticExpression modelObject = new StaticExpression(bindBean); modelObject.setExpressionString("bindBean"); context.getMockFlowExecutionContext().putAttribute("validateOnBindingErrors", false); context.getCurrentState().getAttributes().put("model", modelObject); context.getFlowScope().put("bindBean", bindBean); context.getMockExternalContext().setNativeContext(new MockServletContext()); context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest()); context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse()); context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1")); org.springframework.web.servlet.View mvcView = new MockView(); AbstractMvcView view = new MockMvcView(mvcView, context); view.setExpressionParser(createExpressionParser()); view.setMessageCodesResolver(new WebFlowMessageCodesResolver()); view.processUserEvent(); assertFalse(view.hasFlowEvent()); assertFalse(bindBean.validationMethodInvoked); }
/** * Returns the root flow definition for this request context. Assumes a {@link Flow} implementation. */ public Flow getRootFlow() { return getMockFlowExecutionContext().getDefinitionInternal(); }
public MutableAttributeMap<Object> getFlashScope() { return getMockFlowExecutionContext().getFlashScope(); }
public Flow getDefinitionInternal() { return (Flow) getDefinition(); }
public FlowExecutionKey assignFlowExecutionKey() { GeneratedFlowExecutionKey key = new GeneratedFlowExecutionKey(); getMockFlowExecutionContext().setKey(key); return key; }
public void setCurrentState(State state) { getMockFlowExecutionContext().getMockActiveSession().setState(state); }
/** * Creates a new mock flow execution context for the specified active flow session. */ public MockFlowExecutionContext(FlowSession flowSession) { setActiveSession(flowSession); this.flow = flowSession.getDefinition(); }
public FlowSession endActiveFlowSession(MutableAttributeMap output) throws IllegalStateException { MockFlowSession endingSession = getMockFlowExecutionContext().getMockActiveSession(); endingSession.getDefinitionInternal().end(this, output); endingSession.setStatus(FlowSessionStatus.ENDED); getMockFlowExecutionContext().setActiveSession(null); return endingSession; }
public MutableAttributeMap<Object> getConversationScope() { return getMockFlowExecutionContext().getConversationScope(); }
/** * Returns the root flow definition for this request context. Assumes a {@link Flow} implementation. */ public Flow getRootFlow() { return getMockFlowExecutionContext().getDefinitionInternal(); }
public MutableAttributeMap getFlashScope() { return getMockFlowExecutionContext().getFlashScope(); }
public Flow getDefinitionInternal() { return (Flow) getDefinition(); }