@Test public void equalsAndHashCode() {

  // same instance are equivalent
  Propagation.Factory factory = B3Propagation.newFactoryBuilder()
      .injectFormat(Span.Kind.CLIENT, Format.SINGLE_NO_PARENT)
      .injectFormat(Span.Kind.SERVER, Format.SINGLE_NO_PARENT)
      .build();
  assertThat(factory).isEqualTo(factory);
  // same formats are equivalent
  Propagation.Factory sameFields = B3Propagation.newFactoryBuilder()
      .injectFormat(Span.Kind.CLIENT, Format.SINGLE_NO_PARENT)
      .injectFormat(Span.Kind.SERVER, Format.SINGLE_NO_PARENT)
      .build();
  assertThat(factory.equals(sameFields)).isTrue();
  assertThat(sameFields).isEqualTo(factory);
  assertThat(sameFields).hasSameHashCodeAs(factory);
  // different formats are not equivalent
  assertThat(factory).isNotEqualTo(B3Propagation.FACTORY);
  assertThat(B3Propagation.FACTORY).isNotEqualTo(factory);
  assertThat(factory.hashCode()).isNotEqualTo(B3Propagation.FACTORY.hashCode());
}