MetricsStatsCounter implements StatsCounter { @Override @SuppressWarnings("deprecation") public void recordEviction() { recordEviction(1); } MetricsStatsCounter(MetricRegistry registry, String metricsPrefix); @Override void recordHits(int count); @Override void recordMisses(int count); @Override void recordLoadSuccess(long loadTime); @Override void recordLoadFailure(long loadTime); @Override @SuppressWarnings("deprecation") void recordEviction(); @Override void recordEviction(int weight); @Override void recordEviction(@NonNegative int weight, RemovalCause cause); @Override CacheStats snapshot(); @Override String toString();  }
@Test public void eviction() { stats.recordEviction(); assertThat(registry.histogram(PREFIX + ".evictions").getCount()).isEqualTo(1); assertThat(registry.counter(PREFIX + ".evictions-weight").getCount()).isEqualTo(1); }
@Test public void evictionWithWeight() { stats.recordEviction(3); assertThat(registry.histogram(PREFIX + ".evictions").getCount()).isEqualTo(1); assertThat(registry.counter(PREFIX + ".evictions-weight").getCount()).isEqualTo(3); }
@Test public void evictionWithCause() { for (RemovalCause cause : RemovalCause.values()) { stats.recordEviction(3, cause); assertThat(registry.histogram(PREFIX + ".evictions." + cause.name()).getCount()).isEqualTo(1); } }