Exemplo n.º 1
0
  @Test(dataProvider = "correctStateData")
  public void stateChange(State currentState, State nextState)
      throws SystemException, StateChangeException {
    machine.setCurrentState(currentState);

    machine.nextState(currentState.getSignalChange());

    assertEquals(nextState, machine.getCurrentState());
  }
Exemplo n.º 2
0
  @Test
  public void allCompleted() throws SystemException, StateChangeException {
    State currentState = State.STATE_2;
    machine.setCurrentState(currentState);

    String result = machine.nextState(currentState.getSignalChange());

    assertEquals(Constants.MESSAGE_STATES_COMPLETED, result);
  }
Exemplo n.º 3
0
  @Test(
      dataProvider = "exceptionData",
      expectedExceptions = StateChangeException.class,
      expectedExceptionsMessageRegExp = TEST_MESSAGE)
  public void exceptionTest(State currentState, IMessageReader errorReader)
      throws SystemException, StateChangeException {
    machine.setCurrentState(currentState);
    expect(errorReader.readMessage(ID_MACHINE)).andReturn(TEST_MESSAGE);
    replay(errorReader);

    machine.nextState(incorrectState(currentState));

    verify(errorReader);
  }