BaggageField { public static BaggageField create(String name) { return new BaggageField(name, ExtraBaggageContext.get()); } BaggageField(String name, BaggageContext context); static BaggageField create(String name); @Deprecated static List<BaggageField> getAll(@Nullable TraceContext context); @Deprecated static List<BaggageField> getAll(TraceContextOrSamplingFlags extracted); @Deprecated @Nullable static List<BaggageField> getAll(); static Map<String, String> getAllValues(@Nullable TraceContext context); static Map<String, String> getAllValues(TraceContextOrSamplingFlags extracted); @Nullable static Map<String, String> getAllValues(); @Nullable static BaggageField getByName(@Nullable TraceContext context, String name); @Nullable static BaggageField getByName(TraceContextOrSamplingFlags extracted,
      String name); @Nullable static BaggageField getByName(String name); final String name(); @Nullable String getValue(@Nullable TraceContext context); @Nullable String getValue(); @Nullable String getValue(TraceContextOrSamplingFlags extracted); boolean updateValue(@Nullable TraceContext context, @Nullable String value); boolean updateValue(TraceContextOrSamplingFlags extracted, @Nullable String value); boolean updateValue(String value); @Override String toString(); @Override final boolean equals(Object o); @Override final int hashCode();  }
@Test public void internalStorage() { assertThat(BaggageField.create("foo").context) .isSameAs(ExtraBaggageContext.get()); BaggageContext context = mock(BaggageContext.class); assertThat(new BaggageField("context", context).context) .isSameAs(context); }
@Test public void create_invalid() { assertThatThrownBy(() -> BaggageField.create(null)) .isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> BaggageField.create("")) .isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> BaggageField.create(" ")) .isInstanceOf(IllegalArgumentException.class); }
@Test public void toString_onlyHasName() { assertThat(BaggageField.create("Foo")) .hasToString("BaggageField{Foo}"); }