@Test(dataProvider = "correctStateData") public void stateChange(State currentState, State nextState) throws SystemException, StateChangeException { machine.setCurrentState(currentState); machine.nextState(currentState.getSignalChange()); assertEquals(nextState, machine.getCurrentState()); }
@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); }
@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); }