CounterSet extends CounterFactory { public <UpdateT> List<UpdateT> extractUpdates( boolean delta, CounterUpdateExtractor<UpdateT> extractors) { return extractUpdatesImpl(delta, false, extractors); }  Counter<?, ?> getExistingCounter(CounterName name); @Deprecated Counter<?, ?> getExistingCounter(String name); long size(); List<UpdateT> extractUpdates(
      boolean delta, CounterUpdateExtractor<UpdateT> extractors); List<UpdateT> extractModifiedDeltaUpdates(
      CounterUpdateExtractor<UpdateT> extractors); @Override String toString();  }
@Test public void testExtractUpdates() { CounterSet deltaSet = new CounterSet(); CounterSet cumulativeSet = new CounterSet(); CounterUpdateExtractor<?> updateExtractor = Mockito.mock(CounterUpdateExtractor.class); Counter<Long, Long> delta1 = deltaSet.longSum(name1); Counter<Long, Long> cumulative1 = cumulativeSet.longSum(name1); delta1.addValue(10L); deltaSet.extractUpdates(true, updateExtractor); verify(updateExtractor).longSum(name1, true, 10L); delta1.addValue(5L); deltaSet.extractUpdates(true, updateExtractor); verify(updateExtractor).longSum(name1, true, 5L); deltaSet.extractUpdates(true, updateExtractor); verify(updateExtractor).longSum(name1, true, 0L); cumulative1.addValue(10L); cumulativeSet.extractUpdates(false, updateExtractor); verify(updateExtractor).longSum(name1, false, 10L); cumulative1.addValue(5L); cumulativeSet.extractUpdates(false, updateExtractor); verify(updateExtractor).longSum(name1, false, 15L); cumulativeSet.extractUpdates(false, updateExtractor); verify(updateExtractor, times(2)).longSum(name1, false, 15L); Counter<Integer, Integer> delta2 = deltaSet.intSum(name2); delta1.addValue(100L); delta2.addValue(200); deltaSet.extractModifiedDeltaUpdates(updateExtractor); verify(updateExtractor).longSum(name1, true, 100L); verify(updateExtractor).intSum(name2, true, 200); delta1.addValue(1L); deltaSet.extractModifiedDeltaUpdates(updateExtractor); verify(updateExtractor).longSum(name1, true, 1L); delta2.addValue(5); deltaSet.extractModifiedDeltaUpdates(updateExtractor); verify(updateExtractor).intSum(name2, true, 5); verifyNoMoreInteractions(updateExtractor); }