Timer { public void start() { if (!wasSet) throw new IllegalStateException("cannot start a timer that has not been set"); startTime = clock.getNanoTime(); targetEndTime = startTime.plus(targetElapsedTime); } Timer();  Timer(HardwareClock clock); boolean set(long duration, long error); void start(); boolean hasElapsed(); boolean isLate(); DiscreteInterval getTimeRemaining(); void waitUntilElapsed();  }
@Test(expected=IllegalStateException.class) public void cannotStartTimerThanHasNotBeenSet() { expect(mockClock.getGranularity()).andReturn(1000L).anyTimes(); replay(mockClock); impl.start(); verify(mockClock); }