SpanMutator { public static void changeSpanName(@Nullable Span span, @Nullable String newName) { if (span == null) { return; } if (StringUtils.isBlank(newName)) { return; } span.setSpanName(newName); } private  SpanMutator(); static void changeSpanName(@Nullable Span span, @Nullable String newName);  }
@Test public void changeSpanName_works_as_expected() { Span span = Span.newBuilder("origSpanName", Span.SpanPurpose.SERVER).build(); String newSpanName = UUID.randomUUID().toString(); assertThat(span.getSpanName()).isNotEqualTo(newSpanName); SpanMutator.changeSpanName(span, newSpanName); assertThat(span.getSpanName()).isEqualTo(newSpanName); }
@Test public void changeSpanName_does_nothing_if_passed_null_span() { SpanMutator.changeSpanName(null, "foo"); }
@Test public void changeSpanName_does_nothing_if_passed_null_newName() { Span spanMock = mock(Span.class); SpanMutator.changeSpanName(spanMock, null); verifyZeroInteractions(spanMock); }