### Question:
CollectorProxy implements Collector { @Override public void collectGaugeValues(List<GaugeValue> gaugeValues) throws Exception { if (instance == null) { earlyGaugeValues.offer(gaugeValues); if (instance != null) { earlyGaugeValues.remove(gaugeValues); instance.collectGaugeValues(gaugeValues); } } else { instance.collectGaugeValues(gaugeValues); } }  @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 testCollectGaugeValues() throws Exception { CollectorProxy collectorProxy = new CollectorProxy(); @SuppressWarnings("unchecked") List<GaugeValue> gaugeValues1 = mock(List.class); @SuppressWarnings("unchecked") List<GaugeValue> gaugeValues2 = mock(List.class); @SuppressWarnings("unchecked") List<GaugeValue> gaugeValues3 = mock(List.class); collectorProxy.collectGaugeValues(gaugeValues1); collectorProxy.collectGaugeValues(gaugeValues2); Collector collector = mock(Collector.class); collectorProxy.setInstance(collector); collectorProxy.collectGaugeValues(gaugeValues3); InOrder inOrder = Mockito.inOrder(collector); inOrder.verify(collector).collectGaugeValues(gaugeValues1); inOrder.verify(collector).collectGaugeValues(gaugeValues2); inOrder.verify(collector).collectGaugeValues(gaugeValues3); }