PubsubPluginSink implements BatchablePluginSink { @Override public void sendMetric(final Metric metric) { sendMetrics(Collections.singletonList(metric)); }  @Override boolean isReady(); @Override void init(); @Override AsyncFuture<Void> sendMetrics(Collection<Metric> metrics); @Override AsyncFuture<Void> sendBatches(Collection<Batch> batches); @Override void sendMetric(final Metric metric); @Override void sendBatch(final Batch batch); @Override AsyncFuture<Void> start(); @Override AsyncFuture<Void> stop();  }
@Test public void testSendMetric() { when(publisher.publish(Mockito.any())).thenReturn(ApiFutures.immediateFuture("Sent")); sink.sendMetric(metric); verify(publisher).publish(isA(PubsubMessage.class)); }
@Test public void testSendMetricCache() { sink.writeCache = metric -> true; when(publisher.publish(Mockito.any())).thenReturn(ApiFutures.immediateFuture("Sent")); sink.sendMetric(metric); verifyZeroInteractions(publisher); }