### Question:
TextMapPropagator implements Propagator { public <C> SpanContext extract(C carrier) { if (!(carrier instanceof TextMapExtract)) { return null; } Long traceId = null; Long spanId = null; Map<String, String> baggage = new HashMap<>(); for (Map.Entry<String, String> entry : (TextMapExtract)carrier) { String key = entry.getKey().toLowerCase(english); if (FIELD_NAME_TRACE_ID.equals(key)) { traceId = Util.fromHexString(entry.getValue()); } if (FIELD_NAME_SPAN_ID.equals(key)) { spanId = Util.fromHexString(entry.getValue()); } if (key.startsWith(PREFIX_BAGGAGE)) { baggage.put(key.substring(PREFIX_BAGGAGE.length()), entry.getValue()); } } if (traceId == null || spanId == null) { return null; } return new SpanContext(traceId, spanId, baggage); }  void inject(SpanContext spanContext, final C carrier); SpanContext extract(C carrier);  }### Answer:
@Test public void testExtract_mixedCaseIsLowered() { Map<String, String> mixedCaseHeaders = new HashMap<>(); mixedCaseHeaders.put("Ot-tracer-spanid", Long.toHexString(1)); mixedCaseHeaders.put("Ot-tracer-traceId", Long.toHexString(2)); mixedCaseHeaders.put("ot-Tracer-sampled", "true"); TextMapPropagator subject = new TextMapPropagator(); SpanContext span = subject.extract(new TextMapExtractAdapter(mixedCaseHeaders)); assertNotNull(span); assertEquals(span.getSpanId(), 1); assertEquals(span.getTraceId(), 2); }
@Test public void testExtractEmptyHeaders() { Map<String, String> headers = new HashMap<>(); headers.put("ot-tracer-spanid", ""); headers.put("ot-tracer-traceId", ""); TextMapPropagator subject = new TextMapPropagator(); SpanContext spanContext = subject.extract(new TextMapExtractAdapter(headers)); assertNull(spanContext); }
@Test public void testExtractInvalidHeaders() { Map<String, String> headers = new HashMap<>(); headers.put("ot-tracer-spanid", "#$%"); headers.put("ot-tracer-traceId", "#$%"); TextMapPropagator subject = new TextMapPropagator(); SpanContext spanContext = subject.extract(new TextMapExtractAdapter(headers)); assertNull(spanContext); }