/** * Creates a new mock flow session that sets a flow with id "mockFlow" as the 'active flow' in state "mockState". */ public MockFlowSession() { setDefinition(new Flow("mockFlow")); State state = new TransitionableState(definition, "mockState") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { // nothing to do } }; setState(state); }
public void setCurrentState(State state) { getMockFlowExecutionContext().getMockActiveSession().setState(state); }
/** * Creates a new mock flow session that sets a flow with id "mockFlow" as the 'active flow' in state "mockState". */ public MockFlowSession() { setDefinition(new Flow("mockFlow")); State state = new TransitionableState(definition, "mockState") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { // nothing to do } }; setState(state); }
/** * Creates a new mock flow session that sets a flow with id "mockFlow" as the 'active flow' in state "mockState". */ public MockFlowSession() { setDefinition(new Flow("mockFlow")); State state = new TransitionableState(definition, "mockState") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { // nothing to do } }; setState(state); }
public void setCurrentState(State state) { getMockFlowExecutionContext().getMockActiveSession().setState(state); }
public void setCurrentState(State state) { getMockFlowExecutionContext().getMockActiveSession().setState(state); }
/** * Creates a new mock flow session that sets a flow with id "mockFlow" as the 'active flow' in state "mockState". * This session marks itself active. */ public MockFlowSession() { setDefinition(new Flow("mockFlow")); State state = new ViewState(definition, "mockState"); setStatus(FlowSessionStatus.ACTIVE); setState(state); }
protected void unsetView(MockRequestContext requestContext) { ((MockFlowSession) requestContext.getFlowExecutionContext().getActiveSession()).setState(null); }
protected void initView(MockRequestContext requestContext) { ((MockFlowSession) requestContext.getFlowExecutionContext().getActiveSession()).setState(new ViewState( requestContext.getRootFlow(), "view", context -> { throw new UnsupportedOperationException("Auto-generated method stub"); })); }
public void setCurrentState(State state) { State previousState = (State) getCurrentState(); getMockFlowExecutionContext().getMockActiveSession().setState(state); if (previousState == null) { getMockFlowExecutionContext().getMockActiveSession().setStatus(FlowSessionStatus.ACTIVE); } }
protected void initView(MockRequestContext requestContext) { ((MockFlowSession) requestContext.getFlowExecutionContext().getActiveSession()).setState(new ViewState( requestContext.getRootFlow(), "view", new ViewFactory() { public View getView(RequestContext context) { throw new UnsupportedOperationException("Not implemented"); } })); }
public void testCannotResolveMethod() throws Exception { try { context.getMockFlowExecutionContext().getMockActiveSession().setState(null); action.execute(context); fail("Should've failed with illegal state"); } catch (IllegalStateException e) { } }
public void testDispatchWithCurrentStateId() throws Exception { MockFlowSession session = context.getMockFlowExecutionContext().getMockActiveSession(); session.setState(new ViewState(session.getDefinitionInternal(), "increment", new StubViewFactory())); action.execute(context); assertEquals(1, action.counter); }
public void testExecuteActionInState() { context.getMockFlowExecutionContext().getMockActiveSession().setState(state); TestAction action = new TestAction(); Event result = ActionExecutor.execute(action, context); assertSame(state, context.getCurrentState()); assertEquals("success", result.getId()); }
private MockFlowSession newFlowSession(boolean persistenceContext, FlowSession parent) { MockFlowSession flowSession = new MockFlowSession(); flowSession.setParent(parent); if (persistenceContext) { flowSession.getDefinition().getAttributes().put("persistenceContext", "true"); } EndState endState = new EndState(flowSession.getDefinitionInternal(), "success"); endState.getAttributes().put("commit", true); flowSession.setState(endState); return flowSession; }
public void testNoCommitAttributeSetOnEndState() { assertEquals("Table should only have one row", 1, getCount()); MockRequestContext context = new MockRequestContext(); MockFlowSession flowSession = new MockFlowSession(); flowSession.getDefinition().getAttributes().put("persistenceContext", "true"); hibernateListener.sessionStarting(context, flowSession, null); context.setActiveSession(flowSession); assertSessionBound(); EndState endState = new EndState(flowSession.getDefinitionInternal(), "cancel"); flowSession.setState(endState); hibernateListener.sessionEnding(context, flowSession, "success", null); hibernateListener.sessionEnded(context, flowSession, "cancel", null); assertEquals("Table should only have three rows", 1, getCount()); assertSessionNotBound(); }
public void testNoCommitAttributeSetOnEndState() { assertEquals("Table should only have one row", 1, getCount()); MockRequestContext context = new MockRequestContext(); MockFlowSession flowSession = new MockFlowSession(); flowSession.getDefinition().getAttributes().put("persistenceContext", "true"); jpaListener.sessionStarting(context, flowSession, null); context.setActiveSession(flowSession); assertSessionBound(); EndState endState = new EndState(flowSession.getDefinitionInternal(), "cancel"); flowSession.setState(endState); jpaListener.sessionEnding(context, flowSession, "cancel", null); jpaListener.sessionEnded(context, flowSession, "success", null); assertEquals("Table should only have three rows", 1, getCount()); assertSessionNotBound(); }
public void testCancelEndState() { assertEquals("Table should only have one row", 1, getCount()); MockRequestContext context = new MockRequestContext(); MockFlowSession flowSession = new MockFlowSession(); flowSession.getDefinition().getAttributes().put("persistenceContext", "true"); jpaListener.sessionStarting(context, flowSession, null); context.setActiveSession(flowSession); assertSessionBound(); TestBean bean = new TestBean(1, "Keith Donald"); EntityManager em = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory); em.persist(bean); assertEquals("Table should still only have one row", 1, getCount()); EndState endState = new EndState(flowSession.getDefinitionInternal(), "cancel"); endState.getAttributes().put("commit", false); flowSession.setState(endState); jpaListener.sessionEnding(context, flowSession, "cancel", null); jpaListener.sessionEnded(context, flowSession, "success", null); assertEquals("Table should only have two rows", 1, getCount()); assertSessionNotBound(); }
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()); }
public void testCancelEndState() { assertEquals("Table should only have one row", 1, getCount()); MockRequestContext context = new MockRequestContext(); MockFlowSession flowSession = new MockFlowSession(); flowSession.getDefinition().getAttributes().put("persistenceContext", "true"); hibernateListener.sessionStarting(context, flowSession, null); context.setActiveSession(flowSession); assertSessionBound(); TestBean bean = new TestBean("Keith Donald"); hibernate.templateSave(bean); assertEquals("Table should still only have one row", 1, getCount()); EndState endState = new EndState(flowSession.getDefinitionInternal(), "cancel"); endState.getAttributes().put("commit", false); flowSession.setState(endState); hibernateListener.sessionEnding(context, flowSession, "success", null); hibernateListener.sessionEnded(context, flowSession, "cancel", null); assertEquals("Table should only have two rows", 1, getCount()); assertSessionNotBound(); }