B3Propagation implements Propagation<K> { public static FactoryBuilder newFactoryBuilder() { return new FactoryBuilder(); } B3Propagation(); static Propagation<String> get(); static FactoryBuilder newFactoryBuilder(); static final Propagation.Factory FACTORY; }
@Test public void injectFormat() { B3Propagation.Factory factory = (B3Propagation.Factory) B3Propagation.newFactoryBuilder() .injectFormat(Format.SINGLE) .build(); assertThat(factory.injectorFactory).extracting("injectorFunction") .isEqualTo(Format.SINGLE); }
@Test public void injectKindFormat() { B3Propagation.Factory factory = (B3Propagation.Factory) B3Propagation.newFactoryBuilder() .injectFormat(Span.Kind.CLIENT, Format.SINGLE) .build(); assertThat(factory.injectorFactory).extracting("clientInjectorFunction") .isEqualTo(Format.SINGLE); }
@Test public void injectKindFormats() { B3Propagation.Factory factory = (B3Propagation.Factory) B3Propagation.newFactoryBuilder() .injectFormats(Span.Kind.CLIENT, Format.SINGLE, Format.MULTI) .build(); assertThat(factory.injectorFactory).extracting("clientInjectorFunction.injectorFunctions") .asInstanceOf(InstanceOfAssertFactories.ARRAY) .containsExactly(Format.SINGLE, Format.MULTI); }
@Test public void injectKindFormats_cantBeSame() { assertThatThrownBy(() -> B3Propagation.newFactoryBuilder() .injectFormats(Span.Kind.CLIENT, Format.MULTI, Format.MULTI)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void injectKindFormats_cantBeBothSingle() { assertThatThrownBy(() -> B3Propagation.newFactoryBuilder() .injectFormats(Span.Kind.CLIENT, Format.SINGLE, Format.SINGLE_NO_PARENT)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void build_defaultIsSingleton() { assertThat(B3Propagation.newFactoryBuilder().build()) .isSameAs(B3Propagation.FACTORY); }
@Test public void equalsAndHashCode() { 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); 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); assertThat(factory).isNotEqualTo(B3Propagation.FACTORY); assertThat(B3Propagation.FACTORY).isNotEqualTo(factory); assertThat(factory.hashCode()).isNotEqualTo(B3Propagation.FACTORY.hashCode()); }