public void testInboundOffHook() throws IllegalStateException {
    phoneStateMachine.onRing();

    phoneStateMachine.onOffhook();
    assertTrue(phoneStateMachine.isInboundOffhook());

    /*
     * 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.isInboundOffhook());

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

    assertTrue(exceptionOccured);
    assertTrue(phoneStateMachine.isInboundOffhook());

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

    phoneStateMachine.onRing();
    assertFalse(phoneStateMachine.isInboundOffhook());

    phoneStateMachine.onOffhook();
    assertTrue(phoneStateMachine.isInboundOffhook());

    phoneStateMachine.onIdle();
    assertFalse(phoneStateMachine.isInboundOffhook());

    phoneStateMachine.onOffhook();
    assertFalse(phoneStateMachine.isInboundOffhook());
  }