PauseableTimer { private PauseableTimer(Timer timer) { this.timer = timer; this.clock = Clock.defaultClock(); } private  PauseableTimer(Timer timer); private  PauseableTimer(); static PauseableTimer createTimer(MetricRegistry registry, String name); Context createContext(); Timer getTimer();  }
@Test public void testPauseableTimer() throws Exception { PauseableTimer timer = PauseableTimer.createTimer(registry, "someName"); PauseableTimer.Context context = timer.createContext(); context.resume(); context.pause(); Thread.sleep(100); context.resume(); context.stop(); new Verifications() {{ long time; Timer timer = new Timer((Reservoir) any, (Clock) any); timer.update(time = withCapture(), TimeUnit.NANOSECONDS); Assert.assertTrue(time > 0); Assert.assertTrue(time < 100 * 1000); }}; }