public void testEnterEndStateTerminateFlowExecution() { Flow flow = new Flow("myFlow"); EndState state = new EndState(flow, "end"); MockRequestControlContext context = new MockRequestControlContext(flow); state.enter(context); assertFalse("Active", context.getFlowExecutionContext().isActive()); }
public void testEnterEndStateWithFinalResponseRenderer() { Flow flow = new Flow("myFlow"); EndState state = new EndState(flow, "end"); StubFinalResponseAction action = new StubFinalResponseAction(); state.setFinalResponseAction(action); MockRequestControlContext context = new MockRequestControlContext(flow); state.enter(context); assertTrue(action.executeCalled); }
public void testEnterEndStateWithFinalResponseRendererResponseAlreadyComplete() { Flow flow = new Flow("myFlow"); EndState state = new EndState(flow, "end"); StubFinalResponseAction action = new StubFinalResponseAction(); state.setFinalResponseAction(action); MockRequestControlContext context = new MockRequestControlContext(flow); context.getExternalContext().recordResponseComplete(); state.enter(context); assertFalse(action.executeCalled); }
public void testEnterEndStateWithOutputMapper() { Flow flow = new Flow("myFlow") { @SuppressWarnings("unused") public void end(RequestControlContext context, MutableAttributeMap<Object> output) throws FlowExecutionException { assertEquals("foo", output.get("y")); } }; EndState state = new EndState(flow, "end"); DefaultMapper mapper = new DefaultMapper(); ExpressionParser parser = new WebFlowSpringELExpressionParser(new SpelExpressionParser()); Expression x = parser.parseExpression("flowScope.x", new FluentParserContext().evaluate(RequestContext.class)); Expression y = parser.parseExpression("y", new FluentParserContext().evaluate(MutableAttributeMap.class)); mapper.addMapping(new DefaultMapping(x, y)); state.setOutputMapper(mapper); MockRequestControlContext context = new MockRequestControlContext(flow); context.getFlowScope().put("x", "foo"); state.enter(context); }
public void testEnterEndStateTerminateFlowSession() { final Flow subflow = new Flow("mySubflow"); EndState state = new EndState(subflow, "end"); MockFlowSession session = new MockFlowSession(subflow); Flow parent = new Flow("parent"); SubflowState subflowState = new SubflowState(parent, "subflow", new AbstractGetValueExpression() { public Object getValue(Object context) throws EvaluationException { return subflow; } }); subflowState.getTransitionSet().add(new Transition(on("end"), to("end"))); new EndState(parent, "end"); MockFlowSession parentSession = new MockFlowSession(parent); parentSession.setState(subflowState); session.setParent(parentSession); MockRequestControlContext context = new MockRequestControlContext(new MockFlowExecutionContext(session)); state.enter(context); assertFalse("Active", context.getFlowExecutionContext().isActive()); }