GCStat { long count() { long previous = previousCount; long current = bean.getCollectionCount(); previousCount = current; if (previous == -1) return 0; return current - previous; } private  GCStat(GarbageCollectorMXBean bean, String name);   }
@Test void count() { when(bean.getCollectionCount()).thenReturn(1L, 2L, 3L); assertThat(stat.count()).isEqualTo(0); assertThat(stat.count()).isEqualTo(1); assertThat(stat.count()).isEqualTo(1); }