open fun <T : Any> collect(warningCannotEvaluate: Translatable, maybeSubject: MaybeSubject<T>, assertionCreator: (CollectingAssertionPlant<T>.() -> Unit)?): List<Assertion>
(source)Collects the Assertion created by assertionCreator and uses the given maybeSubject as CollectingAssertionPlant.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 CollectingAssertionPlant.
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 MaybeSubject.Absent and an assertion function tries to access it.
abstract fun <T, A : BaseAssertionPlant<T, A>, C : BaseCollectingAssertionPlant<T, A, C>> collect(warningCannotEvaluate: Translatable, maybeSubject: MaybeSubject<T>, collectingPlantFactory: (() -> T) -> C, assertionCreator: (C.() -> Unit)?): List<Assertion>
(source)Collects the Assertion created by assertionCreator with the collecting assertion plant created by the given collectingPlantFactory and uses the given maybeSubject as BaseCollectingAssertionPlant.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.
maybeSubject
- The subject which will be used for the AssertionPlant.
collectingPlantFactory
- The factory method which creates the appropriate collecting plant which is suitable
for the given assertionCreator.
assertionCreator
- The function which should at least create one assertion.
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.