### Question:
CollectorProxy implements Collector { @Override public void log(LogEvent logEvent) throws Exception { if (instance == null) { earlyLogEvents.offer(logEvent); if (instance != null) { earlyLogEvents.remove(logEvent); instance.log(logEvent); } } else { instance.log(logEvent); } }  @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);  }### Answer:
@Test public void testLog() throws Exception { CollectorProxy collectorProxy = new CollectorProxy(); LogEvent logEvent1 = LogEvent.newBuilder() .setMessage("one") .build(); LogEvent logEvent2 = LogEvent.newBuilder() .setMessage("two") .build(); LogEvent logEvent3 = LogEvent.newBuilder() .setMessage("three") .build(); collectorProxy.log(logEvent1); collectorProxy.log(logEvent2); Collector collector = mock(Collector.class); collectorProxy.setInstance(collector); collectorProxy.log(logEvent3); InOrder inOrder = Mockito.inOrder(collector); inOrder.verify(collector).log(logEvent1); inOrder.verify(collector).log(logEvent2); inOrder.verify(collector).log(logEvent3); }