@Test public void testCollectAggregates() throws Exception { CollectorProxy collectorProxy = new CollectorProxy(); AggregateReader aggregateReader1 = mock(AggregateReader.class); AggregateReader aggregateReader2 = mock(AggregateReader.class); AggregateReader aggregateReader3 = mock(AggregateReader.class); collectorProxy.collectAggregates(aggregateReader1); collectorProxy.collectAggregates(aggregateReader2); Collector collector = mock(Collector.class); collectorProxy.setInstance(collector); collectorProxy.collectAggregates(aggregateReader3); InOrder inOrder = Mockito.inOrder(collector); inOrder.verify(collector).collectAggregates(aggregateReader1); inOrder.verify(collector).collectAggregates(aggregateReader2); inOrder.verify(collector).collectAggregates(aggregateReader3); }
@Override public void collectAggregates(AggregateReader aggregateReader) throws Exception { if (instance == null) { earlyAggregateReaders.offer(aggregateReader); if (instance != null) { earlyAggregateReaders.remove(aggregateReader); instance.collectAggregates(aggregateReader); } } else { instance.collectAggregates(aggregateReader); } }
CollectorProxy implements Collector { @Override public void collectAggregates(AggregateReader aggregateReader) throws Exception { if (instance == null) { earlyAggregateReaders.offer(aggregateReader); if (instance != null) { earlyAggregateReaders.remove(aggregateReader); instance.collectAggregates(aggregateReader); } } else { instance.collectAggregates(aggregateReader); } } }
CollectorProxy implements Collector { @Override public void collectAggregates(AggregateReader aggregateReader) throws Exception { if (instance == null) { earlyAggregateReaders.offer(aggregateReader); if (instance != null) { earlyAggregateReaders.remove(aggregateReader); instance.collectAggregates(aggregateReader); } } else { instance.collectAggregates(aggregateReader); } }  }
CollectorProxy implements Collector { @Override public void collectAggregates(AggregateReader aggregateReader) throws Exception { if (instance == null) { earlyAggregateReaders.offer(aggregateReader); if (instance != null) { earlyAggregateReaders.remove(aggregateReader); instance.collectAggregates(aggregateReader); } } else { instance.collectAggregates(aggregateReader); } }  @Override void init(File confDir, @Nullable File sharedConfDir, Environment environment,
            AgentConfig agentConfig, AgentConfigUpdater agentConfigUpdater); @Override void collectAggregates(AggregateReader aggregateReader); @Override void collectGaugeValues(List<GaugeValue> gaugeValues); @Override void collectTrace(TraceReader traceReader); @Override void log(LogEvent logEvent); @VisibleForTesting void setInstance(Collector instance); }
CollectorProxy implements Collector { @Override public void collectAggregates(AggregateReader aggregateReader) throws Exception { if (instance == null) { earlyAggregateReaders.offer(aggregateReader); if (instance != null) { earlyAggregateReaders.remove(aggregateReader); instance.collectAggregates(aggregateReader); } } else { instance.collectAggregates(aggregateReader); } }  @Override void init(File confDir, @Nullable File sharedConfDir, Environment environment,
            AgentConfig agentConfig, AgentConfigUpdater agentConfigUpdater); @Override void collectAggregates(AggregateReader aggregateReader); @Override void collectGaugeValues(List<GaugeValue> gaugeValues); @Override void collectTrace(TraceReader traceReader); @Override void log(LogEvent logEvent); @VisibleForTesting void setInstance(Collector instance);  }