### Question:
AggregatedMetricsPublisher extends AbstractMetricPublisher { @Override protected Map<String, TimelineMetrics> getMetricsFromCache() { return timelineMetricsHolder.extractMetricsForAggregationPublishing(); } AggregatedMetricsPublisher(TimelineMetricsHolder timelineMetricsHolder, Configuration configuration, int interval);   }### Answer:
@Test public void testGetMetricsFromCache() throws InterruptedException { TimelineMetricsHolder timelineMetricsHolder = TimelineMetricsHolder.getInstance(4,4, Collections.EMPTY_LIST); timelineMetricsHolder.extractMetricsForAggregationPublishing(); timelineMetricsHolder.extractMetricsForRawPublishing(); timelineMetricsHolder.putMetricsForAggregationPublishing(TimelineMetricsHolderTest.getTimelineMetricsWithAppID("aggr1")); timelineMetricsHolder.putMetricsForRawPublishing(TimelineMetricsHolderTest.getTimelineMetricsWithAppID("raw")); timelineMetricsHolder.putMetricsForAggregationPublishing(TimelineMetricsHolderTest.getTimelineMetricsWithAppID("aggr2")); Configuration configuration = new Configuration(); AggregatedMetricsPublisher aggregatedMetricsPublisher = new AggregatedMetricsPublisher(TimelineMetricsHolder.getInstance(), configuration, 1); Map<String, TimelineMetrics> metricsFromCache = aggregatedMetricsPublisher.getMetricsFromCache(); Assert.assertNotNull(metricsFromCache); Collection<TimelineMetrics> actualTimelineMetrics = metricsFromCache.values(); Assert.assertNotNull(actualTimelineMetrics); Assert.assertEquals(2, actualTimelineMetrics.size()); for (TimelineMetrics timelineMetrics : actualTimelineMetrics) { List<TimelineMetric> metrics = timelineMetrics.getMetrics(); Assert.assertEquals(1, metrics.size()); Assert.assertTrue(metrics.get(0).getAppId().contains("aggr")); } }