ContextUtils { public static SpanContext headerToSpanContext(final TraceHeader header) { TraceId traceId = TraceId .fromLowerBase16(xrayTraceIdToOT(header.getRootTraceId().toString()), 0); SpanId spanId = SpanId.fromLowerBase16(header.getParentId().toLowerCase(), 0); TraceFlags flags = TraceFlags.builder() .setIsSampled(header.getSampled().equals(TraceHeader.SampleDecision.SAMPLED) || header.getSampled().equals(TraceHeader.SampleDecision.REQUESTED)) .build(); Tracestate state = Tracestate.getDefault(); return SpanContext.createFromRemoteParent(traceId, spanId, flags, state); }  static SpanContext entityToSpanContext(final Entity entity); static SpanContext headerToSpanContext(final TraceHeader header); static TraceHeader spanContextToHeader(final SpanContext context);  }
@Test public void when_aConTextIsGiven_then_aHeaderIsReturned() { assertEquals(context, ContextUtils.headerToSpanContext(header)); }