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
List
s.- Author:
- Yvonne Wang, Alex Ruiz, Joel Costigliola, Mikhail Mazursky, Jacek Jackowiak
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractIterableAssert
iterables
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
-
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, ie 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, ie 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 actualList
contains a value at givenIndex
that 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 SELF
usingComparisonStrategy
(org.assertj.core.internal.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 Aequals
method 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
isUnmodifiable
Methods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, allSatisfy, 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, 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, zipSatisfy
Methods 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, 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.Descriptable
as
Methods inherited from interface org.assertj.core.api.EnumerableAssert
hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, isEmpty, isNotEmpty, isNullOrEmpty
Methods inherited from interface org.assertj.core.api.ObjectEnumerableAssert
allMatch, allMatch, allSatisfy, allSatisfy, 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, 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:
contains
in 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:
doesNotContain
in 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 givenList
isnull
or empty.NullPointerException
- if the givenIndex
isnull
.IndexOutOfBoundsException
- if the value of the givenIndex
is equal to or greater than the size of the givenList
.NullPointerException
- if the givenCondition
isnull
.AssertionError
- if the value in the givenList
at 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 givenList
isnull
or empty.NullPointerException
- if the givenIndex
isnull
.IndexOutOfBoundsException
- if the value of the givenIndex
is equal to or greater than the size of the givenList
.NullPointerException
- if the givenCondition
isnull
.AssertionError
- if the value in the givenList
at 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
Comparable
interface 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:
this
assertion 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
- theComparator
used to compare list elements- Returns:
this
assertion 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 actualList
contains a value at givenIndex
that 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 atIndex
to meet.index
- the index where the object should be stored in the actualList
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the value at givenIndex
does not satisfy therequirements
.AssertionError
- if the actual list isnull
.NullPointerException
- if the givenrequirements
arenull
.NullPointerException
- if the givenIndex
isnull
.IndexOutOfBoundsException
- if the value of the givenIndex
is equal to or greater than the size of the actualList
.- Since:
- 3.10.0
-
usingElementComparator
Description copied from class:AbstractIterableAssert
Use given custom comparator instead of relying on actual type Aequals
method 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:
usingElementComparator
in interfaceEnumerableAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingElementComparator
in 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:
this
assertion object.
-
usingDefaultElementComparator
Description copied from class:AbstractIterableAssert
Revert 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:
usingDefaultElementComparator
in interfaceEnumerableAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingDefaultElementComparator
in 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.
-
usingComparisonStrategy
protected SELF usingComparisonStrategy(org.assertj.core.internal.ComparisonStrategy comparisonStrategy) - Overrides:
usingComparisonStrategy
in 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:Descriptable
Sets 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:
as
in interfaceDescriptable<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>> - Overrides:
as
in 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:
this
object.- See Also:
-
as
Description copied from interface:Descriptable
Sets 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
String
by 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:
as
in interfaceDescriptable<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>> - Overrides:
as
in 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:
this
object.- See Also:
-
describedAs
Description copied from class:AbstractAssert
Sets 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
String
by 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:
describedAs
in interfaceDescriptable<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>> - Overrides:
describedAs
in 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:
this
object.
-
describedAs
Description copied from interface:Descriptable
Sets 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:
describedAs
in interfaceDescriptable<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>> - Overrides:
describedAs
in 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:
this
object.
-
doesNotHave
Description copied from class:AbstractAssert
Verifies that the actual value does not satisfy the given condition. This method is an alias for
.ExtensionPoints.isNot(Condition)
- Specified by:
doesNotHave
in interfaceExtensionPoints<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
doesNotHave
in 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 ExtensionPoints
object.- See Also:
-
doesNotHaveSameClassAs
Description copied from class:AbstractAssert
Verifies 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:
doesNotHaveSameClassAs
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
doesNotHaveSameClassAs
in 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:AbstractAssert
Verifies that the actual value satisfies the given condition. This method is an alias for
.ExtensionPoints.is(Condition)
- Specified by:
has
in interfaceExtensionPoints<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
has
in 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 ExtensionPoints
object.- See Also:
-
hasSameClassAs
Description copied from class:AbstractAssert
Verifies 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:
hasSameClassAs
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
hasSameClassAs
in 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:AbstractAssert
Verifies 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:
hasToString
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
hasToString
in 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:AbstractAssert
Verifies that the actual value satisfies the given condition. This method is an alias for
.ExtensionPoints.has(Condition)
- Specified by:
is
in interfaceExtensionPoints<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
is
in 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 ExtensionPoints
object.- See Also:
-
isEqualTo
Description copied from class:AbstractAssert
Verifies 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:
isEqualTo
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isEqualTo
in 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:
this
assertion object.
-
isExactlyInstanceOf
Description copied from class:AbstractAssert
Verifies 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:
isExactlyInstanceOf
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isExactlyInstanceOf
in 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:AbstractAssert
Verifies 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:
isIn
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isIn
in 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:
this
assertion object.
-
isIn
Description copied from class:AbstractAssert
Verifies 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:
isIn
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isIn
in 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:
this
assertion object.
-
isInstanceOf
Description copied from class:AbstractAssert
Verifies 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:
isInstanceOf
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isInstanceOf
in 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:AbstractAssert
Verifies 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:
isInstanceOfAny
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isInstanceOfAny
in 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:AbstractAssert
Verifies that the actual value does not satisfy the given condition. This method is an alias for
.ExtensionPoints.doesNotHave(Condition)
- Specified by:
isNot
in interfaceExtensionPoints<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNot
in 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 ExtensionPoints
object.- See Also:
-
isNotEqualTo
Description copied from class:AbstractAssert
Verifies 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:
isNotEqualTo
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotEqualTo
in 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:
this
assertion object.
-
isNotExactlyInstanceOf
Description copied from class:AbstractAssert
Verifies 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:
isNotExactlyInstanceOf
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotExactlyInstanceOf
in 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:AbstractAssert
Verifies 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:
isNotIn
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotIn
in 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:
this
assertion object.
-
isNotIn
Description copied from class:AbstractAssert
Verifies 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:
isNotIn
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotIn
in 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:
this
assertion object.
-
isNotInstanceOf
Description copied from class:AbstractAssert
Verifies 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:
isNotInstanceOf
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotInstanceOf
in 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:AbstractAssert
Verifies 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:
isNotInstanceOfAny
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotInstanceOfAny
in 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:AbstractAssert
Verifies 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:
isNotOfAnyClassIn
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotOfAnyClassIn
in 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:AbstractAssert
Verifies 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:
isNotNull
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotNull
in 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.
-
isNotSameAs
Description copied from class:AbstractAssert
Verifies that the actual value is not the same as the given one, ie 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:
isNotSameAs
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isNotSameAs
in 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:
this
assertion object.
-
isOfAnyClassIn
Description copied from class:AbstractAssert
Verifies 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:
isOfAnyClassIn
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isOfAnyClassIn
in 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:AbstractAssert
Verifies that the actual value is the same as the given one, ie 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:
isSameAs
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
isSameAs
in 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:
this
assertion object.
-
overridingErrorMessage
Description copied from class:AbstractAssert
Overrides 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:
overridingErrorMessage
in 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:AbstractAssert
Revert 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:
usingDefaultComparator
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingDefaultComparator
in 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.
-
usingComparator
Description copied from class:AbstractAssert
Use 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:
usingComparator
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingComparator
in 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:
this
assertion object.
-
usingComparator
public SELF usingComparator(Comparator<? super ACTUAL> customComparator, String customComparatorDescription) Description copied from class:AbstractAssert
Use 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, "Hobbit Race Comparator").isEqualTo(sam);
- Specified by:
usingComparator
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
usingComparator
in 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:
this
assertion object.
-
withFailMessage
Description copied from class:AbstractAssert
Alternative 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:
withFailMessage
in 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:AbstractAssert
In case of an assertion error, a thread dump will be printed toSystem.err
.Example :
will print a thread dump, something similar to this:assertThat("Messi").withThreadDumpOnError().isEqualTo("Ronaldo");
"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:
withThreadDumpOnError
in interfaceAssert<SELF extends AbstractListAssert<SELF,
ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends List<? extends ELEMENT>> - Overrides:
withThreadDumpOnError
in 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.
-