open fun <T> collectNullable(warningCannotEvaluate: Translatable, maybeSubject: MaybeSubject<T>, assertionCreator: CollectingAssertionPlantNullable<T>.() -> Unit): List<Assertion>
(source)
Collects the Assertion created by assertionCreator and uses the given maybeSubject as CollectingAssertionPlantNullable.subject if it is MaybeSubject.Present.
In case maybeSubject is MaybeSubject.Absent and assertionCreator is accessed, then a PlantHasNoSubjectException is thrown and caught in which case a single AssertionGroup with an ExplanatoryAssertionGroupType is returned containing the given warningCannotEvaluate.
warningCannotEvaluate
- The translatable used to explain why the assertions could not be evaluated.
assertionCreator
- The function which should at least create one assertion.
maybeSubject
- The subject which will be used for the CollectingAssertionPlantNullable.
IllegalArgumentException
- Might throw it in case not a single Assertion was collected
(e.g. ThrowingAssertionCollectorForExplanation does).
Return
A list with the collected assertion or an AssertionGroup with an ExplanatoryAssertionGroupType
containing a warning if maybeSubject is null
and an assertion function tries to access it.