### Question:
RollupTypeCacher extends FunctionWithThreadPool<MetricsCollection, Void> { @Override public Void apply(final MetricsCollection input) throws Exception { getThreadPool().submit(new Runnable() { @Override public void run() { recordWithTimer(input); } }); return null; } RollupTypeCacher(ThreadPoolExecutor executor, MetadataCache cache); @Override Void apply(final MetricsCollection input);  }### Answer:
@Test public void testCacher() throws Exception { MetricsCollection collection = createTestData(); MetadataCache rollupTypeCache = mock(MetadataCache.class); ThreadPoolExecutor tpe = new ThreadPoolBuilder().withName("rtc test").build(); RollupTypeCacher rollupTypeCacher = new RollupTypeCacher(tpe, rollupTypeCache); rollupTypeCacher.apply(collection); while (tpe.getCompletedTaskCount() < 1) { Thread.sleep(1); } verifyZeroInteractions(rollupTypeCache); }
@Test public void testCacherDoesCacheRollupTypeForPreAggregatedMetrics() throws Exception { MetricsCollection collection = createPreaggregatedTestMetrics(); MetadataCache rollupTypeCache = mock(MetadataCache.class); ThreadPoolExecutor tpe = new ThreadPoolBuilder().withName("rtc test").build(); RollupTypeCacher rollupTypeCacher = new RollupTypeCacher(tpe, rollupTypeCache); rollupTypeCacher.apply(collection); while (tpe.getCompletedTaskCount() < 1) { Thread.sleep(1); } for (IMetric m : collection.toMetrics()) { verify(rollupTypeCache).put(m.getLocator(), cacheKey, m.getRollupType().toString()); } }