### Question:
Counter extends Metric { Counter(final MetricRegistry registry, final String id, final int maxCardinality) { super(registry, id, maxCardinality); } Counter(final MetricRegistry registry, final String id, final int maxCardinality); void inc(final String... tags); void dec(final String... tags); void inc(long change, final String... tags); void dec(long change, final String... tags);  }### Answer:
@Test public void testCounter() { MetricRegistry metricRegistry = new MetricRegistry(); Counter c = metricRegistry.counter("test"); new Expectations(c) {{ c.emit(anyLong, (String[]) any); }}; c.inc(); new Verifications() {{ String[] tags; c.emit(1L, tags = withCapture()); assertEquals(0, tags.length); }}; c.inc("TEST-key", "test-value"); new Verifications() {{ String[] tags; c.emit(1L, tags = withCapture()); assertThat(tags, arrayContaining("TEST-key", "test-value")); }}; c.dec(); new Verifications() {{ String[] tags; c.emit(-1L, tags = withCapture()); assertEquals(0, tags.length); }}; c.dec("TEST-key", "test-value"); new Verifications() {{ String[] tags; c.emit(-1L, tags = withCapture()); assertThat(tags, arrayContaining("TEST-key", "test-value")); }}; c.inc(100L); new Verifications() {{ String[] tags; c.emit(100L, tags = withCapture()); assertEquals(0, tags.length); }}; c.dec(101L); new Verifications() {{ String[] tags; c.emit(-101L, tags = withCapture()); assertEquals(0, tags.length); }}; }