HttpTagAndSpanNamingStrategy { protected void putTagIfValueIsNotBlank( @NotNull Span span, @NotNull String tagKey, @Nullable Object tagValue ) { if (tagValue == null || span == null || tagKey == null) { return; } String tagValueString = tagValue.toString(); if (StringUtils.isBlank(tagValueString)) { return; } span.putTag(tagKey, tagValueString); }  final @Nullable String getInitialSpanName(
        @NotNull REQ request,
        @NotNull HttpTagAndSpanNamingAdapter<REQ, ?> adapter
    ); final void handleRequestTagging(
        @NotNull Span span,
        @NotNull REQ request,
        @NotNull HttpTagAndSpanNamingAdapter<REQ, ?> adapter
    ); final void handleResponseTaggingAndFinalSpanName(
        @NotNull Span span,
        @Nullable REQ request,
        @Nullable RES response,
        @Nullable Throwable error,
        @NotNull HttpTagAndSpanNamingAdapter<REQ, RES> adapter
    );  }
@Test public void putTagIfValueIsNotBlank_calls_span_putTag_as_expected_for_tagValue_toString_when_result_is_not_blank() { Object tagValueMock = mock(Object.class); String tagValueToStringResult = "tag_value-" + UUID.randomUUID().toString(); doReturn(tagValueToStringResult).when(tagValueMock).toString(); String tagKey = "tag_key-" + UUID.randomUUID().toString(); implSpy.putTagIfValueIsNotBlank(spanMock, tagKey, tagValueMock); verify(spanMock).putTag(tagKey, tagValueToStringResult); }
@DataProvider(value = { "null", "", "[whitespace]" }, splitBy = "\\|") @Test public void putTagIfValueIsNotBlank_does_nothing_when_tagValue_toString_IS_blank( String blankTagValueToStringResult ) { if ("[whitespace]".equals(blankTagValueToStringResult)) { blankTagValueToStringResult = " \n\r\t "; } Object tagValueMock = mock(Object.class); doReturn(blankTagValueToStringResult).when(tagValueMock).toString(); String tagKey = "tag_key-" + UUID.randomUUID().toString(); implSpy.putTagIfValueIsNotBlank(spanMock, tagKey, tagValueMock); verify(spanMock, never()).putTag(anyString(), anyString()); }
@DataProvider(value = { "true | false | false", "false | true | false", "false | false | true" }, splitBy = "\\|") @Test public void putTagIfValueIsNotBlank_does_nothing_when_any_arg_is_null( boolean spanIsNull, boolean tagKeyIsNull, boolean tagValueIsNull ) { Span span = (spanIsNull) ? null : spanMock; String tagKey = (tagKeyIsNull) ? null : UUID.randomUUID().toString(); String tagValue = (tagValueIsNull) ? null : UUID.randomUUID().toString(); implSpy.putTagIfValueIsNotBlank(span, tagKey, tagValue); verify(spanMock, never()).putTag(anyString(), anyString()); }