Exemplo n.º 1
0
  @Test
  public void from_off_through_idle_back_to_off() {
    StateMachine atm = new ATMStateMachine();

    atm.execute(new TurnedOn());
    atm.execute(new TestedOk());
    atm.execute(new TurnedOff());

    assertThat(atm.getActiveStateName()).isEqualTo(OFF);
  }
Exemplo n.º 2
0
  @Test
  public void from_idle_to_idle_with_transaction() {
    StateMachine atm = new ATMStateMachine();
    atm.activeStateConfiguration(asList(IDLE));

    atm.execute(new CardInserted());
    atm.execute(new Authenticated());
    atm.execute(new TransactionSelected());

    assertThat(atm.getActiveStateName()).isEqualTo(IDLE);
  }
Exemplo n.º 3
0
  @Test
  public void simple_state_transfers() {
    // Given
    StateMachine atm = new ATMStateMachine();

    // When
    atm.execute(new TurnedOn());

    // Then
    assertThat(atm.getActiveStateName()).isEqualTo(SELF_TEST);
  }