### Question:
Timer extends Metric { Timer(final MetricRegistry registry, final String id, final int maxCardinality) { super(registry, id, maxCardinality); } Timer(final MetricRegistry registry, final String id, final int maxCardinality); long start(); void stop(final long startTime, final String... tags); void update(final long duration, final String... tags);  }### Answer:
@Test public void testTimer() { MetricRegistry metricRegistry = new MetricRegistry(); Timer t = metricRegistry.timer("test"); new Expectations(t) {{ t.emit(anyLong, (String[]) any); }}; final long startTime = t.start(); t.stop(startTime); new Verifications() {{ String[] tags; long l; t.emit(l = withCapture(), tags = withCapture()); assertThat(l, greaterThan(0L)); assertEquals(0, tags.length); }}; t.stop(startTime, "TEST-key", "test-value"); new Verifications() {{ String[] tags; long l; t.emit(l = withCapture(), tags = withCapture()); assertThat(l, greaterThan(0L)); assertThat(tags, arrayContaining("TEST-key", "test-value")); }}; t.update(100L); new Verifications() {{ String[] tags; t.emit(100L, tags = withCapture()); assertEquals(0, tags.length); }}; }