/** * Set a single listener to be attached to the flow execution the next time one is started by this test. Useful for * attaching a listener that does test assertions during the execution of the flow. * @param executionListener the listener to attach */ protected void setFlowExecutionListener(FlowExecutionListener executionListener) { getFlowExecutionImplFactory().setExecutionListenerLoader( new StaticFlowExecutionListenerLoader(executionListener)); }
/** * Set the listeners to be attached to the flow execution the next time one is started. by this test. Useful for * attaching listeners that do test assertions during the execution of the flow. * @param executionListeners the listeners to attach */ protected void setFlowExecutionListeners(FlowExecutionListener[] executionListeners) { getFlowExecutionImplFactory().setExecutionListenerLoader( new StaticFlowExecutionListenerLoader(executionListeners)); }
/** * Convenience setter that sets a list of listeners that always apply to flow executions launched by the executor * created by this factory. * @param executionListeners the flow execution listeners */ public void setExecutionListeners(FlowExecutionListener[] executionListeners) { setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(executionListeners)); }
/** * Set the listeners to be attached to the flow execution the next time one is started. by this test. Useful for * attaching listeners that do test assertions during the execution of the flow. * @param executionListeners the listeners to attach */ protected void setFlowExecutionListeners(FlowExecutionListener[] executionListeners) { getFlowExecutionImplFactory().setExecutionListenerLoader( new StaticFlowExecutionListenerLoader(executionListeners)); }
/** * Set a single listener to be attached to the flow execution the next time one is started by this test. Useful for * attaching a listener that does test assertions during the execution of the flow. * @param executionListener the listener to attach */ protected void setFlowExecutionListener(FlowExecutionListener executionListener) { getFlowExecutionImplFactory().setExecutionListenerLoader( new StaticFlowExecutionListenerLoader(executionListener)); }
/** * Set the listeners to be attached to the flow execution the next time one is started. by this test. Useful for * attaching listeners that do test assertions during the execution of the flow. * @param executionListeners the listeners to attach */ protected void setFlowExecutionListeners(FlowExecutionListener[] executionListeners) { getFlowExecutionImplFactory().setExecutionListenerLoader( new StaticFlowExecutionListenerLoader(executionListeners)); }
/** * Set a single listener to be attached to the flow execution the next time one is {@link #startFlow() started} by * this test. Useful for attaching a listener that does test assertions during the execution of the flow. * @param executionListener the listener to attach */ protected void setFlowExecutionListener(FlowExecutionListener executionListener) { getFlowExecutionImplFactory().setExecutionListenerLoader( new StaticFlowExecutionListenerLoader(executionListener)); }
/** * Set the listeners to be attached to the flow execution the next time one is {@link #startFlow() started} by this * test. Useful for attaching listeners that do test assertions during the execution of the flow. * @param executionListeners the listeners to attach * @since 1.0.4 */ protected void setFlowExecutionListeners(FlowExecutionListener[] executionListeners) { getFlowExecutionImplFactory().setExecutionListenerLoader( new StaticFlowExecutionListenerLoader(executionListeners)); }
/** * Set a single listener to be attached to the flow execution the next time one is started by this test. Useful for * attaching a listener that does test assertions during the execution of the flow. * @param executionListener the listener to attach */ protected void setFlowExecutionListener(FlowExecutionListener executionListener) { getFlowExecutionImplFactory().setExecutionListenerLoader( new StaticFlowExecutionListenerLoader(executionListener)); }
private FlowExecutor buildFlowExecutorViaClientFlowExecution() { val repository = new ClientFlowExecutionRepository(); repository.setFlowDefinitionLocator(this.flowDefinitionRegistry); repository.setTranscoder(getWebflowStateTranscoder()); val factory = new FlowExecutionImplFactory(); factory.setExecutionKeyFactory(repository); factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader()); repository.setFlowExecutionFactory(factory); factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(executionListeners)); return new FlowExecutorImpl(this.flowDefinitionRegistry, factory, repository); }
public void testStaticListener() { final FlowExecutionListener listener1 = new FlowExecutionListener() {}; loader = new StaticFlowExecutionListenerLoader(listener1); assertEquals(listener1, loader.getListeners(new Flow("foo"))[0]); }
private FlowExecutor buildFlowExecutorViaServerSessionBindingExecution() { val conversationManager = new SessionBindingConversationManager(); val session = webflowProperties.getSession(); conversationManager.setLockTimeoutSeconds((int) Beans.newDuration(session.getLockTimeout()).getSeconds()); conversationManager.setMaxConversations(session.getMaxConversations()); val executionFactory = new FlowExecutionImplFactory(); executionFactory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(executionListeners)); val flowExecutionSnapshotFactory = new SerializedFlowExecutionSnapshotFactory(executionFactory, this.flowDefinitionRegistry); flowExecutionSnapshotFactory.setCompress(session.isCompress()); val repository = new DefaultFlowExecutionRepository(conversationManager, flowExecutionSnapshotFactory); executionFactory.setExecutionKeyFactory(repository); return new FlowExecutorImpl(this.flowDefinitionRegistry, executionFactory, repository); }
public void testStaticListeners() { final FlowExecutionListener listener1 = new FlowExecutionListener() {}; final FlowExecutionListener listener2 = new FlowExecutionListener() {}; loader = new StaticFlowExecutionListenerLoader(listener1, listener2); assertEquals(listener1, loader.getListeners(new Flow("foo"))[0]); assertEquals(listener2, loader.getListeners(new Flow("foo"))[1]); }
public void testCreateWithExecutionListener() { FlowExecutionListener listener1 = new FlowExecutionListener() { public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) { starting = true; } }; factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener1)); FlowExecution execution = factory.createFlowExecution(flowDefinition); assertFalse(execution.isActive()); execution.start(null, new MockExternalContext()); assertTrue(starting); }
public void testGetFlowExecutorOptionsSpecified() throws Exception { factoryBean.setFlowDefinitionLocator(id -> { Flow flow = new Flow(id); ViewState view = new ViewState(flow, "view", new StubViewFactory()); view.getTransitionSet().add(new Transition(new DefaultTargetStateResolver("end"))); new EndState(flow, "end"); return flow; }); Set<FlowElementAttribute> attributes = new HashSet<>(); attributes.add(new FlowElementAttribute("foo", "bar", null)); factoryBean.setFlowExecutionAttributes(attributes); FlowExecutionListener listener = new FlowExecutionListener() {}; factoryBean.setFlowExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener)); factoryBean.setMaxFlowExecutionSnapshots(2); factoryBean.setMaxFlowExecutions(1); factoryBean.afterPropertiesSet(); factoryBean.getObject(); } }
public void testFlowStateExceptionHandlingTransition() { new EndState(flow, "end"); TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); handler.add(TestException.class, "end"); flow.getExceptionHandlerSet().add(handler); FlowExecutionListener listener = new FlowExecutionListener() { @SuppressWarnings("unused") public void sessionEnding(RequestContext context, FlowSession session, MutableAttributeMap<?> output) { assertTrue(context.getFlashScope().contains("flowExecutionException")); assertTrue(context.getFlashScope().contains("rootCauseException")); assertTrue(context.getFlashScope().get("rootCauseException") instanceof TestException); } }; FlowExecutionImplFactory factory = new FlowExecutionImplFactory(); factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener)); FlowExecution execution = factory.createFlowExecution(flow); execution.start(null, new MockExternalContext()); assertTrue("Should have ended", !execution.isActive()); }
Flow flow = assembler.assembleFlow(); FlowExecutionImplFactory factory = new FlowExecutionImplFactory(); factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(new FlowExecutionListener() { public void viewRendering(RequestContext context, View view, StateDefinition viewState) { if (context.getCurrentEvent() != null && context.getCurrentEvent().getId().equals("submit")) {
protected void setUp() throws Exception { initDataSource(); populateDataBase(); persistenceListener = createFlowExecutionListener(); ClassPathResource resource = new ClassPathResource("managed-root-flow.xml", getClass()); DefaultFlowModelHolder holder = new DefaultFlowModelHolder(new XmlFlowModelBuilder(resource)); FlowModelFlowBuilder builder = new FlowModelFlowBuilder(holder); MockFlowBuilderContext context = new MockFlowBuilderContext("managed-root-flow"); FlowAssembler assembler = new FlowAssembler(builder, context); Flow rootFlow = assembler.assembleFlow(); ClassPathResource childFlowResource = new ClassPathResource("managed-child-flow.xml", getClass()); DefaultFlowModelHolder childFlowHolder = new DefaultFlowModelHolder(new XmlFlowModelBuilder(childFlowResource)); FlowModelFlowBuilder childFlowBuilder = new FlowModelFlowBuilder(childFlowHolder); MockFlowBuilderContext childFlowContext = new MockFlowBuilderContext("managed-child-flow"); FlowAssembler childFlowAssembler = new FlowAssembler(childFlowBuilder, childFlowContext); Flow childFlow = childFlowAssembler.assembleFlow(); Flow notManaged = new Flow("notmanaged-child-flow"); new EndState(notManaged, "finish"); context.registerSubflow(childFlow); context.registerSubflow(notManaged); Action incrementCountAction = incrementCountAction(); context.registerBean("incrementCountAction", incrementCountAction); childFlowContext.registerBean("incrementCountAction", incrementCountAction); Object assertCountAction = assertCountAction(); context.registerBean("assertCountAction", assertCountAction); childFlowContext.registerBean("assertCountAction", assertCountAction); FlowExecutionImplFactory factory = new FlowExecutionImplFactory(); factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(persistenceListener)); flowExecution = factory.createFlowExecution(rootFlow); }
FlowExecutionListener listener = new FlowExecutionListener() { }; factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener)); MockFlowExecutionKeyFactory keyFactory = new MockFlowExecutionKeyFactory(); factory.setExecutionKeyFactory(keyFactory);