@Test
public void shouldReportCacheHitMissMetrics() throws IOException {

  InOrder inOrder = Mockito.inOrder(stats, counterSnapshotFactory);
  // Verify we get a miss first time
  shardedCounter.getCounterSnapshot(COUNTER_ID1);
  inOrder.verify(stats).recordCounterCacheMiss();
  inOrder.verify(counterSnapshotFactory).create(COUNTER_ID1);
  // Snapshot should be cached now
  shardedCounter.getCounterSnapshot(COUNTER_ID1);
  inOrder.verify(stats).recordCounterCacheHit();
  // Snapshot should still be cached
  shardedCounter.getCounterSnapshot(COUNTER_ID1);
  inOrder.verify(stats).recordCounterCacheHit();
  // Invalidate the cache and verify we get a miss
  shardedCounter.inMemSnapshot.invalidate(COUNTER_ID1);
  shardedCounter.getCounterSnapshot(COUNTER_ID1);
  inOrder.verify(stats).recordCounterCacheMiss();
  inOrder.verify(counterSnapshotFactory).create(COUNTER_ID1);
  inOrder.verifyNoMoreInteractions();
}