### Question:
IntervalCounter implements Counter { public static IntervalCounter get(Registry registry, Id id) { ConcurrentMap<Id, Object> state = registry.state(); Object c = Utils.computeIfAbsent(state, id, i -> new IntervalCounter(registry, i)); if (!(c instanceof IntervalCounter)) { Utils.propagateTypeError(registry, id, IntervalCounter.class, c.getClass()); c = new IntervalCounter(new NoopRegistry(), id); } return (IntervalCounter) c; } IntervalCounter(Registry registry, Id id); static IntervalCounter get(Registry registry, Id id); @Override void add(double amount); @Override double actualCount(); @Override Id id(); double secondsSinceLastUpdate(); @Override Iterable<Measurement> measure(); @Override boolean hasExpired();  }### Answer:
@Test public void testIncrement() { Registry r = new DefaultRegistry(clock); Id id = r.createId("test"); Counter c = IntervalCounter.get(r, id); Assertions.assertEquals(0, c.count()); c.increment(); Assertions.assertEquals(1, c.count()); c.increment(41); Assertions.assertEquals(42, c.count()); }
@Test public void testReusesInstance() { Registry r = new DefaultRegistry(clock); Id id = r.createId("test"); Counter c1 = IntervalCounter.get(r, id); Counter c2 = IntervalCounter.get(r, id); Assertions.assertSame(c1, c2); }