StartedKamonTimer implements StartedTimer { @Override public StoppedTimer stop() { if (isRunning()) { stopped = true; return StoppedKamonTimer.fromStartedTimer(this); } throw new IllegalStateException( String.format("Tried to stop the already stopped timer <%s> with segment <%s>.", name, getTag(SEGMENT_TAG))); } private  StartedKamonTimer(final String name, final Map<String, String> tags); @Override StartedTimer tags(final Map<String, String> tags); @Nullable @Override String getTag(final String key); @Override Map<String, String> getTags(); @Override StartedTimer tag(final String key, final String value); @Override StoppedTimer stop(); @Override boolean isRunning(); @Override StartedTimer startNewSegment(final String segmentName); @Override StartedTimer onStop(final OnStopHandler onStopHandler); @Override String getName(); @Override Long getStartTimeStamp(); @Override Map<String, StartedTimer> getSegments(); @Override List<OnStopHandler> getOnStopHandlers(); @Override String toString();  }
@Test(expected = IllegalStateException.class) public void stopAStoppedTimerCausesException() { sut.stop(); sut.stop(); }