### Question:
CurrentSpanUtils { public static Runnable withSpan(Span span, boolean endSpan, Runnable runnable) { return new RunnableInSpan(span, runnable, endSpan); } private  CurrentSpanUtils(); static Runnable withSpan(Span span, boolean endSpan, Runnable runnable); static Callable<C> withSpan(Span span, boolean endSpan, Callable<C> callable);  }### Answer:
@Test void withSpanRunnable() { assertThat(getCurrentSpan()).isInstanceOf(DefaultSpan.class); Runnable runnable = () -> { assertThat(getCurrentSpan()).isSameAs(span); }; CurrentSpanUtils.withSpan(span, false, runnable).run(); verifyNoInteractions(span); assertThat(getCurrentSpan()).isInstanceOf(DefaultSpan.class); }
@Test void withSpanRunnable_EndSpan() { assertThat(getCurrentSpan()).isInstanceOf(DefaultSpan.class); Runnable runnable = () -> { assertThat(getCurrentSpan()).isSameAs(span); }; CurrentSpanUtils.withSpan(span, true, runnable).run(); verify(span).end(); assertThat(getCurrentSpan()).isInstanceOf(DefaultSpan.class); }
@Test void withSpanCallable() throws Exception { final Object ret = new Object(); assertThat(getCurrentSpan()).isInstanceOf(DefaultSpan.class); Callable<Object> callable = () -> { assertThat(getCurrentSpan()).isSameAs(span); return ret; }; assertThat(CurrentSpanUtils.withSpan(span, false, callable).call()).isEqualTo(ret); verifyNoInteractions(span); assertThat(getCurrentSpan()).isInstanceOf(DefaultSpan.class); }
@Test void withSpanCallable_EndSpan() throws Exception { final Object ret = new Object(); assertThat(getCurrentSpan()).isInstanceOf(DefaultSpan.class); Callable<Object> callable = () -> { assertThat(getCurrentSpan()).isSameAs(span); return ret; }; assertThat(CurrentSpanUtils.withSpan(span, true, callable).call()).isEqualTo(ret); verify(span).end(); assertThat(getCurrentSpan()).isInstanceOf(DefaultSpan.class); }