public void testCreate() { FlowExecution execution = factory.createFlowExecution(flowDefinition); assertSame(flowDefinition, execution.getDefinition()); assertFalse(execution.hasStarted()); assertFalse(execution.isActive()); }
public void testCreateWithExecutionKeyFactory() { State state = new State(flowDefinition, "state") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { context.assignFlowExecutionKey(); context.updateCurrentFlowExecutionSnapshot(); context.removeCurrentFlowExecutionSnapshot(); context.removeAllFlowExecutionSnapshots(); } }; flowDefinition.setStartState(state); factory.setExecutionKeyFactory(new MockFlowExecutionKeyFactory()); FlowExecution execution = factory.createFlowExecution(flowDefinition); execution.start(null, new MockExternalContext()); assertTrue(getKeyCalled); assertTrue(removeAllSnapshotsCalled); assertTrue(removeSnapshotCalled); assertTrue(updateSnapshotCalled); assertNull(execution.getKey()); }
public void testCreateNullArgument() { try { factory.createFlowExecution(null); fail("Should've failed"); } catch (IllegalArgumentException e) { } }
public void testCreateWithExecutionAttributes() { MutableAttributeMap<Object> attributes = new LocalAttributeMap<>(); attributes.put("foo", "bar"); factory.setExecutionAttributes(attributes); FlowExecution execution = factory.createFlowExecution(flowDefinition); assertEquals(attributes, execution.getAttributes()); assertSame("Flow execution attributes are global", attributes.asMap(), execution.getAttributes().asMap()); }
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); }
flowExecution.getFlowSessions().add(session2); factory.restoreFlowExecution(flowExecution, flowDefinition, flowExecutionKey, conversationScope, locator); assertSame("Flow execution attributes are global", flowExecution.getAttributes().asMap(), executionAttributes.asMap()); assertEquals(1, flowExecution.getListeners().length); assertSame(listener, flowExecution.getListeners()[0]); assertSame(flowExecutionKey, flowExecution.getKey()); assertSame(keyFactory, flowExecution.getKeyFactory()); assertSame(conversationScope, flowExecution.getConversationScope()); assertSame(flowExecution.getFlowSessions().get(0).getDefinition(), flowDefinition); assertSame(flowExecution.getFlowSessions().get(0).getDefinition().getState("end"), flowDefinition.getState("end")); assertSame(flowExecution.getFlowSessions().get(1).getDefinition(), locator.child); assertSame(flowExecution.getFlowSessions().get(1).getDefinition().getState("state"), locator.child.getState("state"));