NoopAwareSpanHandler extends SpanHandler { public static SpanHandler create(SpanHandler[] handlers, AtomicBoolean noop) { if (handlers.length == 0) return SpanHandler.NOOP; if (handlers.length == 1) return new NoopAwareSpanHandler(handlers[0], noop); return new NoopAwareSpanHandler(new CompositeSpanHandler(handlers), noop); } NoopAwareSpanHandler(SpanHandler delegate, AtomicBoolean noop); static SpanHandler create(SpanHandler[] handlers,
      AtomicBoolean noop); @Override boolean begin(TraceContext context, MutableSpan span, TraceContext parent); @Override boolean end(TraceContext context, MutableSpan span, Cause cause); @Override boolean handlesAbandoned(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void create_emptyIsNoop() { assertThat(NoopAwareSpanHandler.create(new SpanHandler[0], noop)) .isEqualTo(SpanHandler.NOOP); }
@Test public void create_multiple() { SpanHandler[] handlers = new SpanHandler[2]; handlers[0] = one; handlers[1] = two; SpanHandler handler = NoopAwareSpanHandler.create(handlers, noop); assertThat(handler).extracting("delegate.handlers") .asInstanceOf(InstanceOfAssertFactories.array(SpanHandler[].class)) .containsExactly(one, two); }