### Question:
RawMetricsPublisher extends AbstractMetricPublisher { @Override protected String processMetrics(Map<String, TimelineMetrics> metricValues) { TimelineMetrics timelineMetrics = new TimelineMetrics(); for (TimelineMetrics metrics : metricValues.values()) { for (TimelineMetric timelineMetric : metrics.getMetrics()) timelineMetrics.addOrMergeTimelineMetric(timelineMetric); } String json = null; try { json = mapper.writeValueAsString(timelineMetrics); LOG.debug(json); } catch (Exception e) { LOG.error("Failed to convert result into json", e); } return json; } RawMetricsPublisher(TimelineMetricsHolder timelineMetricsHolder, Configuration configuration, int interval);   }### Answer:
@Test public void testProcessMetrics() throws Exception { Configuration configuration = new Configuration(); TimelineMetricsHolder timelineMetricsHolder = TimelineMetricsHolder.getInstance(); timelineMetricsHolder.extractMetricsForAggregationPublishing(); timelineMetricsHolder.extractMetricsForRawPublishing(); TreeMap<Long, Double> metric1App1Metrics = new TreeMap<>(); metric1App1Metrics.put(1L, 1d); metric1App1Metrics.put(2L, 2d); metric1App1Metrics.put(3L, 3d); timelineMetricsHolder.putMetricsForRawPublishing(getTimelineMetricsForAppId("metricName1", "app1", metric1App1Metrics)); TreeMap<Long, Double> metric2App2Metrics = new TreeMap<>(); metric2App2Metrics.put(1L, 4d); metric2App2Metrics.put(2L, 5d); metric2App2Metrics.put(3L, 6d); timelineMetricsHolder.putMetricsForRawPublishing(getTimelineMetricsForAppId("metricName2", "app2", metric2App2Metrics)); TreeMap<Long, Double> metric3App3Metrics = new TreeMap<>(); metric3App3Metrics.put(1L, 7d); metric3App3Metrics.put(2L, 8d); metric3App3Metrics.put(3L, 9d); timelineMetricsHolder.putMetricsForRawPublishing(getTimelineMetricsForAppId("metricName3", "app3", metric3App3Metrics)); RawMetricsPublisher rawMetricsPublisher = new RawMetricsPublisher(TimelineMetricsHolder.getInstance(), configuration, 60); String rawJson = rawMetricsPublisher.processMetrics(timelineMetricsHolder.extractMetricsForRawPublishing()); String expectedResult = "{\"metrics\":[{\"timestamp\":0,\"metadata\":{},\"metricname\":\"metricName1\",\"appid\":\"app1\",\"starttime\":0,\"metrics\":{\"1\":1.0,\"2\":2.0,\"3\":3.0}},{\"timestamp\":0,\"metadata\":{},\"metricname\":\"metricName2\",\"appid\":\"app2\",\"starttime\":0,\"metrics\":{\"1\":4.0,\"2\":5.0,\"3\":6.0}},{\"timestamp\":0,\"metadata\":{},\"metricname\":\"metricName3\",\"appid\":\"app3\",\"starttime\":0,\"metrics\":{\"1\":7.0,\"2\":8.0,\"3\":9.0}}]}"; Assert.assertNotNull(rawJson); Assert.assertEquals(expectedResult, rawJson); }