FilteringPluginSink implements PluginSink { @Override public void sendMetric(final Metric metric) { if (filter.matchesMetric(metric)) { sink.sendMetric(metric); } } FilteringPluginSink(final Filter filter); @Override void init(); @Override void sendMetric(final Metric metric); @Override void sendBatch(final Batch batch); @Override AsyncFuture<Void> start(); @Override AsyncFuture<Void> stop(); @Override boolean isReady(); PluginSink getSink();  }
@Test public void testSendMetricTrueFilter() { doNothing().when(childSink).sendMetric(metric); ArgumentCaptor<Metric> captor = ArgumentCaptor.forClass(Metric.class); sink.sendMetric(metric); verify(childSink, times(1)).sendMetric(captor.capture()); Metric sentMetric = captor.getValue(); assertEquals("test_metric", sentMetric.getKey()); }
@Test public void testSendMetricNotFilter() { sink.filter = new NotFilter(new MatchKey(metric.getKey())); doNothing().when(childSink).sendMetric(metric); ArgumentCaptor<Metric> captor = ArgumentCaptor.forClass(Metric.class); sink.sendMetric(metric); verify(childSink, times(0)).sendMetric(captor.capture()); }