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());
  }
  /** Test whether isRinging returns true only on cases where it should be true */
  public void testIsRinging() {
    assertFalse(phoneStateMachine.isRinging());

    phoneStateMachine.onRing();
    assertTrue(phoneStateMachine.isRinging());

    phoneStateMachine.onOffhook();
    assertFalse(phoneStateMachine.isRinging());

    phoneStateMachine.onIdle();
    assertFalse(phoneStateMachine.isRinging());

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