### Question:
OverAllQueryMetrics { public Map<MetricType, Long> publish() { Map<MetricType, Long> metricsForPublish = new HashMap<>(); metricsForPublish.put(numParallelScans.getMetricType(), numParallelScans.getValue()); metricsForPublish.put(wallClockTimeMS.getMetricType(), wallClockTimeMS.getValue()); metricsForPublish.put(resultSetTimeMS.getMetricType(), resultSetTimeMS.getValue()); metricsForPublish.put(queryTimedOut.getMetricType(), queryTimedOut.getValue()); metricsForPublish.put(queryFailed.getMetricType(), queryFailed.getValue()); metricsForPublish.put(cacheRefreshedDueToSplits.getMetricType(), cacheRefreshedDueToSplits.getValue()); return metricsForPublish; } OverAllQueryMetrics(boolean isRequestMetricsEnabled, LogLevel connectionLogLevel); void updateNumParallelScans(long numParallelScans); void queryTimedOut(); void queryFailed(); void cacheRefreshedDueToSplits(); void startQuery(); void endQuery(); void startResultSetWatch(); void stopResultSetWatch(); Map<MetricType, Long> publish(); void reset(); OverAllQueryMetrics combine(OverAllQueryMetrics metric);  }### Answer:
@Test public void testPublish() { MyClock clock = new MyClock(10L, delta); EnvironmentEdgeManager.injectEdge(clock); overAllQueryMetrics.startQuery(); overAllQueryMetrics.startResultSetWatch(); assertPublishedMetrics(overAllQueryMetrics.publish(), numParallelScans, queryTimeouts, queryFailures, cacheRefreshesDueToSplits, 0L); overAllQueryMetrics.endQuery(); overAllQueryMetrics.stopResultSetWatch(); assertPublishedMetrics(overAllQueryMetrics.publish(), numParallelScans, queryTimeouts, queryFailures, cacheRefreshesDueToSplits, 2*delta); }
@Test public void testNoOpRequestMetricsIfRequestMetricsDisabled() { OverAllQueryMetrics noOpMetrics = new OverAllQueryMetrics(false, LogLevel.OFF); populateMetrics(noOpMetrics, numParallelScans, queryTimeouts, queryFailures, cacheRefreshesDueToSplits); Map<MetricType, Long> noOpMap = noOpMetrics.publish(); assertEquals(1, noOpMap.size()); assertEquals(0L, (long)noOpMap.get(NO_OP_METRIC)); }