doc / ch.tutteli.atrium.domain.creating.collectors / ThrowingAssertionCollectorForExplanation / collect

collect

abstract fun <E : Any> collect(warning: Translatable, assertionCreator: AssertionPlant<E>.() -> Unit, subject: E?): List<Assertion> (source)

Collects the Assertion created by assertionCreator and uses the given subject as CollectingAssertionPlant.subject if not null.

In case subject is null then a PlantHasNoSubjectException is thrown in case the subject is accessed. In such a case a single AssertionGroup with an ExplanatoryAssertionGroupType is returned containing the given warning.

In contrast to ThrowingAssertionCollectorForExplanation this assertion collector should not throw

Parameters

warning - The translatable used to explain why the assertions could not be evaluated.

assertionCreator - The function which should at least create one assertion.

subject - The subject which will be used for the AssertionPlant.

Exceptions

IllegalArgumentException - in case not a single Assertion was collected.

Return
A list with the collected assertion or an AssertionGroup with an ExplanatoryAssertionGroupType containing a warning if subject is null and an assertion function tries to access it.