File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
main/java/io/opentelemetry/sdk/testing/assertj
test/java/io/opentelemetry/sdk/testing/assertj Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -59,9 +59,10 @@ public TraceAssert hasSpansSatisfyingExactly(
5959 List <Consumer <SpanDataAssert >> assertionsList =
6060 StreamSupport .stream (assertions .spliterator (), false ).collect (Collectors .toList ());
6161 hasSize (assertionsList .size ());
62+
6263 // Avoid zipSatisfy - https://github.com/assertj/assertj-core/issues/2300
6364 for (int i = 0 ; i < assertionsList .size (); i ++) {
64- assertionsList .get (i ).accept (new SpanDataAssert (actual .get (i )));
65+ assertionsList .get (i ).accept (new SpanDataAssert (actual .get (i )). describedAs ( "Span " + i ) );
6566 }
6667 return this ;
6768 }
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ public TracesAssert hasTracesSatisfyingExactly(
105105 hasSize (assertionsList .size ());
106106 // Avoid zipSatisfy - https://github.com/assertj/assertj-core/issues/2300
107107 for (int i = 0 ; i < assertionsList .size (); i ++) {
108- assertionsList .get (i ).accept (new TraceAssert (actual .get (i )));
108+ assertionsList .get (i ).accept (new TraceAssert (actual .get (i )). describedAs ( "Trace " + i ) );
109109 }
110110 return this ;
111111 }
Original file line number Diff line number Diff line change @@ -680,6 +680,15 @@ void hasSpansSatisfyingExactly() {
680680 trace ->
681681 trace .hasSpansSatisfyingExactly (
682682 span -> span .hasSpanId (SPAN_ID1 ), span -> span .hasSpanId (SPAN_ID2 )));
683+ // wrong number of spans
684+ assertThatThrownBy (
685+ () ->
686+ TracesAssert .assertThat (traces )
687+ .hasTracesSatisfyingExactly (
688+ trace -> trace .hasSpansSatisfyingExactly (span -> span .hasSpanId (SPAN_ID1 ))))
689+ .isInstanceOf (AssertionError .class )
690+ .hasMessageStartingWith ("[Trace 0] \n " + "Expected size: 1 but was: 2" );
691+
683692 // test asserting spans in wrong oder
684693 assertThatThrownBy (
685694 () ->
@@ -689,7 +698,9 @@ void hasSpansSatisfyingExactly() {
689698 trace .hasSpansSatisfyingExactly (
690699 span -> span .hasSpanId (SPAN_ID2 ),
691700 span -> span .hasSpanId (SPAN_ID1 ))))
692- .isInstanceOf (AssertionError .class );
701+ .isInstanceOf (AssertionError .class )
702+ .hasMessage (
703+ "[Span 0] Expected span [span1] to have span ID <0000000000000004> but was <0000000000000003>" );
693704
694705 // test asserting spans in any order
695706 TracesAssert .assertThat (traces )
You can’t perform that action at this time.
0 commit comments