Class SoftAssertionsExtension.ThreadLocalErrorCollector
java.lang.Object
org.assertj.core.api.junit.jupiter.SoftAssertionsExtension.ThreadLocalErrorCollector
- All Implemented Interfaces:
AfterAssertionErrorCollected
,AssertionErrorCollector
- Enclosing class:
SoftAssertionsExtension
static class SoftAssertionsExtension.ThreadLocalErrorCollector
extends Object
implements AssertionErrorCollector
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) InheritableThreadLocal
<AssertionErrorCollector> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
collectAssertionError
(AssertionError assertionError) This method can be used to collect soft assertion errors.void
reset()
void
setDelegate
(AssertionErrorCollector assertionErrorCollector) Optionally sets a "delegate" collector into which the collected assertions will be deposited.void
Indicates/sets that the last assertion was a success.boolean
Returns the result of last soft assertion which can be used to decide what the next one should be.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.assertj.core.api.AssertionErrorCollector
onAssertionErrorCollected
-
Field Details
-
threadLocal
InheritableThreadLocal<AssertionErrorCollector> threadLocal
-
-
Constructor Details
-
ThreadLocalErrorCollector
ThreadLocalErrorCollector()
-
-
Method Details
-
getDelegate
- Specified by:
getDelegate
in interfaceAssertionErrorCollector
-
setDelegate
Description copied from interface:AssertionErrorCollector
Optionally sets a "delegate" collector into which the collected assertions will be deposited.Note that if you set a delegate, this instance will no longer collect or report assertion errors itself but will forward them all to the delegate for collection.
- Specified by:
setDelegate
in interfaceAssertionErrorCollector
- Parameters:
assertionErrorCollector
- theAssertionErrorCollector
to which the assertions will be forwarded.
-
reset
public void reset() -
collectAssertionError
Description copied from interface:AssertionErrorCollector
This method can be used to collect soft assertion errors.To be able to react after an assertion error is collected, use
AssertionErrorCollector.onAssertionErrorCollected(AssertionError)
.- Specified by:
collectAssertionError
in interfaceAssertionErrorCollector
- Parameters:
assertionError
- theAssertionError
to collect.
-
assertionErrorsCollected
- Specified by:
assertionErrorsCollected
in interfaceAssertionErrorCollector
-
succeeded
public void succeeded()Description copied from interface:AssertionErrorCollector
Indicates/sets that the last assertion was a success.- Specified by:
succeeded
in interfaceAssertionErrorCollector
-
wasSuccess
public boolean wasSuccess()Description copied from interface:AssertionErrorCollector
Returns the result of last soft assertion which can be used to decide what the next one should be.Example:
Person person = ... SoftAssertions soft = new SoftAssertions(); if (soft.assertThat(person.getAddress()).isNotNull().wasSuccess()) { soft.assertThat(person.getAddress().getStreet()).isNotNull(); }
- Specified by:
wasSuccess
in interfaceAssertionErrorCollector
- Returns:
- true if the last assertion was a success.
-