### Question:
CompositeRegistry implements Registry { @Override public Iterator<Meter> iterator() { rlock.lock(); try { if (registries.isEmpty()) { return Collections.emptyIterator(); } else { final Set<Id> ids = new HashSet<>(); for (Registry r : registries) { for (Meter m : r) ids.add(m.id()); } return new Iterator<Meter>() { private final Iterator<Id> idIter = ids.iterator(); @Override public boolean hasNext() { return idIter.hasNext(); } @Override public Meter next() { return get(idIter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } } finally { rlock.unlock(); } } CompositeRegistry(Clock clock); void add(Registry registry); void remove(Registry registry); void removeAll(); @Override Clock clock(); @Override Id createId(String name); @Override Id createId(String name, Iterable<Tag> tags); @Override void register(Meter meter); @Override ConcurrentMap<Id, Object> state(); @Override Counter counter(Id id); @Override DistributionSummary distributionSummary(Id id); @Override Timer timer(Id id); @Override Gauge gauge(Id id); @Override Gauge maxGauge(Id id); @Override Meter get(Id id); @Override Iterator<Meter> iterator();  }### Answer:
@Test public void testIterator() { Registry r = newRegistry(5, true); r.counter(r.createId("foo")).increment(); r.counter(r.createId("bar")).increment(); Set<Id> expected = new HashSet<>(); expected.add(r.createId("foo")); expected.add(r.createId("bar")); for (Meter m : r) { expected.remove(m.id()); } Assertions.assertTrue(expected.isEmpty()); }