### Question:
StringCodec implements Codec<StringBuilder> { @Override public JaegerSpanContext extract(StringBuilder s) { if (s == null) { throw new EmptyTracerStateStringException(); } String value = s.toString(); if (!"".equals(value)) { String[] parts = value.split(":"); if (parts.length != 4) { if (LOG.isDebugEnabled()) { LOG.debug("MalformedTracerStateString: {}", value); } throw new MalformedTracerStateStringException(value); } else { String traceId = parts[0]; if (traceId.length() <= 32 && traceId.length() >= 1) { return new JaegerSpanContext(high(traceId), (new BigInteger(traceId, 16)).longValue(), (new BigInteger(parts[1], 16)).longValue(), (new BigInteger(parts[2], 16)).longValue(), (new BigInteger(parts[3], 16)).byteValue()); } else { throw new TraceIdOutOfBoundException( "Trace id [" + traceId + "] length is not within 1 and 32"); } } } else { throw new EmptyTracerStateStringException(); } }  @Override JaegerSpanContext extract(StringBuilder s); @Override void inject(JaegerSpanContext context, StringBuilder string); static final Logger LOG; static final StringFormat FORMAT; }### Answer:
@Test void testExtract() throws Exception { StringCodec codec = new StringCodec(); LambdaTestUtils.intercept(EmptyTracerStateStringException.class, () -> codec.extract(null)); StringBuilder sb = new StringBuilder().append("123"); LambdaTestUtils.intercept(MalformedTracerStateStringException.class, "String does not match tracer state format", () -> codec.extract(sb)); sb.append(":456:789"); LambdaTestUtils.intercept(MalformedTracerStateStringException.class, "String does not match tracer state format", () -> codec.extract(sb)); sb.append(":66"); JaegerSpanContext context = codec.extract(sb); String expectedContextString = new String("123:456:789:66"); assertTrue(context.getTraceId().equals("123")); assertTrue(context.toString().equals(expectedContextString)); }