Class SpanAssert<SELF extends SpanAssert<SELF>>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,io.micrometer.tracing.exporter.FinishedSpan>
io.micrometer.tracing.test.simple.SpanAssert<SELF>
- All Implemented Interfaces:
org.assertj.core.api.Assert<SELF,,io.micrometer.tracing.exporter.FinishedSpan> org.assertj.core.api.Descriptable<SELF>,org.assertj.core.api.ExtensionPoints<SELF,io.micrometer.tracing.exporter.FinishedSpan>
- Direct Known Subclasses:
SpansAssert.SpansAssertReturningAssert
public class SpanAssert<SELF extends SpanAssert<SELF>>
extends org.assertj.core.api.AbstractAssert<SELF,io.micrometer.tracing.exporter.FinishedSpan>
Assertion methods for
SimpleSpans.
To create a new instance of this class, invoke
assertThat(FinishedSpan) or then(FinishedSpan).
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSyntactic sugar that extendsAbstractThrowableAssertmethods with an option to go back toSpanAssert. -
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSpanAssert(io.micrometer.tracing.exporter.FinishedSpan actual) Creates a new instance ofSpanAssert. -
Method Summary
Modifier and TypeMethodDescriptionstatic SpanAssertassertThat(io.micrometer.tracing.exporter.FinishedSpan actual) Creates the assert object forFinishedSpan.Syntactic sugar to assert a throwable on aFinishedSpan.getError().doesNotHaveEventWithNameEqualTo(String eventName) Verifies that this span does not have an event with a given name.Verifies that this span does not have ip equal to the given value.doesNotHaveKindEqualTo(io.micrometer.tracing.Span.Kind kind) Verifies that this span doesn't have span kind equal to the given value.doesNotHaveLink(io.micrometer.tracing.Link link) Verifies that this span does not have a link.doesNotHaveLink(Consumer<io.micrometer.tracing.Link> consumer) Verifies that this span has no links that passes the assertion function.doesNotHaveNameEqualTo(String spanName) Verifies that this span does not have name equal to the given valuedoesNotHavePortEqualTo(int port) Verifies that this span doesn't have port equal to the given value.doesNotHaveRemoteServiceNameEqualTo(String remoteServiceName) Verifies that this span does not have remote service name equal to the given value.doesNotHaveSpanIdEqualTo(String spanId) Verifies that this span doesn't have span id equal to the given value.doesNotHaveTag(io.micrometer.common.docs.KeyName key, String value) Verifies that this span does not have a tag with key and value.doesNotHaveTag(String key, String value) Verifies that this span does not have a tag with key and value.doesNotHaveTagWithKey(io.micrometer.common.docs.KeyName key) Verifies that this span does not have a tag with key.Verifies that this span does not have a tag with key.doesNotHaveTraceIdEqualTo(String spanId) Verifies that this span doesn't have trace id equal to the given value.hasEventWithNameEqualTo(String eventName) Verifies that this span has an event with a given name.hasIpEqualTo(String ip) Verifies that this span has ip equal to the given value.Verifies that this span has ip set.Verifies that this span has ip set.hasKindEqualTo(io.micrometer.tracing.Span.Kind kind) Verifies that this span has span kind equal to the given value.hasLink(io.micrometer.tracing.Link link) Verifies that this span has a link.Verifies that this span has at least one link that passes the assertion function.hasNameEqualTo(String spanName) Verifies that this span has name equal to the given valueVerifies that this span has no tags.hasPortEqualTo(int port) Verifies that this span has port equal to the given value.Verifies that this span doesn't have a port set.Verifies that this span has a port set.hasRemoteServiceNameEqualTo(String remoteServiceName) Verifies that this span has remote service name equal to the given value.hasSpanIdEqualTo(String spanId) Verifies that this span has span id equal to the given value.Verifies that this span has a tag with key and value.Verifies that this span has a tag with key and value.hasTagWithKey(io.micrometer.common.docs.KeyName key) Verifies that this span has a tag with key.hasTagWithKey(String key) Verifies that this span has a tag with key.hasTraceIdEqualTo(String spanId) Verifies that this span has trace id equal to the given value.isEnded()Verifies that this span is ended.Verifies that this span is not ended.Verifies that this span is not started.Verifies that this span is started.static SpanAssertthen(io.micrometer.tracing.exporter.FinishedSpan actual) Creates the assert object forFinishedSpan.Syntactic sugar to assert a throwable on aFinishedSpan.getError().Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs
-
Constructor Details
-
SpanAssert
protected SpanAssert(io.micrometer.tracing.exporter.FinishedSpan actual) Creates a new instance ofSpanAssert.- Parameters:
actual- actual object to assert
-
-
Method Details
-
assertThat
Creates the assert object forFinishedSpan.- Parameters:
actual- span to assert against- Returns:
- span assertions
-
then
Creates the assert object forFinishedSpan.- Parameters:
actual- span to assert against- Returns:
- span assertions
-
hasNoTags
Verifies that this span has no tags.Examples:
// assertions succeed assertThat(finishedSpan).hasNoTags(); // assertions fail assertThat(finishedSpanWithTags).hasNoTags();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has tags.- Since:
- 1.0.0
-
hasTagWithKey
Verifies that this span has a tag with key.Examples:
// assertions succeed assertThat(finishedSpanWithTagFoo).hasTagWithKey("foo"); // assertions fail assertThat(finishedSpanWithNoTags).hasTagWithKey("foo");- Parameters:
key- tag key name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span doesn't have a tag with given key.- Since:
- 1.0.0
-
hasTagWithKey
Verifies that this span has a tag with key.Examples:
// assertions succeed assertThat(finishedSpanWithTagFoo).hasTagWithKey("foo"); // assertions fail assertThat(finishedSpanWithNoTags).hasTagWithKey("foo");- Parameters:
key- tag key name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span doesn't have a tag with given key.- Since:
- 1.0.0
-
hasTag
Verifies that this span has a tag with key and value.Examples:
// assertions succeed assertThat(finishedSpanWithTag).hasTag("tagKey", "tagValue"); // assertions fail assertThat(finishedSpanWithNoTags).hasTag("tagKey", "tagValue");- Parameters:
key- tag key namevalue- tag value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span doesn't have a tag with given key and value.- Since:
- 1.0.0
-
hasTag
Verifies that this span has a tag with key and value.Examples:
// assertions succeed assertThat(finishedSpanWithTag).hasTag("tagKey", "tagValue"); // assertions fail assertThat(finishedSpanWithNoTags).hasTag("tagKey", "tagValue");- Parameters:
key- tag key namevalue- tag value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span doesn't have a tag with given key and value.- Since:
- 1.0.0
-
doesNotHaveTagWithKey
Verifies that this span does not have a tag with key.Examples:
// assertions succeed assertThat(finishedSpanWithNoTags).doesNotHaveTagWithKey("foo"); // assertions fail assertThat(finishedSpanWithFooTag).doesNotHaveTagWithKey("foo");- Parameters:
key- tag key name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has a tag with given key.- Since:
- 1.0.0
-
doesNotHaveTagWithKey
Verifies that this span does not have a tag with key.Examples:
// assertions succeed assertThat(finishedSpanWithNoTags).doesNotHaveTagWithKey("foo"); // assertions fail assertThat(finishedSpanWithFooTag).doesNotHaveTagWithKey("foo");- Parameters:
key- tag key name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has a tag with given key.- Since:
- 1.0.0
-
doesNotHaveTag
Verifies that this span does not have a tag with key and value.Examples:
// assertions succeed assertThat(finishedSpanWithNoTags).doesNotHaveTag("tagKey", "tagValue"); // assertions fail assertThat(finishedSpanWithFooTag).doesNotHaveTag("foo", "tagValue");- Parameters:
key- tag key namevalue- tag value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has a tag with given key and value.- Since:
- 1.0.0
-
doesNotHaveTag
Verifies that this span does not have a tag with key and value.Examples:
// assertions succeed assertThat(finishedSpanWithNoTags).doesNotHaveTag("tagKey", "tagValue"); // assertions fail assertThat(finishedSpanWithFooTag).doesNotHaveTag("foo", "tagValue");- Parameters:
key- tag key namevalue- tag value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has a tag with given key and value.- Since:
- 1.0.0
-
isStarted
Verifies that this span is started.Examples:
// assertions succeed assertThat(startedSpan).isStarted(); // assertions fail assertThat(notStartedSpan).isStarted();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has not been started- Since:
- 1.0.0
-
isNotStarted
Verifies that this span is not started.Examples:
// assertions succeed assertThat(notStartedSpan).isNotStarted(); // assertions fail assertThat(startedSpan).isNotStarted();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has been started- Since:
- 1.0.0
-
isEnded
Verifies that this span is ended.Examples:
// assertions succeed assertThat(endedSpan).isEnded(); // assertions fail assertThat(notEndedSpan).isEnded();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has not been ended- Since:
- 1.0.0
-
isNotEnded
Verifies that this span is not ended.Examples:
// assertions succeed assertThat(notEndedSpan).isNotEnded(); // assertions fail assertThat(endedSpan).isNotEnded();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has been ended- Since:
- 1.0.0
-
assertThatThrowable
Syntactic sugar to assert a throwable on aFinishedSpan.getError().- Returns:
SpanAssert.SpanAssertReturningAssert
-
thenThrowable
Syntactic sugar to assert a throwable on aFinishedSpan.getError().- Returns:
SpanAssert.SpanAssertReturningAssert
-
hasRemoteServiceNameEqualTo
Verifies that this span has remote service name equal to the given value.Examples:
// assertions succeed assertThat(remoteServiceNameContainingSpan).hasRemoteServiceNameEqualTo("foo"); // assertions fail assertThat(remoteServiceNameMissingSpan).hasRemoteServiceNameEqualTo("foo");- Parameters:
remoteServiceName- remote service name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does not have remote service name equal to the given value- Since:
- 1.0.0
-
doesNotHaveRemoteServiceNameEqualTo
Verifies that this span does not have remote service name equal to the given value.Examples:
// assertions succeed assertThat(remoteServiceNameMissingSpan).doesNotHaveRemoteServiceNameEqualTo("foo"); // assertions fail assertThat(remoteServiceNameContainingSpan).doesNotHaveRemoteServiceNameEqualTo("foo");- Parameters:
remoteServiceName- remote service name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does has remote service name equal to the given value- Since:
- 1.0.0
-
hasKindEqualTo
Verifies that this span has span kind equal to the given value.Examples:
// assertions succeed assertThat(clientSpan).hasKindEqualTo(Span.Kind.CLIENT); // assertions fail assertThat(serverSpan).hasKindEqualTo(Span.Kind.SERVER);- Parameters:
kind- span kind- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does not have span kind equal to the given value- Since:
- 1.0.0
-
doesNotHaveKindEqualTo
Verifies that this span doesn't have span kind equal to the given value.Examples:
// assertions succeed assertThat(serverSpan).doesNotHaveKindEqualTo(Span.Kind.CLIENT); // assertions fail assertThat(clientSpan).doesNotHaveKindEqualTo(Span.Kind.SERVER);- Parameters:
kind- span kind- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has span kind equal to the given value- Since:
- 1.0.0
-
hasEventWithNameEqualTo
Verifies that this span has an event with a given name.Examples:
// assertions succeed assertThat(spanWithEventFoo).hasEventWithNameEqualTo("foo"); // assertions fail assertThat(spanWithNoEvents).hasEventWithNameEqualTo("foo");- Parameters:
eventName- name of the event- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does not have span kind equal to the given value- Since:
- 1.0.0
-
doesNotHaveEventWithNameEqualTo
Verifies that this span does not have an event with a given name.Examples:
// assertions succeed assertThat(spanWithNoEvents).doesNotHaveEventWithNameEqualTo("foo"); // assertions fail assertThat(spanWithEventFoo).doesNotHaveEventWithNameEqualTo("foo");- Parameters:
eventName- name of the event- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has span kind equal to the given value- Since:
- 1.0.0
-
hasNameEqualTo
Verifies that this span has name equal to the given valueExamples:
// assertions succeed assertThat(spanNamedFoo).hasNameEqualTo("foo"); // assertions fail assertThat(spanNamedBar).hasNameEqualTo("foo");- Parameters:
spanName- span name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does not have name equal to the given value- Since:
- 1.0.0
-
doesNotHaveNameEqualTo
Verifies that this span does not have name equal to the given valueExamples:
// assertions succeed assertThat(spanNamedFoo).doesNotHaveNameEqualTo("bar"); // assertions fail assertThat(spanNamedBar).doesNotHaveNameEqualTo("bar");- Parameters:
spanName- span name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does not have name equal to the given value- Since:
- 1.0.0
-
hasIpEqualTo
Verifies that this span has ip equal to the given value.Examples:
// assertions succeed assertThat(spanWithIpLocalhost).hasIpEqualTo("127.0.0.1"); // assertions fail assertThat(spanWithNoIp).hasIpEqualTo("127.0.0.1");- Parameters:
ip- ip- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does not have ip equal to the given value- Since:
- 1.0.0
-
doesNotHaveIpEqualTo
Verifies that this span does not have ip equal to the given value.Examples:
// assertions succeed assertThat(spanWithNoIp).doesNotHaveIpEqualTo("127.0.0.1"); // assertions fail assertThat(spanWithIpLocalhost).doesNotHaveIpEqualTo("127.0.0.1");- Parameters:
ip- ip- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has ip equal to the given value- Since:
- 1.0.0
-
hasIpThatIsNotBlank
Verifies that this span has ip set.Examples:
// assertions succeed assertThat(spanWithIpLocalhost).hasIpThatIsNotBlank(); // assertions fail assertThat(spanWithNoIp).hasIpThatIsNotBlank();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does not have ip set- Since:
- 1.0.0
-
hasIpThatIsBlank
Verifies that this span has ip set.Examples:
// assertions succeed assertThat(spanWithNoIp).hasIpThatIsBlank(); // assertions fail assertThat(spanWithIpLocalhost).hasIpThatIsBlank();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span does not have ip set- Since:
- 1.0.0
-
hasPortEqualTo
Verifies that this span has port equal to the given value.Examples:
// assertions succeed assertThat(spanWithPort80).hasPortEqualTo(80); // assertions fail assertThat(spanWithPort80).hasPortEqualTo(7777);- Parameters:
port- port- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has port equal to the given value- Since:
- 1.0.0
-
doesNotHavePortEqualTo
Verifies that this span doesn't have port equal to the given value.Examples:
// assertions succeed assertThat(spanWithPort80).doesNotHavePortEqualTo(7777); // assertions fail assertThat(spanWithPort80).doesNotHavePortEqualTo(80);- Parameters:
port- port- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has port equal to the given value- Since:
- 1.0.0
-
hasPortThatIsNotSet
Verifies that this span doesn't have a port set.Examples:
// assertions succeed assertThat(spanWithNoPort).hasPortThatIsNotSet(); // assertions fail assertThat(spanWithPort80).hasPortThatIsNotSet();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has port that was set- Since:
- 1.0.0
-
hasPortThatIsSet
Verifies that this span has a port set.Examples:
// assertions succeed assertThat(spanWithPort80).hasPortThatIsSet(); // assertions fail assertThat(spanWithNoPort).hasPortThatIsSet();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has port that wasn't set- Since:
- 1.0.0
-
hasLink
Verifies that this span has a link.Examples:
// assertions succeed Link linkPresentInSpan = ...; assertThat(spanWithALink).hasLink(linkPresentInSpan); // assertions fail Link linkNotPresentInSpan = ...; assertThat(spanWithALink).hasLink(linkNotPresentInSpan);- Parameters:
link- link to check- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there's no matching link- Since:
- 1.1.0
-
doesNotHaveLink
Verifies that this span does not have a link.Examples:
// assertions succeed Link linkNotPresentInSpan = ...; assertThat(spanWithALink).doesNotHaveLink(linkNotPresentInSpan); // assertions fail Link linkNotPresentInSpan = ...; assertThat(spanWithALink).doesNotHaveLink(linkNotPresentInSpan);- Parameters:
link- link to check- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there's a matching link- Since:
- 1.1.0
-
hasLink
Verifies that this span has at least one link that passes the assertion function.Examples:
// assertions succeed assertThat(spanWithALinkWithTags).hasLink(link -> Assertions.assertThat(link.getTags()).isNotEmpty()); // assertions fail assertThat(spanWithALinkWithNoTags).hasLink(link -> Assertions.assertThat(link.getTags()).isNotEmpty());- Parameters:
consumer- user assertion function to assert the trace context and tags against- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the assertion from the assertion has failed for all links entries- Since:
- 1.1.0
-
doesNotHaveLink
Verifies that this span has no links that passes the assertion function.Examples:
// assertions succeed assertThat(spanWithALinkWithNoTags).doesNotHaveLink(link -> Assertions.assertThat(link.getTags()).isNotEmpty()); // assertions fail assertThat(spanWithALinkWithTags).doesNotHaveLink(link -> Assertions.assertThat(link.getTags()).isNotEmpty());- Parameters:
consumer- user assertion function to assert the trace context and tags against- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the assertion from the assertion has failed for all links entries- Since:
- 1.1.0
-
hasSpanIdEqualTo
Verifies that this span has span id equal to the given value.Examples:
// assertions succeed assertThat(spanWithId123).hasSpanIdEqualTo("123"); // assertions fail assertThat(spanWithId123).hasSpanIdEqualTo("234");- Parameters:
spanId- span id- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has a span id not equal to the given one- Since:
- 1.0.4
-
doesNotHaveSpanIdEqualTo
Verifies that this span doesn't have span id equal to the given value.Examples:
// assertions succeed assertThat(spanWithId123).hasSpanIdEqualTo("234"); // assertions fail assertThat(spanWithId123).hasSpanIdEqualTo("123");- Parameters:
spanId- span id- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has a span id equal to the given one- Since:
- 1.0.4
-
hasTraceIdEqualTo
Verifies that this span has trace id equal to the given value.Examples:
// assertions succeed assertThat(spanWithTraceId123).hasTraceIdEqualTo("123"); // assertions fail assertThat(spanWithTraceId123).hasTraceIdEqualTo("234");- Parameters:
spanId- span id- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has a trace id not equal to the given one- Since:
- 1.0.4
-
doesNotHaveTraceIdEqualTo
Verifies that this span doesn't have trace id equal to the given value.Examples:
// assertions succeed assertThat(spanWithTraceId123).hasTraceIdEqualTo("234"); // assertions fail assertThat(spanWithTraceId123).hasTraceIdEqualTo("123");- Parameters:
spanId- span id- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if span has a span id equal to the given one- Since:
- 1.0.4
-