public void testOutboundOffHook() throws IllegalStateException {
    phoneStateMachine.onOffhook();
    assertTrue(phoneStateMachine.isOutboundOffhook());

    /*
     * Although it is very unlikely that an off-hooked phone will be off-hooked again, make sure
     * that the phone stays in the same state.
     */
    phoneStateMachine.onOffhook();
    assertTrue(phoneStateMachine.isOutboundOffhook());

    boolean exceptionOccured = false;
    try {
      phoneStateMachine.onRing();
    } catch (IllegalStateException e) {
      // The phone cannot ring while off-hook!
      exceptionOccured = true;
    }

    assertTrue(exceptionOccured);
    assertTrue(phoneStateMachine.isOutboundOffhook());

    phoneStateMachine.onIdle();
    assertTrue(phoneStateMachine.isIdle());
  }
  /** Test whether isIdle returns true only on cases where it should be true */
  public void testIsIdle() {
    phoneStateMachine.onRing();
    assertFalse(phoneStateMachine.isIdle());

    phoneStateMachine.onOffhook();
    assertFalse(phoneStateMachine.isIdle());

    phoneStateMachine.onIdle();
    assertTrue(phoneStateMachine.isIdle());
    phoneStateMachine.onOffhook();
    assertFalse(phoneStateMachine.isIdle());
  }
  public void testRinging() throws IllegalStateException {
    phoneStateMachine.onRing();
    assertTrue(phoneStateMachine.isRinging());

    /*
     * Although it is very unlikely that the phone will ring twice in a row, make sure that it still
     * stays on the same state.
     */
    phoneStateMachine.onRing();
    assertTrue(phoneStateMachine.isRinging());

    phoneStateMachine.onIdle();
    assertTrue(phoneStateMachine.isIdle());
  }
 public void testIdleState() throws IllegalStateException {
   phoneStateMachine.onIdle();
   assertTrue(phoneStateMachine.isIdle());
 }