### Question:
InfluxdbReporter extends AbstractReporter<MeasurementInfo> implements Scheduled { @Override public void report() { BatchPoints report = buildReport(); if (report != null) { influxDB.write(report); } } InfluxdbReporter(); @Override void open(MetricConfig config); @Override void close(); @Override void report();  }### Answer:
@Test public void testMetricReporting() throws Exception { MetricRegistryImpl metricRegistry = createMetricRegistry(); try { String metricName = "TestCounter"; Counter counter = registerTestMetric(metricName, metricRegistry); counter.inc(42); stubFor(post(urlPathEqualTo("/write")) .willReturn(aResponse() .withStatus(200))); InfluxdbReporter reporter = (InfluxdbReporter) metricRegistry.getReporters().get(0); reporter.report(); verify(postRequestedFor(urlPathEqualTo("/write")) .withQueryParam("db", equalTo(TEST_INFLUXDB_DB)) .withHeader("Content-Type", containing("text/plain")) .withRequestBody(containing("taskmanager_" + metricName + ",host=" + METRIC_HOSTNAME + ",tm_id=" + METRIC_TM_ID + " count=42i"))); } finally { metricRegistry.shutdown().get(); } }
@Test public void testMetricReporting() throws Exception { String retentionPolicy = "one_hour"; MetricRegistryImpl metricRegistry = createMetricRegistry(retentionPolicy); try { String metricName = "TestCounter"; Counter counter = registerTestMetric(metricName, metricRegistry); counter.inc(42); stubFor(post(urlPathEqualTo("/write")) .willReturn(aResponse() .withStatus(200))); InfluxdbReporter reporter = (InfluxdbReporter) metricRegistry.getReporters().get(0); reporter.report(); verify(postRequestedFor(urlPathEqualTo("/write")) .withQueryParam("db", equalTo(TEST_INFLUXDB_DB)) .withQueryParam("rp", equalTo(retentionPolicy)) .withHeader("Content-Type", containing("text/plain")) .withRequestBody(containing("taskmanager_" + metricName + ",host=" + METRIC_HOSTNAME + ",tm_id=" + METRIC_TM_ID + " count=42i"))); } finally { metricRegistry.shutdown().get(); } }
@Test public void testMetricReporting() throws Exception { String retentionPolicy = "one_hour"; InfluxDB.ConsistencyLevel consistencyLevel = InfluxDB.ConsistencyLevel.ANY; MetricRegistryImpl metricRegistry = createMetricRegistry(retentionPolicy, consistencyLevel); try { String metricName = "TestCounter"; Counter counter = registerTestMetric(metricName, metricRegistry); counter.inc(42); stubFor(post(urlPathEqualTo("/write")) .willReturn(aResponse() .withStatus(200))); InfluxdbReporter reporter = (InfluxdbReporter) metricRegistry.getReporters().get(0); reporter.report(); verify(postRequestedFor(urlPathEqualTo("/write")) .withQueryParam("db", equalTo(TEST_INFLUXDB_DB)) .withQueryParam("rp", equalTo(retentionPolicy)) .withQueryParam("consistency", equalTo(consistencyLevel.name().toLowerCase())) .withHeader("Content-Type", containing("text/plain")) .withRequestBody(containing("taskmanager_" + metricName + ",host=" + METRIC_HOSTNAME + ",tm_id=" + METRIC_TM_ID + " count=42i"))); } finally { metricRegistry.shutdown().get(); } }