### Question:
AwsXRayPropagator implements TextMapPropagator { @Override public <C> void inject(Context context, @Nullable C carrier, Setter<C> setter) { Objects.requireNonNull(context, "context"); Objects.requireNonNull(setter, "setter"); Span span = TracingContextUtils.getSpan(context); if (!span.getContext().isValid()) { return; } SpanContext spanContext = span.getContext(); String otTraceId = spanContext.getTraceIdAsHexString(); String xrayTraceId = TRACE_ID_VERSION + TRACE_ID_DELIMITER + otTraceId.substring(0, TRACE_ID_FIRST_PART_LENGTH) + TRACE_ID_DELIMITER + otTraceId.substring(TRACE_ID_FIRST_PART_LENGTH); String parentId = spanContext.getSpanIdAsHexString(); char samplingFlag = spanContext.isSampled() ? IS_SAMPLED : NOT_SAMPLED; String traceHeader = TRACE_ID_KEY + KV_DELIMITER + xrayTraceId + TRACE_HEADER_DELIMITER + PARENT_ID_KEY + KV_DELIMITER + parentId + TRACE_HEADER_DELIMITER + SAMPLED_FLAG_KEY + KV_DELIMITER + samplingFlag; setter.set(carrier, TRACE_HEADER_KEY, traceHeader); } private  AwsXRayPropagator(); static AwsXRayPropagator getInstance(); @Override List<String> fields(); @Override void inject(Context context, @Nullable C carrier, Setter<C> setter); @Override Context extract(Context context, C carrier, Getter<C> getter);  }### Answer:
@Test void inject_SampledContext() { Map<String, String> carrier = new LinkedHashMap<>(); xrayPropagator.inject( withSpanContext( SpanContext.create( TRACE_ID_BASE16, SPAN_ID_BASE16, SAMPLED_TRACE_FLAG, TRACE_STATE_DEFAULT), Context.current()), carrier, setter); assertThat(carrier) .containsEntry( TRACE_HEADER_KEY, "Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1"); }
@Test void inject_NotSampledContext() { Map<String, String> carrier = new LinkedHashMap<>(); xrayPropagator.inject( withSpanContext( SpanContext.create( TRACE_ID_BASE16, SPAN_ID_BASE16, TraceFlags.getDefault(), TRACE_STATE_DEFAULT), Context.current()), carrier, setter); assertThat(carrier) .containsEntry( TRACE_HEADER_KEY, "Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=0"); }
@Test void inject_WithTraceState() { Map<String, String> carrier = new LinkedHashMap<>(); xrayPropagator.inject( withSpanContext( SpanContext.create( TRACE_ID_BASE16, SPAN_ID_BASE16, TraceFlags.getDefault(), TraceState.builder().set("foo", "bar").build()), Context.current()), carrier, setter); assertThat(carrier) .containsEntry( TRACE_HEADER_KEY, "Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=0"); }