### Question:
SimpleSpanProcessor implements SpanProcessor { @Override public void onEnd(ReadableSpan span) { if (sampled && !span.getSpanContext().isSampled()) { return; } try { List<SpanData> spans = Collections.singletonList(span.toSpanData()); final CompletableResultCode result = spanExporter.export(spans); result.whenComplete( new Runnable() { @Override public void run() { if (!result.isSuccess()) { logger.log(Level.FINE, "Exporter failed"); } } }); } catch (Exception e) { logger.log(Level.WARNING, "Exporter threw an Exception", e); } } private  SimpleSpanProcessor(SpanExporter spanExporter, boolean sampled); @Override void onStart(ReadWriteSpan span); @Override boolean isStartRequired(); @Override void onEnd(ReadableSpan span); @Override boolean isEndRequired(); @Override CompletableResultCode shutdown(); @Override CompletableResultCode forceFlush(); static Builder newBuilder(SpanExporter spanExporter);  }### Answer:
@Test void onEndSync_SampledSpan() { SpanData spanData = TestUtils.makeBasicSpan(); when(readableSpan.getSpanContext()).thenReturn(SAMPLED_SPAN_CONTEXT); when(readableSpan.toSpanData()).thenReturn(spanData); simpleSampledSpansProcessor.onEnd(readableSpan); verify(spanExporter).export(Collections.singletonList(spanData)); }
@Test void onEndSync_NotSampledSpan() { when(readableSpan.getSpanContext()).thenReturn(NOT_SAMPLED_SPAN_CONTEXT); simpleSampledSpansProcessor.onEnd(readableSpan); verifyNoInteractions(spanExporter); }
@Test void onEndSync_ExporterReturnError() { SpanData spanData = TestUtils.makeBasicSpan(); when(readableSpan.getSpanContext()).thenReturn(SAMPLED_SPAN_CONTEXT); when(readableSpan.toSpanData()).thenReturn(spanData); simpleSampledSpansProcessor.onEnd(readableSpan); simpleSampledSpansProcessor.onEnd(readableSpan); verify(spanExporter, times(2)).export(Collections.singletonList(spanData)); }