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
Fields Modifier and Type Field Description (package private) InheritableThreadLocal<AssertionErrorCollector>
threadLocal
-
Constructor Summary
Constructors Constructor Description ThreadLocalErrorCollector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<AssertionError>
assertionErrorsCollected()
void
collectAssertionError(AssertionError assertionError)
This method can be used to collect soft assertion errors.Optional<AssertionErrorCollector>
getDelegate()
void
reset()
void
setDelegate(AssertionErrorCollector assertionErrorCollector)
Optionally sets a "delegate" collector into which the collected assertions will be deposited.void
succeeded()
Indicates/sets that the last assertion was a success.boolean
wasSuccess()
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 Detail
-
threadLocal
InheritableThreadLocal<AssertionErrorCollector> threadLocal
-
-
Method Detail
-
getDelegate
public Optional<AssertionErrorCollector> getDelegate()
- Specified by:
getDelegate
in interfaceAssertionErrorCollector
-
setDelegate
public void setDelegate(AssertionErrorCollector assertionErrorCollector)
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
public void collectAssertionError(AssertionError assertionError)
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
public List<AssertionError> 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.
-
-