Examples of UntypedStateMachineBuilder


Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder

    }
   
    @Test
    public void testMultipleEvents() {
        System.out.println("Test run on thread "+Thread.currentThread().getName());
        UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(StateMachineSample.class);
        builder.externalTransition().from("D").to("A").on(FSMEvent.ToA);
        builder.externalTransition().from("A").to("B").on(FSMEvent.ToB);
        builder.externalTransition().from("B").to("C").on(FSMEvent.ToC);
        builder.externalTransition().from("C").to("D").on(FSMEvent.ToD);
       
        final StateMachineSample fsm = builder.newUntypedStateMachine("D");
        fsm.addDeclarativeListener(new TestListener());
        String expected1 = (String) fsm.test(FSMEvent.ToA, 5);
        System.out.println("expected1: "+expected1);
        assertThat(expected1, equalTo("A"));
        String expected2 = (String) fsm.test(FSMEvent.ToA, 11);
View Full Code Here

Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder

        assertThat(expected3, equalTo("C"));
    }
   
    @Test
    public void testThreadLocal() {
        UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(StateMachineSample.class);
        builder.externalTransition().from("A").to("B").on(FSMEvent.ToB).callMethod("onAToB");
        final StateMachineSample fsm = builder.newUntypedStateMachine("A");
        assertTrue(StateMachineContext.currentInstance()==null);
        fsm.fire(FSMEvent.ToB, 10);
        assertTrue(fsm==fsm.currentInstance);
        assertTrue(StateMachineContext.currentInstance()==null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.