@Test
  public void testOnEntry() throws Exception {
    State s1 = new State("s1");
    State s2 = new State("s2");

    s1.addTransition(new SuccessTransition("foo", s2));
    s1.addOnExitSelfTransaction(new SampleSelfTransition());
    s2.addOnEntrySelfTransaction(new SampleSelfTransition());

    StateContext context = new DefaultStateContext();
    StateMachine sm = new StateMachine(new State[] {s1, s2}, "s1");
    sm.handle(new Event("foo", context));
    assertEquals(true, context.getAttribute("success"));
    assertEquals(true, context.getAttribute("SelfSuccess" + s1.getId()));
    assertEquals(true, context.getAttribute("SelfSuccess" + s2.getId()));
  }
  @Test
  public void testBreakAndContinue() throws Exception {
    State s1 = new State("s1");
    s1.addTransition(new BreakAndContinueTransition("foo"));
    s1.addTransition(new SuccessTransition("foo"));

    StateContext context = new DefaultStateContext();
    StateMachine sm = new StateMachine(new State[] {s1}, "s1");
    sm.handle(new Event("foo", context));
    assertEquals(true, context.getAttribute("success"));
  }
  @Test
  public void testBreakAndGotoNext() throws Exception {
    State s1 = new State("s1");
    State s2 = new State("s2");
    s1.addTransition(new BreakAndGotoNextTransition("foo", "s2"));
    s2.addTransition(new SuccessTransition("foo"));

    StateContext context = new DefaultStateContext();
    StateMachine sm = new StateMachine(new State[] {s1, s2}, "s1");
    sm.handle(new Event("foo", context));
    assertSame(s2, context.getCurrentState());
    sm.handle(new Event("foo", context));
    assertEquals(true, context.getAttribute("success"));
  }