### Question:
MultiCursor { public MultiCursor(final Collection<Aggregator> aggregators) { cursors = new Cursor[aggregators.size()]; nextTagSets = new String[aggregators.size()][]; initialize(aggregators); } MultiCursor(final Collection<Aggregator> aggregators); boolean next(); @SuppressFBWarnings( value = {"EI_EXPOSE_REP"}, justification = "Avoid creating copies for performance reasons.") String[] getTags(); CursorEntry nextCursorEntry();  }### Answer:
@Test public void testMultiCursor() { final BasicGaugeAggregator gaugeAggregator = new BasicGaugeAggregator("gauge", DEFAULT_MAX_CARDINALITY, 10); final BasicTimerAggregator timerAggregator = new BasicTimerAggregator("timer", DEFAULT_MAX_CARDINALITY, 10); final BasicCounterAggregator counterAggregator = new BasicCounterAggregator("counter", DEFAULT_MAX_CARDINALITY, 10); final String[] tagSet1 = new String[]{"testTag", "value"}; final String[] tagSet2 = new String[]{"testTag", "value", "testTag2", "value2"}; final String[] tagSet2b = new String[]{"testTag", "value", "testTag2", "value2"}; final String[] tagSet3 = new String[]{"testTag", "value2"}; final String[] tagSet4 = new String[]{"testTag3", "value"}; gaugeAggregator.apply(tagSet3, 1L, CURRENT_TIME); gaugeAggregator.apply(tagSet3, 2L, CURRENT_TIME); gaugeAggregator.apply(tagSet3, 3L, CURRENT_TIME); gaugeAggregator.apply(tagSet2, 10L, CURRENT_TIME); gaugeAggregator.apply(tagSet1, 0L, CURRENT_TIME); gaugeAggregator.apply(tagSet4, -1L, CURRENT_TIME); timerAggregator.apply(tagSet2b, 110L, CURRENT_TIME); timerAggregator.apply(tagSet2b, 100L, CURRENT_TIME); counterAggregator.apply(tagSet4, 1L, CURRENT_TIME); counterAggregator.apply(tagSet1, 1L, CURRENT_TIME); final MultiCursor multiCursor = new MultiCursor( Arrays.asList(timerAggregator, gaugeAggregator, counterAggregator, AggregatingReporter.NOOP)); final Map<Integer, List<String>> records = new java.util.HashMap<>(); while (multiCursor.next()) { CursorEntry entry = multiCursor.nextCursorEntry(); while (entry != null) { final List<String> metricIds = records .getOrDefault(Arrays.hashCode(multiCursor.getTags()), new java.util.ArrayList<>()); metricIds.add(entry.getMetricId()); records.put(Arrays.hashCode(multiCursor.getTags()), metricIds); log.info("{} {}", multiCursor.getTags(), entry.getMetricId()); entry = multiCursor.nextCursorEntry(); } assertNull(multiCursor.nextCursorEntry()); } assertFalse(multiCursor.next()); assertEquals(4, records.size()); for(Map.Entry<Integer, List<String>> entry: records.entrySet()) { log.info("{} {} {}", entry.getKey(), entry.getValue()); } assertThat(records.get(Arrays.hashCode(tagSet1)), containsInAnyOrder("gauge", "counter")); assertThat(records.get(Arrays.hashCode(tagSet2b)), containsInAnyOrder("gauge", "timer")); assertThat(records.get(Arrays.hashCode(tagSet3)), containsInAnyOrder("gauge")); assertThat(records.get(Arrays.hashCode(tagSet4)), containsInAnyOrder("gauge", "counter")); }