Package org.assertj.vavr.api
Class SeqAssert<ELEMENT>
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.AbstractIterableAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
-
- org.assertj.vavr.api.SeqAssert<ELEMENT>
-
- All Implemented Interfaces:
org.assertj.core.api.Assert<SeqAssert<ELEMENT>,io.vavr.collection.Seq<ELEMENT>>,org.assertj.core.api.Descriptable<SeqAssert<ELEMENT>>,org.assertj.core.api.EnumerableAssert<SeqAssert<ELEMENT>,ELEMENT>,org.assertj.core.api.ExtensionPoints<SeqAssert<ELEMENT>,io.vavr.collection.Seq<ELEMENT>>,org.assertj.core.api.IndexedObjectEnumerableAssert<SeqAssert<ELEMENT>,ELEMENT>,org.assertj.core.api.ObjectEnumerableAssert<SeqAssert<ELEMENT>,ELEMENT>
public class SeqAssert<ELEMENT> extends org.assertj.core.api.AbstractIterableAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ACTUALactual()SELFcontains(ELEMENT value, org.assertj.core.data.Index index)Verifies that the actualSeqcontains the given object at the given index.SELFcontainsExactlyInAnyOrder(io.vavr.collection.Traversable<ELEMENT> values)SELFdoesNotContain(ELEMENT value, org.assertj.core.data.Index index)Verifies that the actual group does not contain the given object at the given index.SELFhas(org.assertj.core.api.Condition<? super ELEMENT> condition, org.assertj.core.data.Index index)Verifies that the actual object at the given index in the actual group satisfies the given condition.org.assertj.core.api.WritableAssertionInfoinfo()SELFis(org.assertj.core.api.Condition<? super ELEMENT> condition, org.assertj.core.data.Index index)Verifies that the actual object at the given index in the actual group satisfies the given condition (alias ofhas(Condition, Index)).SELFisSorted()Verifies that the actual sequence is sorted in ascending order according to the natural ordering of its elements.SELFisSortedAccordingTo(Comparator<? super ELEMENT> comparator)Verifies that the actual sequence is sorted according to the given comparator.
Empty sequences are considered sorted whatever the comparator is.
One element sequences are considered sorted if the element is compatible with comparator.protected SeqAssert<ELEMENT>newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable)org.assertj.core.internal.Objectsobjects()SELFsatisfies(Consumer<? super ELEMENT> requirements, org.assertj.core.data.Index index)Verifies that the actual @{code Seq} contains the value at givenIndexthat satisfy givenrequirements.protected org.assertj.core.api.ObjectAssert<ELEMENT>toAssert(ELEMENT value, String description)SELFusingElementComparator(Comparator<? super ELEMENT> customComparator)Use given custom comparator instead of relying on actual type Aequalsmethod to compare theSeqelement's object for incoming assertion checks.SELFwithAssertionState(org.assertj.vavr.api.AbstractVavrAssert assertInstance)-
Methods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, anyMatch, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, as, as, contains, containsAll, containsAnyElementsOf, containsAnyOf, containsExactly, containsExactlyElementsOf, containsExactlyInAnyOrder, containsExactlyInAnyOrderElementsOf, containsNull, containsOnly, containsOnlyElementsOf, containsOnlyNulls, containsOnlyOnce, containsOnlyOnceElementsOf, containsSequence, containsSequence, containsSubsequence, containsSubsequence, describedAs, describedAs, doesNotContain, doesNotContainAnyElementsOf, doesNotContainNull, doesNotContainSequence, doesNotContainSequence, doesNotContainSubsequence, doesNotContainSubsequence, doesNotHave, doesNotHaveAnyElementsOfTypes, doesNotHaveDuplicates, doesNotHaveSameClassAs, doNotHave, element, element, endsWith, endsWith, extracting, extracting, extracting, extracting, extracting, extracting, extractingResultOf, extractingResultOf, filteredOn, filteredOn, filteredOn, filteredOn, filteredOn, filteredOnAssertions, filteredOnNull, first, first, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatMap, flatMap, flatMap, flatMap, getComparatorsByType, getComparatorsForElementPropertyOrFieldTypes, has, hasAtLeastOneElementOfType, 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, last, last, map, map, map, navigationDescription, noneMatch, noneSatisfy, overridingErrorMessage, satisfiesExactly, satisfiesExactlyInAnyOrder, singleElement, singleElement, size, startsWith, usingComparator, usingComparator, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparatorForType, usingComparisonStrategy, usingDefaultComparator, usingDefaultElementComparator, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveComparison, usingRecursiveComparison, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, withFailMessage, withThreadDumpOnError, zipSatisfy
-
Methods inherited from class org.assertj.core.api.AbstractAssert
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, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, withFailMessage, withRepresentation
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.EnumerableAssert
hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, isEmpty, isNotEmpty, isNullOrEmpty, usingDefaultElementComparator
-
Methods inherited from interface org.assertj.core.api.ObjectEnumerableAssert
allMatch, allMatch, allSatisfy, anyMatch, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, contains, containsAll, containsAnyElementsOf, containsAnyOf, containsExactly, containsExactlyElementsOf, containsExactlyInAnyOrder, containsExactlyInAnyOrderElementsOf, containsNull, containsOnly, containsOnlyElementsOf, containsOnlyNulls, containsOnlyOnce, containsOnlyOnceElementsOf, containsSequence, containsSequence, containsSubsequence, containsSubsequence, doesNotContain, doesNotContainAnyElementsOf, doesNotContainNull, doesNotContainSequence, doesNotContainSequence, doesNotContainSubsequence, doesNotContainSubsequence, doesNotHaveAnyElementsOfTypes, doesNotHaveDuplicates, doNotHave, endsWith, endsWith, hasAtLeastOneElementOfType, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameElementsAs, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, isSubsetOf, isSubsetOf, noneMatch, noneSatisfy, satisfiesExactly, satisfiesExactlyInAnyOrder, startsWith
-
-
-
-
Method Detail
-
toAssert
protected org.assertj.core.api.ObjectAssert<ELEMENT> toAssert(ELEMENT value, String description)
-
newAbstractIterableAssert
protected SeqAssert<ELEMENT> newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable)
-
usingElementComparator
public SELF usingElementComparator(Comparator<? super ELEMENT> customComparator)
Use given custom comparator instead of relying on actual type Aequalsmethod to compare theSeqelement's object for incoming assertion checks.- Specified by:
usingElementComparatorin interfaceorg.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractSeqAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>,ACTUAL extends io.vavr.collection.Seq<? extends ELEMENT>>- Overrides:
usingElementComparatorin classorg.assertj.core.api.AbstractIterableAssert<SELF extends org.assertj.vavr.api.AbstractSeqAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>,ACTUAL extends io.vavr.collection.Seq<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends org.assertj.core.api.AbstractAssert<ELEMENT_ASSERT,ELEMENT>>- Parameters:
customComparator- the comparator to use for incoming assertion checks.- Returns:
thisassertion object.- Throws:
NullPointerException- if the given comparator isnull.
-
contains
public SELF contains(ELEMENT value, org.assertj.core.data.Index index)Verifies that the actualSeqcontains the given object at the given index.Example:
Seq<Ring> elvesRings = List.of(vilya, nenya, narya); // assertions will pass assertThat(elvesRings).contains(vilya, atIndex(0)); assertThat(elvesRings).contains(nenya, atIndex(1)); assertThat(elvesRings).contains(narya, atIndex(2)); // assertions will fail assertThat(elvesRings).contains(vilya, atIndex(1)); assertThat(elvesRings).contains(nenya, atIndex(2)); assertThat(elvesRings).contains(narya, atIndex(0));- Specified by:
containsin interfaceorg.assertj.core.api.IndexedObjectEnumerableAssert<SELF extends org.assertj.vavr.api.AbstractSeqAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>,ACTUAL extends io.vavr.collection.Seq<? extends ELEMENT>>- Parameters:
value- the object to look for.index- the index where the object should be stored in the actual group.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actual group isnullor empty.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the actual group.AssertionError- if the actual group does not contain the given object at the given index.
-
doesNotContain
public SELF doesNotContain(ELEMENT value, org.assertj.core.data.Index index)Verifies that the actual group does not contain the given object at the given index.Example:
Seq<Ring> elvesRings = List.of(vilya, nenya, narya); // assertions will pass assertThat(elvesRings).contains(vilya, atIndex(1)); assertThat(elvesRings).contains(nenya, atIndex(2)); assertThat(elvesRings).contains(narya, atIndex(0)); // assertions will fail assertThat(elvesRings).contains(vilya, atIndex(0)); assertThat(elvesRings).contains(nenya, atIndex(1)); assertThat(elvesRings).contains(narya, atIndex(2));- Specified by:
doesNotContainin interfaceorg.assertj.core.api.IndexedObjectEnumerableAssert<SELF extends org.assertj.vavr.api.AbstractSeqAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>,ACTUAL extends io.vavr.collection.Seq<? extends ELEMENT>>- Parameters:
value- the object to look for.index- the index where the object should not be stored in the actual group.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actual group isnull.NullPointerException- if the givenIndexisnull.AssertionError- if the actual group contains the given object at the given index.
-
has
public SELF has(org.assertj.core.api.Condition<? super ELEMENT> condition, org.assertj.core.data.Index index)Verifies that the actual object at the given index in the actual group satisfies the given condition.- Parameters:
condition- the given condition.index- the index where the object should be stored in the actual group.- Returns:
- this assertion object.
- Throws:
AssertionError- if the givenSeqisnullor empty.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the givenSeq.NullPointerException- if the givenConditionisnull.AssertionError- if the value in the givenSeqat the given index does not satisfy the givenCondition.
-
is
public SELF is(org.assertj.core.api.Condition<? super ELEMENT> condition, org.assertj.core.data.Index index)Verifies that the actual object at the given index in the actual group satisfies the given condition (alias ofhas(Condition, Index)).- Parameters:
condition- the given condition.index- the index where the object should be stored in the actual group.- Returns:
- this assertion object.
- Throws:
AssertionError- if the givenSeqisnullor empty.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the givenSeq.NullPointerException- if the givenConditionisnull.AssertionError- if the value in the givenSeqat the given index does not satisfy the givenCondition.
-
isSorted
public SELF isSorted()
Verifies that the actual sequence is sorted in ascending order according to the natural ordering of its elements.All sequence elements must implement the
Comparableinterface and must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the sequence), examples :- a sequence composed of {"a1", "a2", "a3"} is ok because the element type (String) is Comparable
- a sequence composed of Rectangle {r1, r2, r3} is NOT ok because Rectangle is not Comparable
- a sequence composed of {True, "abc", False} is NOT ok because elements are not mutually comparable
Unique element sequences are considered sorted unless the element type is not Comparable.- Returns:
thisassertion object.- Throws:
AssertionError- if the actual sequence is not sorted in ascending order according to the natural ordering of its elements.AssertionError- if the actual sequence isnull.AssertionError- if the actual sequence element type does not implementComparable.AssertionError- if the actual sequence elements are not mutuallyComparable.
-
isSortedAccordingTo
public SELF isSortedAccordingTo(Comparator<? super ELEMENT> comparator)
Verifies that the actual sequence is sorted according to the given comparator.
Empty sequences are considered sorted whatever the comparator is.
One element sequences are considered sorted if the element is compatible with comparator.- Parameters:
comparator- theComparatorused to compare sequence elements- Returns:
thisassertion object.- Throws:
AssertionError- if the actual sequence is not sorted according to the given comparator.AssertionError- if the actual sequence isnull.NullPointerException- if the given comparator isnull.AssertionError- if the actual sequence elements are not mutually comparable according to given Comparator.
-
satisfies
public SELF satisfies(Consumer<? super ELEMENT> requirements, org.assertj.core.data.Index index)
Verifies that the actual @{code Seq} contains the value at givenIndexthat satisfy givenrequirements.Example:
Seq<TolkienCharacter> ringBearers = List.of(frodo, elrond, gandalf); // this assertion will pass assertThat(ringBearers).satisfies( ringBearer -> { assertThat(ringBearer.getAge()).isGreaterThan(200); assertThat(ringBearer.getRace()).isEqualTo(ELF); }, atIndex(1)); // this assertion will fail assertThat(ringBearers).satisfies( ringBearer -> { assertThat(ringBearer.getRace()).isEqualTo(ELF); }, atIndex(0);- Parameters:
requirements- the given requirements for the element atIndexto meet.index- the index where the object should be stored in the actualSeq.- Returns:
thisassertion object.- Throws:
AssertionError- if the value at givenIndexdoes not satisfy therequirements.AssertionError- if the actual sequence isnull.NullPointerException- if the givenrequirementsarenull.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the actualSeq.
-
containsExactlyInAnyOrder
public SELF containsExactlyInAnyOrder(io.vavr.collection.Traversable<ELEMENT> values)
-
actual
public ACTUAL actual()
-
withAssertionState
public SELF withAssertionState(org.assertj.vavr.api.AbstractVavrAssert assertInstance)
-
objects
public org.assertj.core.internal.Objects objects()
-
info
public org.assertj.core.api.WritableAssertionInfo info()
-
-