public class FlowExecutionImplTests extends TestCase {
public void testStartAndEnd() {
Flow flow = new Flow("flow");
new EndState(flow, "end");
MockFlowExecutionListener mockListener = new MockFlowExecutionListener();
FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener };
FlowExecutionImpl execution = new FlowExecutionImpl(flow);
execution.setListeners(listeners);
MockExternalContext context = new MockExternalContext();
assertFalse(execution.hasStarted());
execution.start(null, context);
assertTrue(execution.hasStarted());
assertFalse(execution.isActive());
assertTrue(execution.hasEnded());
try {
execution.getActiveSession();
fail("should have failed");
} catch (IllegalStateException e) {
}
assertEquals(1, mockListener.getRequestsSubmittedCount());
assertEquals(1, mockListener.getRequestsProcessedCount());
assertEquals(1, mockListener.getSessionCreatingCount());
assertEquals(1, mockListener.getSessionStartingCount());
assertEquals(1, mockListener.getSessionStartedCount());
assertEquals(1, mockListener.getStateEnteringCount());
assertEquals(1, mockListener.getStateEnteredCount());
assertEquals(1, mockListener.getSessionEndingCount());
assertEquals(1, mockListener.getSessionEndedCount());
assertEquals(0, mockListener.getEventSignaledCount());
assertEquals(0, mockListener.getTransitionExecutingCount());
assertEquals(0, mockListener.getPausedCount());
assertEquals(0, mockListener.getResumingCount());
assertEquals(0, mockListener.getExceptionThrownCount());
assertEquals(0, mockListener.getFlowNestingLevel());
}