Class AbstractListAssert<SELF extends AbstractListAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>,ACTUAL extends List<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>>
- Type Parameters:
SELF- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" for more details.ACTUAL- the type of the "actual" value.ELEMENT- the type of elements of the "actual" value.ELEMENT_ASSERT- used for navigational assertions to return the right assert type.
- All Implemented Interfaces:
Assert<SELF,,ACTUAL> Descriptable<SELF>,EnumerableAssert<SELF,,ELEMENT> ExtensionPoints<SELF,,ACTUAL> IndexedObjectEnumerableAssert<SELF,,ELEMENT> ObjectEnumerableAssert<SELF,ELEMENT>
- Direct Known Subclasses:
ClassBasedNavigableListAssert,FactoryBasedNavigableListAssert
Lists.- Author:
- Yvonne Wang, Alex Ruiz, Joel Costigliola, Mikhail Mazursky, Jacek Jackowiak
-
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the description of the assertion that is going to be called after.as(Description description) Sets the description of the assertion that is going to be called after.Verifies that the actual group contains the given object at the given index.describedAs(String description, Object... args) Sets the description of the assertion that is going to be called after.describedAs(Description description) Sets the description of the assertion that is going to be called after.doesNotContain(ELEMENT value, Index index) Verifies that the actual group does not contain the given object at the given index.doesNotHave(Condition<? super ACTUAL> condition) Verifies that the actual value does not satisfy the given condition.doesNotHaveSameClassAs(Object other) Verifies that the actual value does not have the same class as the given object.Verifies that the actual value satisfies the given condition.Verifies that the actual object at the given index in the actual group satisfies the given condition.hasSameClassAs(Object other) Verifies that the actual value has the same class as the given object.hasToString(String expectedToString) Verifies that actualactual.toString()is equal to the givenString.Verifies that the actual value satisfies the given condition.Verifies that the actual object at the given index in the actual group satisfies the given condition.Verifies that the actual value is equal to the given one.isExactlyInstanceOf(Class<?> type) Verifies that the actual value is exactly an instance of the given type.Verifies that the actual value is present in the given iterable.Verifies that the actual value is present in the given array of values.isInstanceOf(Class<?> type) Verifies that the actual value is an instance of the given type.isInstanceOfAny(Class<?>... types) Verifies that the actual value is an instance of any of the given types.Verifies that the actual value does not satisfy the given condition.isNotEqualTo(Object other) Verifies that the actual value is not equal to the given one.isNotExactlyInstanceOf(Class<?> type) Verifies that the actual value is not exactly an instance of given type.Verifies that the actual value is not present in the given iterable.Verifies that the actual value is not present in the given array of values.isNotInstanceOf(Class<?> type) Verifies that the actual value is not an instance of the given type.isNotInstanceOfAny(Class<?>... types) Verifies that the actual value is not an instance of any of the given types.Verifies that the actual value is notnull.isNotOfAnyClassIn(Class<?>... types) Verifies that the actual value type is not in given types.isNotSameAs(Object other) Verifies that the actual value is not the same as the given one, i.e., using == comparison.isOfAnyClassIn(Class<?>... types) Verifies that the actual value type is in given types.Verifies that the actual value is the same as the given one, i.e., using == comparison.isSorted()Verifies that the actual list is sorted in ascending order according to the natural ordering of its elements.isSortedAccordingTo(Comparator<? super ELEMENT> comparator) Verifies that the actual list is sorted according to the given comparator.
Empty lists are considered sorted whatever the comparator is.
One element lists are considered sorted if the element is compatible with comparator.overridingErrorMessage(String newErrorMessage, Object... args) Overrides AssertJ default error message by the given one.Verifies that the actualListcontains a value at givenIndexthat satisfies the givenrequirements.usingComparator(Comparator<? super ACTUAL> customComparator) Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.usingComparator(Comparator<? super ACTUAL> customComparator, String customComparatorDescription) Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.protected SELFusingComparisonStrategy(ComparisonStrategy comparisonStrategy) Revert to standard comparison for the incoming assertion checks.Revert to standard comparison for incoming assertion group element checks.usingElementComparator(Comparator<? super ELEMENT> customComparator) Use given custom comparator instead of relying on actual type Aequalsmethod to compare group elements for incoming assertion checks.withFailMessage(String newErrorMessage, Object... args) Alternative method forAbstractAssert.overridingErrorMessage(java.lang.String, java.lang.Object...)In case of an assertion error, a thread dump will be printed toSystem.err.Methods inherited from class org.assertj.core.api.AbstractCollectionAssert
isUnmodifiableMethods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, allSatisfy, anyMatch, anyMatch, anySatisfy, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, 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, doesNotContain, doesNotContainAnyElementsOf, doesNotContainForProxy, doesNotContainNull, doesNotContainSequence, doesNotContainSequence, doesNotContainSequenceForProxy, doesNotContainSubsequence, doesNotContainSubsequence, doesNotContainSubsequenceForProxy, doesNotHaveAnyElementsOfTypes, doesNotHaveDuplicates, 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, hasAtLeastOneElementOfType, hasExactlyElementsOfTypes, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameElementsAs, hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, inBinary, inHexadecimal, isEmpty, isNotEmpty, isNullOrEmpty, isSubsetOf, isSubsetOf, isSubsetOfForProxy, last, last, map, map, map, navigationDescription, newAbstractIterableAssert, newAbstractIterableAssertForProxy, noneMatch, noneMatch, noneSatisfy, noneSatisfy, satisfiesExactly, satisfiesExactly, satisfiesExactlyForProxy, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrderForProxy, satisfiesOnlyOnce, satisfiesOnlyOnce, satisfiesOnlyOnceForProxy, singleElement, singleElement, size, startsWith, startsWithForProxy, toAssert, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparatorForType, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparatorIgnoringFields, usingRecursiveFieldByFieldElementComparatorOnFields, zipSatisfyMethods inherited from class org.assertj.core.api.AbstractAssert
actual, areEqual, asInstanceOf, asList, assertionError, asString, descriptionText, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, hashCode, hasSameHashCodeAs, hasToString, isElementOfCustomAssert, isInstanceOfSatisfying, isNull, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingEquals, usingEquals, 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, describedAsMethods inherited from interface org.assertj.core.api.EnumerableAssert
hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, isEmpty, isNotEmpty, isNullOrEmptyMethods inherited from interface org.assertj.core.api.ObjectEnumerableAssert
allMatch, allMatch, allSatisfy, allSatisfy, anyMatch, anyMatch, anySatisfy, 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, hasExactlyElementsOfTypes, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameElementsAs, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, isSubsetOf, isSubsetOf, noneMatch, noneMatch, noneSatisfy, noneSatisfy, satisfiesExactly, satisfiesExactly, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrder, satisfiesOnlyOnce, satisfiesOnlyOnce, startsWith
-
Constructor Details
-
AbstractListAssert
-
-
Method Details
-
contains
Verifies that the actual group contains the given object at the given index.Example:
List<Ring> elvesRings = newArrayList(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 interfaceIndexedObjectEnumerableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? 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.
-
doesNotContain
Verifies that the actual group does not contain the given object at the given index.Example:
List<Ring> elvesRings = newArrayList(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 interfaceIndexedObjectEnumerableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? 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.
-
has
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 givenListisnullor empty.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the givenList.NullPointerException- if the givenConditionisnull.AssertionError- if the value in the givenListat the given index does not satisfy the givenCondition.
-
is
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 givenListisnullor empty.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the givenList.NullPointerException- if the givenConditionisnull.AssertionError- if the value in the givenListat the given index does not satisfy the givenCondition.
-
isSorted
Verifies that the actual list is sorted in ascending order according to the natural ordering of its elements.All list 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 list), examples :- a list composed of {"a1", "a2", "a3"} is ok because the element type (String) is Comparable
- a list composed of Rectangle {r1, r2, r3} is NOT ok because Rectangle is not Comparable
- a list composed of {True, "abc", False} is NOT ok because elements are not mutually comparable
Unique element lists are considered sorted unless the element type is not Comparable.- Returns:
thisassertion object.- Throws:
AssertionError- if the actual list is not sorted in ascending order according to the natural ordering of its elements.AssertionError- if the actual list isnull.AssertionError- if the actual list element type does not implementComparable.AssertionError- if the actual list elements are not mutuallyComparable.
-
isSortedAccordingTo
Verifies that the actual list is sorted according to the given comparator.
Empty lists are considered sorted whatever the comparator is.
One element lists are considered sorted if the element is compatible with comparator.- Parameters:
comparator- theComparatorused to compare list elements- Returns:
thisassertion object.- Throws:
AssertionError- if the actual list is not sorted according to the given comparator.AssertionError- if the actual list isnull.NullPointerException- if the given comparator isnull.AssertionError- if the actual list elements are not mutually comparable according to given Comparator.
-
satisfies
Verifies that the actualListcontains a value at givenIndexthat satisfies the givenrequirements.Example:
List<TolkienCharacter> ringBearers = newArrayList(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 actualList.- Returns:
thisassertion object.- Throws:
AssertionError- if the value at givenIndexdoes not satisfy therequirements.AssertionError- if the actual list 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 actualList.- Since:
- 3.10.0
-
usingElementComparator
Description copied from class:AbstractIterableAssertUse given custom comparator instead of relying on actual type Aequalsmethod to compare group elements for incoming assertion checks.Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.
Examples :// compares invoices by payee assertThat(invoiceList).usingComparator(invoicePayeeComparator).isEqualTo(expectedInvoiceList); // compares invoices by date, doesNotHaveDuplicates and contains both use the given invoice date comparator assertThat(invoiceList).usingComparator(invoiceDateComparator).doesNotHaveDuplicates().contains(may2010Invoice); // as assertThat(invoiceList) creates a new assertion, it falls back to standard comparison strategy // based on Invoice's equal method to compare invoiceList elements to lowestInvoice. assertThat(invoiceList).contains(lowestInvoice); // standard comparison : the fellowshipOfTheRing includes Gandalf but not Sauron (believe me) ... assertThat(fellowshipOfTheRing).contains(gandalf) .doesNotContain(sauron); // ... but if we compare only races, Sauron is in fellowshipOfTheRing because he's a Maia like Gandalf. assertThat(fellowshipOfTheRing).usingElementComparator(raceComparator) .contains(sauron);- Specified by:
usingElementComparatorin interfaceEnumerableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingElementComparatorin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
customComparator- the comparator to use for incoming assertion checks.- Returns:
thisassertion object.
-
usingDefaultElementComparator
Description copied from class:AbstractIterableAssertRevert to standard comparison for incoming assertion group element checks.This method should be used to disable a custom comparison strategy set by calling
EnumerableAssert.usingElementComparator(Comparator).- Specified by:
usingDefaultElementComparatorin interfaceEnumerableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingDefaultElementComparatorin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Returns:
thisassertion object.
-
usingComparisonStrategy
- Overrides:
usingComparisonStrategyin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>>
-
as
Description copied from interface:DescriptableSets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
The description follows
String.format(String, Object...)syntax.Example :
try { // set an incorrect age to Mr Frodo which is really 33 years old. frodo.setAge(50); // specify a test description (call as() before the assertion !), it supports String format syntax. assertThat(frodo.getAge()).as("check %s's age", frodo.getName()).isEqualTo(33); } catch (AssertionError e) { assertThat(e).hasMessage("[check Frodo's age]\n expected: 33\n but was: 50"); }- Specified by:
asin interfaceDescriptable<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>> - Overrides:
asin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
description- the new description to set.args- optional parameter if description is a format String.- Returns:
thisobject.- See Also:
-
as
Description copied from interface:DescriptableSets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
This overloaded version of "describedAs" offers more flexibility than the one taking a
Stringby allowing users to pass their own implementation of a description. For example, a description that creates its value lazily, only when an assertion failure occurs.- Specified by:
asin interfaceDescriptable<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>> - Overrides:
asin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
description- the new description to set.- Returns:
thisobject.- See Also:
-
describedAs
Description copied from class:AbstractAssertSets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
This overloaded version of "describedAs" offers more flexibility than the one taking a
Stringby allowing users to pass their own implementation of a description. For example, a description that creates its value lazily, only when an assertion failure occurs.- Specified by:
describedAsin interfaceDescriptable<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>> - Overrides:
describedAsin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
description- the new description to set.- Returns:
thisobject.
-
describedAs
Description copied from interface:DescriptableSets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
Alias for
since "as" is a keyword in Groovy.Descriptable.as(String, Object...)- Specified by:
describedAsin interfaceDescriptable<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>> - Overrides:
describedAsin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
description- the new description to set.args- optional parameter if description is a format String.- Returns:
thisobject.
-
doesNotHave
Description copied from class:AbstractAssertVerifies that the actual value does not satisfy the given condition. This method is an alias for.ExtensionPoints.isNot(Condition)- Specified by:
doesNotHavein interfaceExtensionPoints<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
doesNotHavein classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
condition- the given condition.- Returns:
this ExtensionPointsobject.- See Also:
-
doesNotHaveSameClassAs
Description copied from class:AbstractAssertVerifies that the actual value does not have the same class as the given object.Example:
// assertions succeed assertThat(1).doesNotHaveSameClassAs("abc"); assertThat(new ArrayList<String>()).doesNotHaveSameClassAs(new LinkedList<String>()); // assertions fail assertThat(1).doesNotHaveSameClassAs(2); assertThat("abc").doesNotHaveSameClassAs("123"); assertThat(new ArrayList<String>()).doesNotHaveSameClassAs(new ArrayList<Integer>());- Specified by:
doesNotHaveSameClassAsin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
doesNotHaveSameClassAsin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
other- the object to check type against.- Returns:
- this assertion object.
-
has
Description copied from class:AbstractAssertVerifies that the actual value satisfies the given condition. This method is an alias for.ExtensionPoints.is(Condition)- Specified by:
hasin interfaceExtensionPoints<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
hasin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
condition- the given condition.- Returns:
this ExtensionPointsobject.- See Also:
-
hasSameClassAs
Description copied from class:AbstractAssertVerifies that the actual value has the same class as the given object.Example:
// assertions succeed assertThat(1).hasSameClassAs(2); assertThat("abc").hasSameClassAs("123"); assertThat(new ArrayList<String>()).hasSameClassAs(new ArrayList<Integer>()); // assertions fail assertThat(1).hasSameClassAs("abc"); assertThat(new ArrayList<String>()).hasSameClassAs(new LinkedList<String>());- Specified by:
hasSameClassAsin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
hasSameClassAsin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
other- the object to check type against.- Returns:
- this assertion object.
-
hasToString
Description copied from class:AbstractAssertVerifies that actualactual.toString()is equal to the givenString.Example :
CartoonCharacter homer = new CartoonCharacter("Homer"); // Instead of writing ... assertThat(homer.toString()).isEqualTo("Homer"); // ... you can simply write: assertThat(homer).hasToString("Homer");- Specified by:
hasToStringin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
hasToStringin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
expectedToString- the expected String description of actual.- Returns:
- this assertion object.
-
is
Description copied from class:AbstractAssertVerifies that the actual value satisfies the given condition. This method is an alias for.ExtensionPoints.has(Condition)- Specified by:
isin interfaceExtensionPoints<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
condition- the given condition.- Returns:
this ExtensionPointsobject.- See Also:
-
isEqualTo
Description copied from class:AbstractAssertVerifies that the actual value is equal to the given one.Example:
// assertions succeed assertThat("abc").isEqualTo("abc"); assertThat(new HashMap<String, Integer>()).isEqualTo(new HashMap<String, Integer>()); // assertions fail assertThat("abc").isEqualTo("123"); assertThat(new ArrayList<String>()).isEqualTo(1);- Specified by:
isEqualToin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isEqualToin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isExactlyInstanceOf
Description copied from class:AbstractAssertVerifies that the actual value is exactly an instance of the given type.Example:
// assertions succeed assertThat("abc").isExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isExactlyInstanceOf(ArrayList.class); assertThat(new HashMap<String, Integer>()).isExactlyInstanceOf(HashMap.class); // assertions fail assertThat(1).isExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isExactlyInstanceOf(List.class); assertThat(new HashMap<String, Integer>()).isExactlyInstanceOf(Map.class);- Specified by:
isExactlyInstanceOfin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isExactlyInstanceOfin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
type- the type to check the actual value against.- Returns:
- this assertion object.
-
isIn
Description copied from class:AbstractAssertVerifies that the actual value is present in the given iterable.This assertion always fails if the given iterable is empty.
Example:
Iterable<Ring> elvesRings = list(vilya, nenya, narya); // assertion succeeds assertThat(nenya).isIn(elvesRings); // assertions fail: assertThat(oneRing).isIn(elvesRings); assertThat(oneRing).isIn(emptyList());- Specified by:
isInin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isInin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
values- the given iterable to search the actual value in.- Returns:
thisassertion object.
-
isIn
Description copied from class:AbstractAssertVerifies that the actual value is present in the given array of values.This assertion always fails if the given array of values is empty.
Example:
Ring[] elvesRings = new Ring[] { vilya, nenya, narya }; // assertion succeeds assertThat(nenya).isIn(elvesRings); // assertions fail assertThat(oneRing).isIn(elvesRings); assertThat(oneRing).isIn(new Ring[0]);- Specified by:
isInin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isInin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
values- the given array to search the actual value in.- Returns:
thisassertion object.
-
isInstanceOf
Description copied from class:AbstractAssertVerifies that the actual value is an instance of the given type.Example:
// assertions succeed assertThat("abc").isInstanceOf(String.class); assertThat(new HashMap<String, Integer>()).isInstanceOf(HashMap.class); assertThat(new HashMap<String, Integer>()).isInstanceOf(Map.class); // assertions fail assertThat(1).isInstanceOf(String.class); assertThat(new ArrayList<String>()).isInstanceOf(LinkedList.class);- Specified by:
isInstanceOfin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isInstanceOfin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
type- the type to check the actual value against.- Returns:
- this assertion object.
-
isInstanceOfAny
Description copied from class:AbstractAssertVerifies that the actual value is an instance of any of the given types.Example:
// assertions succeed assertThat("abc").isInstanceOfAny(String.class, Integer.class); assertThat(new ArrayList<String>()).isInstanceOfAny(LinkedList.class, ArrayList.class); assertThat(new HashMap<String, Integer>()).isInstanceOfAny(TreeMap.class, Map.class); // assertions fail assertThat(1).isInstanceOfAny(Double.class, Float.class); assertThat(new ArrayList<String>()).isInstanceOfAny(LinkedList.class, Vector.class);- Specified by:
isInstanceOfAnyin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isInstanceOfAnyin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
types- the types to check the actual value against.- Returns:
- this assertion object.
-
isNot
Description copied from class:AbstractAssertVerifies that the actual value does not satisfy the given condition. This method is an alias for.ExtensionPoints.doesNotHave(Condition)- Specified by:
isNotin interfaceExtensionPoints<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
condition- the given condition.- Returns:
this ExtensionPointsobject.- See Also:
-
isNotEqualTo
Description copied from class:AbstractAssertVerifies that the actual value is not equal to the given one.Example:
// assertions succeed assertThat("abc").isNotEqualTo("123"); assertThat(new ArrayList<String>()).isNotEqualTo(1); // assertions fail assertThat("abc").isNotEqualTo("abc"); assertThat(new HashMap<String, Integer>()).isNotEqualTo(new HashMap<String, Integer>());- Specified by:
isNotEqualToin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotEqualToin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
other- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isNotExactlyInstanceOf
Description copied from class:AbstractAssertVerifies that the actual value is not exactly an instance of given type.Example:
// assertions succeed assertThat(1).isNotExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isNotExactlyInstanceOf(List.class); assertThat(new HashMap<String, Integer>()).isNotExactlyInstanceOf(Map.class); // assertions fail assertThat("abc").isNotExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isNotExactlyInstanceOf(ArrayList.class); assertThat(new HashMap<String, Integer>()).isNotExactlyInstanceOf(HashMap.class);- Specified by:
isNotExactlyInstanceOfin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotExactlyInstanceOfin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
type- the type to check the actual value against.- Returns:
- this assertion object.
-
isNotIn
Description copied from class:AbstractAssertVerifies that the actual value is not present in the given iterable.This assertion always succeeds if the given iterable is empty.
Example:
Iterable<Ring> elvesRings = list(vilya, nenya, narya); // assertions succeed: assertThat(oneRing).isNotIn(elvesRings); assertThat(oneRing).isNotIn(emptyList()); // assertions fails: assertThat(nenya).isNotIn(elvesRings);- Specified by:
isNotInin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotInin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
values- the given iterable to search the actual value in.- Returns:
thisassertion object.
-
isNotIn
Description copied from class:AbstractAssertVerifies that the actual value is not present in the given array of values.This assertion always succeeds if the given array of values is empty.
Example:
Ring[] elvesRings = new Ring[] { vilya, nenya, narya }; // assertions succeed assertThat(oneRing).isNotIn(elvesRings); assertThat(oneRing).isNotIn(new Ring[0]); // assertions fails: assertThat(nenya).isNotIn(elvesRings);- Specified by:
isNotInin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotInin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
values- the given array to search the actual value in.- Returns:
thisassertion object.
-
isNotInstanceOf
Description copied from class:AbstractAssertVerifies that the actual value is not an instance of the given type.Example:
// assertions succeed assertThat(1).isNotInstanceOf(Double.class); assertThat(new ArrayList<String>()).isNotInstanceOf(LinkedList.class); // assertions fail assertThat("abc").isNotInstanceOf(String.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOf(HashMap.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOf(Map.class);- Specified by:
isNotInstanceOfin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotInstanceOfin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
type- the type to check the actual value against.- Returns:
- this assertion object.
-
isNotInstanceOfAny
Description copied from class:AbstractAssertVerifies that the actual value is not an instance of any of the given types.Example:
// assertions succeed assertThat(1).isNotInstanceOfAny(Double.class, Float.class); assertThat(new ArrayList<String>()).isNotInstanceOfAny(LinkedList.class, Vector.class); // assertions fail assertThat(1).isNotInstanceOfAny(Double.class, Integer.class); assertThat(new ArrayList<String>()).isNotInstanceOfAny(LinkedList.class, ArrayList.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOfAny(TreeMap.class, Map.class);- Specified by:
isNotInstanceOfAnyin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotInstanceOfAnyin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
types- the types to check the actual value against.- Returns:
- this assertion object.
-
isNotOfAnyClassIn
Description copied from class:AbstractAssertVerifies that the actual value type is not in given types.Example:
// assertions succeed assertThat(new HashMap<String, Integer>()).isNotOfAnyClassIn(Map.class, TreeMap.class); assertThat(new ArrayList<String>()).isNotOfAnyClassIn(LinkedList.class, List.class); // assertions fail assertThat(new HashMap<String, Integer>()).isNotOfAnyClassIn(HashMap.class, TreeMap.class); assertThat(new ArrayList<String>()).isNotOfAnyClassIn(ArrayList.class, LinkedList.class);- Specified by:
isNotOfAnyClassInin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotOfAnyClassInin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
types- the types to check the actual value against.- Returns:
- this assertion object.
-
isNotNull
Description copied from class:AbstractAssertVerifies that the actual value is notnull.Example:
// assertions succeed assertThat("abc").isNotNull(); assertThat(new HashMap<String, Integer>()).isNotNull(); // assertions fails String value = null; assertThat(value).isNotNull();- Specified by:
isNotNullin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotNullin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Returns:
thisassertion object.
-
isNotSameAs
Description copied from class:AbstractAssertVerifies that the actual value is not the same as the given one, i.e., using == comparison.Example:
// Name is a class with first and last fields, two Names are equals if both first and last are equals. Name tyrion = new Name("Tyrion", "Lannister"); Name alias = tyrion; Name clone = new Name("Tyrion", "Lannister"); // assertions succeed: assertThat(clone).isNotSameAs(tyrion) .isEqualTo(tyrion); // assertion fails: assertThat(alias).isNotSameAs(tyrion);- Specified by:
isNotSameAsin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotSameAsin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
other- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isOfAnyClassIn
Description copied from class:AbstractAssertVerifies that the actual value type is in given types.Example:
// assertions succeed assertThat(new HashMap<String, Integer>()).isOfAnyClassIn(HashMap.class, TreeMap.class); assertThat(new ArrayList<String>()).isOfAnyClassIn(ArrayList.class, LinkedList.class); // assertions fail assertThat(new HashMap<String, Integer>()).isOfAnyClassIn(TreeMap.class, Map.class); assertThat(new ArrayList<String>()).isOfAnyClassIn(LinkedList.class, List.class);- Specified by:
isOfAnyClassInin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isOfAnyClassInin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
types- the types to check the actual value against.- Returns:
- this assertion object.
-
isSameAs
Description copied from class:AbstractAssertVerifies that the actual value is the same as the given one, i.e., using == comparison.Example:
// Name is a class with first and last fields, two Names are equals if both first and last are equals. Name tyrion = new Name("Tyrion", "Lannister"); Name alias = tyrion; Name clone = new Name("Tyrion", "Lannister"); // assertions succeed: assertThat(tyrion).isSameAs(alias) .isEqualTo(clone); // assertion fails: assertThat(tyrion).isSameAs(clone);- Specified by:
isSameAsin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isSameAsin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.
-
overridingErrorMessage
Description copied from class:AbstractAssertOverrides AssertJ default error message by the given one.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
The new error message is built using
String.format(String, Object...)if you provide args parameter (if you don't, the error message is taken as it is).Example:
assertThat(player.isRookie()).overridingErrorMessage("Expecting Player <%s> to be a rookie but was not.", player) .isTrue();- Overrides:
overridingErrorMessagein classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
newErrorMessage- the error message that will replace the default one provided by Assertj.args- the args used to fill error message as inString.format(String, Object...).- Returns:
- this assertion object.
-
usingDefaultComparator
Description copied from class:AbstractAssertRevert to standard comparison for the incoming assertion checks.This method should be used to disable a custom comparison strategy set by calling
usingComparator.- Specified by:
usingDefaultComparatorin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingDefaultComparatorin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Returns:
thisassertion object.
-
usingComparator
Description copied from class:AbstractAssertUse the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.The custom comparator is bound to assertion instance, meaning that if a new assertion instance is created, the default comparison strategy will be used.
Examples :
// frodo and sam are instances of Character with Hobbit race (obviously :). // raceComparator implements Comparator<Character> assertThat(frodo).usingComparator(raceComparator).isEqualTo(sam);- Specified by:
usingComparatorin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingComparatorin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
customComparator- the comparator to use for the incoming assertion checks.- Returns:
thisassertion object.
-
usingComparator
public SELF usingComparator(Comparator<? super ACTUAL> customComparator, String customComparatorDescription) Description copied from class:AbstractAssertUse the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.The custom comparator is bound to the current assertion chain, meaning that if a new assertion instance is created, the default comparison strategy will be used.
Examples :
// frodo and sam are instances of Character with Hobbit race (obviously :). // raceComparator implements Comparator<Character> assertThat(frodo).usingComparator(raceComparator, "Hobbit Race Comparator").isEqualTo(sam);- Specified by:
usingComparatorin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingComparatorin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
customComparator- the comparator to use for the incoming assertion checks.customComparatorDescription- comparator description to be used in assertion error messages- Returns:
thisassertion object.
-
withFailMessage
Description copied from class:AbstractAssertAlternative method forAbstractAssert.overridingErrorMessage(java.lang.String, java.lang.Object...)You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
Example:
assertThat(player.isRookie()).withFailMessage("Expecting Player <%s> to be a rookie but was not.", player) .isTrue();- Overrides:
withFailMessagein classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Parameters:
newErrorMessage- the error message that will replace the default one provided by Assertj.args- the args used to fill error message as inString.format(String, Object...).- Returns:
- this assertion object.
-
withThreadDumpOnError
Description copied from class:AbstractAssertIn case of an assertion error, a thread dump will be printed toSystem.err.Example :
assertThat("Messi").withThreadDumpOnError().isEqualTo("Ronaldo");will print a thread dump, something similar to this:
"JDWP Command Reader" java.lang.Thread.State: RUNNABLE "JDWP Event Helper Thread" java.lang.Thread.State: RUNNABLE "JDWP Transport Listener: dt_socket" java.lang.Thread.State: RUNNABLE "Signal Dispatcher" java.lang.Thread.State: RUNNABLE "Finalizer" java.lang.Thread.State: WAITING at java.lang.Object.wait(Native Method) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:189) "Reference Handler" java.lang.Thread.State: WAITING at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:503) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133) "main" java.lang.Thread.State: RUNNABLE at sun.management.ThreadImpl.dumpThreads0(Native Method) at sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:446) at org.assertj.core.internal.Failures.threadDumpDescription(Failures.java:193) at org.assertj.core.internal.Failures.printThreadDumpIfNeeded(Failures.java:141) at org.assertj.core.internal.Failures.failure(Failures.java:91) at org.assertj.core.internal.Objects.assertEqual(Objects.java:314) at org.assertj.core.api.AbstractAssert.isEqualTo(AbstractAssert.java:198) at org.assertj.examples.ThreadDumpOnErrorExample.main(ThreadDumpOnErrorExample.java:28)- Specified by:
withThreadDumpOnErrorin interfaceAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
withThreadDumpOnErrorin classAbstractIterableAssert<SELF extends AbstractListAssert<SELF,ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> - Returns:
- this assertion object.
-