Class SpansAssert
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractIterableAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
org.assertj.core.api.AbstractCollectionAssert<org.assertj.core.api.CollectionAssert<ELEMENT>,Collection<? extends ELEMENT>,ELEMENT,org.assertj.core.api.ObjectAssert<ELEMENT>>
org.assertj.core.api.CollectionAssert<io.micrometer.tracing.exporter.FinishedSpan>
io.micrometer.tracing.test.simple.SpansAssert
- All Implemented Interfaces:
org.assertj.core.api.Assert<org.assertj.core.api.CollectionAssert<io.micrometer.tracing.exporter.FinishedSpan>,,Collection<? extends io.micrometer.tracing.exporter.FinishedSpan>> org.assertj.core.api.Descriptable<org.assertj.core.api.CollectionAssert<io.micrometer.tracing.exporter.FinishedSpan>>,org.assertj.core.api.EnumerableAssert<org.assertj.core.api.CollectionAssert<io.micrometer.tracing.exporter.FinishedSpan>,,io.micrometer.tracing.exporter.FinishedSpan> org.assertj.core.api.ExtensionPoints<org.assertj.core.api.CollectionAssert<io.micrometer.tracing.exporter.FinishedSpan>,,Collection<? extends io.micrometer.tracing.exporter.FinishedSpan>> org.assertj.core.api.ObjectEnumerableAssert<org.assertj.core.api.CollectionAssert<io.micrometer.tracing.exporter.FinishedSpan>,io.micrometer.tracing.exporter.FinishedSpan>
public class SpansAssert
extends org.assertj.core.api.CollectionAssert<io.micrometer.tracing.exporter.FinishedSpan>
Assertion methods for
SimpleSpans.
To create a new instance of this class, invoke
assertThat(Collection) or then(Collection).
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSyntactic sugar that extendsSpanAssertmethods with an option to go back toSpansAssert. -
Field Summary
Fields inherited from class org.assertj.core.api.AbstractIterableAssert
iterablesFields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSpansAssert(Collection<? extends io.micrometer.tracing.exporter.FinishedSpan> actual) Creates a new instance ofSpansAssert. -
Method Summary
Modifier and TypeMethodDescriptionstatic SpansAssertassertThat(Collection<? extends io.micrometer.tracing.exporter.FinishedSpan> actual) Creates the assert object for a collection ofFinishedSpan.Provides verification for the first span having the given name.Provides verification for the first span having the given name (ignoring case).forAllSpansWithNameEqualTo(String name, Consumer<SpanAssert> spanConsumer) Provides verification for all spans having the given name.forAllSpansWithNameEqualToIgnoreCase(String name, Consumer<SpanAssert> spanConsumer) Provides verification for all spans having the given name (ignoring case).hasASpanWithATag(io.micrometer.common.docs.KeyName key, String value) Verifies that there is a span with a tag.hasASpanWithATag(String key, String value) Verifies that there is a span with a tag.hasASpanWithATagKey(io.micrometer.common.docs.KeyName key) Verifies that there is a span with a tag key.Verifies that there is a span with a tag key.hasASpanWithName(String name) Verifies that there is a span with a given name.hasASpanWithName(String name, Consumer<SpanAssert> spanConsumer) Verifies that there is a span with a given name and also given assertion is met.Verifies that there is a span with a given name (ignoring case).hasASpanWithNameIgnoreCase(String name, Consumer<SpanAssert> spanConsumer) Verifies that there is a span with a given name (ignoring case) and also given assertion is met.hasASpanWithRemoteServiceName(String remoteServiceName) Verifies that there is a span with a given remote service name.hasNumberOfSpansEqualTo(int expectedNumberOfSpans) Verifies that there is a proper number of spans.hasNumberOfSpansWithNameEqualTo(String spanName, int expectedNumberOfSpans) Verifies that there is a proper number of spans with the given name.hasNumberOfSpansWithNameEqualToIgnoreCase(String spanName, int expectedNumberOfSpans) Verifies that there is a proper number of spans with the given name (ignoring case).Verifies that all spans have the same trace id.static SpansAssertthen(Collection<? extends io.micrometer.tracing.exporter.FinishedSpan> actual) Creates the assert object for a collection ofFinishedSpan.Provides verification for the first span having the given name.Provides verification for the first span having the given name (ignoring case).Methods inherited from class org.assertj.core.api.CollectionAssert
assertThatCollection, newAbstractIterableAssert, toAssertMethods inherited from class org.assertj.core.api.AbstractCollectionAssert
isUnmodifiableMethods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, allSatisfy, anyMatch, anySatisfy, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, as, as, contains, containsAll, containsAnyElementsOf, containsAnyOf, containsAnyOfForProxy, containsExactly, containsExactlyElementsOf, containsExactlyForProxy, containsExactlyInAnyOrder, containsExactlyInAnyOrderElementsOf, containsExactlyInAnyOrderForProxy, containsForProxy, containsNull, containsOnly, containsOnlyElementsOf, containsOnlyForProxy, containsOnlyNulls, containsOnlyOnce, containsOnlyOnceElementsOf, containsOnlyOnceForProxy, containsSequence, containsSequence, containsSequenceForProxy, containsSubsequence, containsSubsequence, containsSubsequenceForProxy, describedAs, describedAs, doesNotContain, doesNotContainAnyElementsOf, doesNotContainForProxy, doesNotContainNull, doesNotContainSequence, doesNotContainSequence, doesNotContainSequenceForProxy, doesNotContainSubsequence, doesNotContainSubsequence, doesNotContainSubsequenceForProxy, doesNotHave, doesNotHaveAnyElementsOfTypes, doesNotHaveDuplicates, doesNotHaveSameClassAs, doNotHave, element, element, elements, endsWith, endsWith, endsWithForProxy, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, extractingResultOf, extractingResultOf, filteredOn, filteredOn, filteredOn, filteredOn, filteredOn, filteredOnAssertions, filteredOnAssertions, filteredOnNull, first, first, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtractingForProxy, flatMap, flatMap, flatMap, flatMap, getComparatorsByType, getComparatorsForElementPropertyOrFieldTypes, has, hasAtLeastOneElementOfType, hasExactlyElementsOfTypes, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameClassAs, hasSameElementsAs, hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, hasToString, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, inBinary, inHexadecimal, is, isEmpty, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEmpty, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNullOrEmpty, isOfAnyClassIn, isSameAs, isSubsetOf, isSubsetOf, isSubsetOfForProxy, last, last, map, map, map, navigationDescription, newAbstractIterableAssertForProxy, noneMatch, noneSatisfy, noneSatisfy, overridingErrorMessage, satisfiesExactly, satisfiesExactly, satisfiesExactlyForProxy, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrderForProxy, singleElement, singleElement, size, startsWith, startsWithForProxy, usingComparator, usingComparator, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparatorForType, usingComparisonStrategy, usingDefaultComparator, usingDefaultElementComparator, usingElementComparator, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveComparison, usingRecursiveComparison, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparatorIgnoringFields, usingRecursiveFieldByFieldElementComparatorOnFields, withFailMessage, withThreadDumpOnError, zipSatisfyMethods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, descriptionText, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, hashCode, hasSameHashCodeAs, isElementOfCustomAssert, isInstanceOfSatisfying, isNull, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, withFailMessage, withRepresentationMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as
-
Constructor Details
-
SpansAssert
Creates a new instance ofSpansAssert.- Parameters:
actual- actual object to assert
-
-
Method Details
-
assertThat
public static SpansAssert assertThat(Collection<? extends io.micrometer.tracing.exporter.FinishedSpan> actual) Creates the assert object for a collection ofFinishedSpan.- Parameters:
actual- span to assert against- Returns:
- span collection assertions
-
then
public static SpansAssert then(Collection<? extends io.micrometer.tracing.exporter.FinishedSpan> actual) Creates the assert object for a collection ofFinishedSpan.- Parameters:
actual- span to assert against- Returns:
- span collection assertions
-
haveSameTraceId
Verifies that all spans have the same trace id.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpan)).haveSameTraceId(); // assertions fail assertThat(Arrays.asList(finishedSpanWithTraceIdX, finishedSpanWithTraceIdY)).haveSameTraceId();- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if spans do not have the same trace id.- Since:
- 1.0.0
-
hasASpanWithName
Verifies that there is a span with a given name.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).hasASpanWithName("foo"); // assertions fail assertThat(Collections.singletonList(finishedSpanWithNameBar)).hasASpanWithName("foo");- Parameters:
name- searched span name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given name- Since:
- 1.0.0
-
hasASpanWithName
Verifies that there is a span with a given name and also given assertion is met.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).hasASpanWithName("foo", spanAssert -> spanAssert.isStarted()); // assertions fail assertThat(Collections.singletonList(notFinishedSpanWithNameFoo)).hasASpanWithName("foo", spanAssert -> spanAssert.isStarted());- Parameters:
name- searched span namespanConsumer- assertion to be executed for each span- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given nameAssertionError- if the span assertion is not met- Since:
- 1.0.0
-
hasASpanWithNameIgnoreCase
Verifies that there is a span with a given name (ignoring case) and also given assertion is met.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).hasASpanWithNameIgnoreCase("FoO", spanAssert -> spanAssert.isStarted()); // assertions fail assertThat(Collections.singletonList(notFinishedSpanWithNameFoo)).hasASpanWithNameIgnoreCase("FoO", spanAssert -> spanAssert.isStarted());- Parameters:
name- searched span namespanConsumer- assertion to be executed for each span- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given nameAssertionError- if the span assertion is not met- Since:
- 1.0.0
-
hasASpanWithNameIgnoreCase
Verifies that there is a span with a given name (ignoring case).Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).hasASpanWithNameIgnoreCase("FoO"); // assertions fail assertThat(Collections.singletonList(finishedSpanWithNameBar)).hasASpanWithNameIgnoreCase("FoO");- Parameters:
name- searched span name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given name (ignoring case)- Since:
- 1.0.0
-
forAllSpansWithNameEqualTo
Provides verification for all spans having the given name.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).forAllSpansWithNameEqualTo("foo", spanAssert -> spanAssert.isStarted()); // assertions fail assertThat(Collections.singletonList(nonStartedSpanWithNameFoo)).forAllSpansWithNameEqualTo("foo", spanAssert -> spanAssert.isStarted());- Parameters:
name- searched span namespanConsumer- assertion to be executed for each span- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given nameAssertionError- if there is a span with the given name but the additional assertion is not successful- Since:
- 1.0.0
-
forAllSpansWithNameEqualToIgnoreCase
public SpansAssert forAllSpansWithNameEqualToIgnoreCase(String name, Consumer<SpanAssert> spanConsumer) Provides verification for all spans having the given name (ignoring case).Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).forAllSpansWithNameEqualTo("foo", spanAssert -> spanAssert.isStarted()); // assertions fail assertThat(Collections.singletonList(nonStartedSpanWithNameFoo)).forAllSpansWithNameEqualTo("foo", spanAssert -> spanAssert.isStarted());- Parameters:
name- searched span name (ignoring case)spanConsumer- assertion to be executed for each span- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given name (ignoring case)AssertionError- if there is a span with the given name (ignoring case) but the additional assertion is not successful- Since:
- 1.0.0
-
assertThatASpanWithNameEqualTo
Provides verification for the first span having the given name.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).assertThatASpanWithNameEqualTo("foo").isStarted(); // assertions fail assertThat(Collections.singletonList(notStartedSpanWithNameFoo)).assertThatASpanWithNameEqualTo("foo").isStarted();- Parameters:
name- searched span name- Returns:
SpansAssert.SpansAssertReturningAssertassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given name- Since:
- 1.0.0
-
thenASpanWithNameEqualTo
Provides verification for the first span having the given name.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).thenASpanWithNameEqualTo("foo").isStarted(); // assertions fail assertThat(Collections.singletonList(notStartedSpanWithNameFoo)).thenASpanWithNameEqualTo("foo").isStarted();- Parameters:
name- searched span name- Returns:
SpansAssert.SpansAssertReturningAssertassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given name- Since:
- 1.0.0
-
assertThatASpanWithNameEqualToIgnoreCase
Provides verification for the first span having the given name (ignoring case).Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).assertThatASpanWithNameEqualToIgnoreCase("FoO").isStarted(); // assertions fail assertThat(Collections.singletonList(notStartedSpanWithNameFoo)).assertThatASpanWithNameEqualToIgnoreCase("FoO").isStarted();- Parameters:
name- searched span name (ignoring case)- Returns:
SpansAssert.SpansAssertReturningAssertassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given name (ignoring case)- Since:
- 1.0.0
-
thenASpanWithNameEqualToIgnoreCase
Provides verification for the first span having the given name (ignoring case).Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).thenASpanWithNameEqualToIgnoreCase("FoO").isStarted(); // assertions fail assertThat(Collections.singletonList(notStartedSpanWithNameFoo)).thenASpanWithNameEqualToIgnoreCase("FoO").isStarted();- Parameters:
name- searched span name (ignoring case)- Returns:
SpansAssert.SpansAssertReturningAssertassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with the given name (ignoring case)- Since:
- 1.0.0
-
hasNumberOfSpansEqualTo
Verifies that there is a proper number of spans.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpan)).hasNumberOfSpansEqualTo(1); // assertions fail assertThat(Collections.singletonList(finishedSpan)).hasNumberOfSpansEqualTo(2);- Parameters:
expectedNumberOfSpans- expected number of spans- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the number of spans is different from the desired one- Since:
- 1.0.0
-
hasNumberOfSpansWithNameEqualTo
Verifies that there is a proper number of spans with the given name.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).hasNumberOfSpansWithNameEqualTo("foo", 1); // assertions fail assertThat(Collections.singletonList(finishedSpanWithNameFoo)).hasNumberOfSpansWithNameEqualTo("foo", 2);- Parameters:
spanName- span nameexpectedNumberOfSpans- expected number of spans with the given name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the number of properly named spans is different from the desired one- Since:
- 1.0.0
-
hasNumberOfSpansWithNameEqualToIgnoreCase
public SpansAssert hasNumberOfSpansWithNameEqualToIgnoreCase(String spanName, int expectedNumberOfSpans) Verifies that there is a proper number of spans with the given name (ignoring case).Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithNameFoo)).hasNumberOfSpansWithNameEqualToIgnoreCase(1); // assertions fail assertThat(Collections.singletonList(finishedSpanWithNameFoo)).hasNumberOfSpansWithNameEqualToIgnoreCase(2);- Parameters:
spanName- span nameexpectedNumberOfSpans- expected number of spans with the given name (ignoring case)- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the number of properly named spans is different from the desired one- Since:
- 1.0.0
-
hasASpanWithRemoteServiceName
Verifies that there is a span with a given remote service name.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithRemoteServiceNameFoo)).hasASpanWithRemoteServiceName("FoO"); // assertions fail assertThat(Collections.singletonList(finishedSpanWithRemoteServiceNameBar)).hasASpanWithRemoteServiceName("FoO");- Parameters:
remoteServiceName- searched remote service name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with given remote service name- Since:
- 1.0.0
-
hasASpanWithATag
Verifies that there is a span with a tag.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithTagFooBar)).hasASpanWithATag("foo", "bar"); // assertions fail assertThat(Collections.singletonList(finishedSpanWithTagBazBar)).hasASpanWithATag("foo", "bar");- Parameters:
key- expected tag keyvalue- expected tag value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with given tag key and value- Since:
- 1.0.0
-
hasASpanWithATagKey
Verifies that there is a span with a tag key.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithTagFooBar)).hasASpanWithATagKey("foo"); // assertions fail assertThat(Collections.singletonList(finishedSpanWithTagBazBar)).hasASpanWithATagKey("foo");- Parameters:
key- expected tag key- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with given tag key- Since:
- 1.0.0
-
hasASpanWithATag
Verifies that there is a span with a tag.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithTagFooBar)).hasASpanWithATag(SomeKeyName.FOO, "bar"); // assertions fail assertThat(Collections.singletonList(finishedSpanWithTagBazBar)).hasASpanWithATag(SomeKeyName.FOO, "baz");- Parameters:
key- expected tag keyvalue- expected tag value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with given tag key- Since:
- 1.0.0
-
hasASpanWithATagKey
Verifies that there is a span with a tag key.Examples:
// assertions succeed assertThat(Collections.singletonList(finishedSpanWithTagFooBar)).hasASpanWithATagKey(SomeKeyName.FOO); // assertions fail assertThat(Collections.singletonList(finishedSpanWithTagBazBar)).hasASpanWithATagKey(SomeKeyName.FOO);- Parameters:
key- expected tag key- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no span with given tag key- Since:
- 1.0.0
-