title: Error with Zipkin in unit test (cannot mock Span.baggageItems)
body: <p>I am getting this error when I try to run the unitTest in my spring boot application.</p>
  
  <pre><code>java.lang.NullPointerException: null
  at org.springframework.cloud.sleuth.Span.baggageItems(Span.java:381)
  at org.springframework.cloud.sleuth.instrument.web.ZipkinHttpSpanInjector.inject(ZipkinHttpSpanInjector.java:27)
  at org.springframework.cloud.sleuth.instrument.web.ZipkinHttpSpanInjector.inject(ZipkinHttpSpanInjector.java:15)
  at org.springframework.cloud.sleuth.instrument.web.client.AbstractTraceHttpRequestInterceptor.publishStartEvent(AbstractTraceHttpRequestInterceptor.java:60)
  at org.springframework.cloud.sleuth.instrument.web.client.TraceRestTemplateInterceptor.intercept(TraceRestTemplateInterceptor.java:52)
  at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:86)
  </code></pre>
  
  <p>I notice that I only get this error when I use this version for <strong><em>spring-cloud-dependencies</em></strong>:</p>
  
  <pre><code>&lt;spring-cloud.version&gt;Dalston.RELEASE&lt;/spring-cloud.version&gt;
  </code></pre>
  
  <p>but if I use this previous version:</p>
  
  <pre><code>&lt;spring-cloud.version&gt;Camden.SR6&lt;/spring-cloud.version&gt;
  </code></pre>
  
  <p>everything works as I expect</p>
  
  <p>What can I do in order to avoid this error with the last version?</p>
  
  <p>The unit tests are extended this class in order to mock the SpanAccessor</p>
  
  <pre><code>public class AbstractSpanAccessorTest {
  
  @MockBean
  private Tracer tracer;
  
  @MockBean
  private Span span;
  
  private Random random = new Random();
  
  @Before
  public void mockSpan() {
      long id = createId();
      Span spanMock = Span.builder().name("mock").traceId(id).spanId(id).build();
      doReturn(spanMock.traceIdString()).when(span).traceIdString();
      doReturn(span).when(tracer).getCurrentSpan();
      doReturn(span).when(tracer).createSpan(anyString());
  }
  
  private long createId() {
      return random.nextLong();
  }
  </code></pre>
  
  <p>}</p>