Timer { public synchronized void started() { if (stopwatch.isRunning()) { throw new IllegalStateException("Already started"); } stopwatch.reset().start(); } @Inject  Timer(EventBus eventBus, @Assisted Object target); @VisibleForTesting  Timer(EventBus eventBus, Object target, Stopwatch stopwatch); synchronized void started(); synchronized void stop(); synchronized void reset(); void time(Runnable target); long getElapsedTime();  }
@Test(expected = IllegalStateException.class) public void testStartedTwice() { Timer timer = new Timer(eventBus, this); timer.started(); timer.started(); fail("Timer should have thrown an exception"); }