### Question:
MetricReporter extends AbstractScheduledService { @Override protected void runOneIteration() { logger.fine("Running background metric push"); if (metricExporter.state() == State.FAILED) { startMetricExporter(); } ImmutableList.Builder<MetricPoint<?>> points = new ImmutableList.Builder<>(); for (Metric<?> metric : metricRegistry.getRegisteredMetrics()) { points.addAll(metric.getTimestampedValues()); logger.fine(String.format("Enqueued metric %s", metric)); MetricMetrics.pushedPoints.increment( metric.getMetricSchema().kind().name(), metric.getValueClass().toString()); } if (!writeQueue.offer(Optional.of(points.build()))) { logger.severe("writeQueue full, dropped a reporting interval of points"); } MetricMetrics.pushIntervals.increment(); } MetricReporter(
      MetricWriter metricWriter, long writeInterval, ThreadFactory threadFactory); @VisibleForTesting  MetricReporter(
      MetricWriter metricWriter,
      long writeInterval,
      ThreadFactory threadFactory,
      MetricRegistry metricRegistry,
      BlockingQueue<Optional<ImmutableList<MetricPoint<?>>>> writeQueue);   }### Answer:
@Test public void testRunOneIteration_enqueuesBatch() throws Exception { Metric<?> metric = new Counter("/name", "description", "vdn", ImmutableSet.<LabelDescriptor>of()); when(registry.getRegisteredMetrics()).thenReturn(ImmutableList.of(metric, metric)); MetricReporter reporter = new MetricReporter(writer, 10L, threadFactory, registry, writeQueue); reporter.runOneIteration(); verify(writeQueue).offer(Optional.of(ImmutableList.<MetricPoint<?>>of())); }