@Test public void requireThatMetricProviderDelegatesToConsumerFactory() { MetricConsumer consumer = Mockito.mock(MetricConsumer.class); MetricProvider provider = MetricProviders.newInstance(consumer); Metric metric = provider.get(); assertNotNull(metric); Metric.Context fooCtx = Mockito.mock(Metric.Context.class); metric.add("foo", 6, fooCtx); metric.set("foo", 9, fooCtx); Mockito.verify(consumer, Mockito.times(1)).add("foo", 6, fooCtx); Mockito.verify(consumer, Mockito.times(1)).set("foo", 9, fooCtx); }
@Override public Metric get() { return metric; }
MetricProvider implements Provider<Metric> { @Override public Metric get() { return metric; } }
MetricProvider implements Provider<Metric> { @Override public Metric get() { return metric; } MetricProvider(MetricConsumerProvider provider); }
MetricProvider implements Provider<Metric> { @Override public Metric get() { return metric; } MetricProvider(MetricConsumerProvider provider); @Override Metric get(); @Override void deconstruct(); }
MetricProvider implements Provider<Metric> { @Override public Metric get() { return metric; } MetricProvider(MetricConsumerProvider provider); @Override Metric get(); @Override void deconstruct();  }