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 TypeMethodDescriptionvoidcollectAssertionError(AssertionError assertionError) This method can be used to collect soft assertion errors.voidreset()voidsetDelegate(AssertionErrorCollector assertionErrorCollector) Optionally sets a "delegate" collector into which the collected assertions will be deposited.voidIndicates/sets that the last assertion was a success.booleanReturns 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, waitMethods inherited from interface org.assertj.core.api.AssertionErrorCollector
onAssertionErrorCollected
-
Field Details
-
threadLocal
InheritableThreadLocal<AssertionErrorCollector> threadLocal
-
-
Constructor Details
-
ThreadLocalErrorCollector
ThreadLocalErrorCollector()
-
-
Method Details
-
getDelegate
- Specified by:
getDelegatein interfaceAssertionErrorCollector
-
setDelegate
Description copied from interface:AssertionErrorCollectorOptionally 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:
setDelegatein interfaceAssertionErrorCollector- Parameters:
assertionErrorCollector- theAssertionErrorCollectorto which the assertions will be forwarded.
-
reset
public void reset() -
collectAssertionError
Description copied from interface:AssertionErrorCollectorThis 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:
collectAssertionErrorin interfaceAssertionErrorCollector- Parameters:
assertionError- theAssertionErrorto collect.
-
assertionErrorsCollected
- Specified by:
assertionErrorsCollectedin interfaceAssertionErrorCollector
-
succeeded
public void succeeded()Description copied from interface:AssertionErrorCollectorIndicates/sets that the last assertion was a success.- Specified by:
succeededin interfaceAssertionErrorCollector
-
wasSuccess
public boolean wasSuccess()Description copied from interface:AssertionErrorCollectorReturns 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:
wasSuccessin interfaceAssertionErrorCollector- Returns:
- true if the last assertion was a success.
-