TraceMongoCommandListener implements CommandListener { @Override public void commandSucceeded(CommandSucceededEvent event) { Span span = threadLocalSpan.remove(); if (span == null) return; span.finish(); } TraceMongoCommandListener(MongoDBTracing mongoDBTracing);   TraceMongoCommandListener(ThreadLocalSpan threadLocalSpan); @Override void commandStarted(CommandStartedEvent event); @Override void commandSucceeded(CommandSucceededEvent event); @Override void commandFailed(CommandFailedEvent event);  }
@Test public void commandSucceeded_withoutCommandStarted() { listener.commandSucceeded(createCommandSucceededEvent()); verify(threadLocalSpan).remove(); verifyNoMoreInteractions(threadLocalSpan); }