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

collect

open fun <T> collect(expect: Expect<T>, assertionCreator: Expect<T>.() -> Unit): Assertion

Uses the Expect.maybeSubject and delegates to the other overload.

See the other overload for more information.

abstract fun <T> collect(maybeSubject: Option<T>, assertionCreator: Expect<T>.() -> Unit): Assertion

Use this function if you want to make Assertions about a feature or you perform a type transformation or any other action which results in an assertion container being created and you do not require this resulting container.

Or in other words, you do not want to make further assertions about the resulting subject in the resulting sub assertion container.

Parameters

maybeSubject - Either Some wrapping the subject of the current assertion or None in case a previous subject change was not successful - used as subject for the given assertionCreator.

assertionCreator - A lambda which defines the assertions for the feature.

Exceptions

IllegalArgumentException - in case the given assertionCreator did not create a single assertion.

Return
The collected assertions as an AssertionGroup with an InvisibleAssertionGroupType.

open fun <T : Any> collect(plant: AssertionPlant<T>, assertionCreator: CollectingAssertionPlant<T>.() -> Unit): AssertionGroup
Deprecated: Switch from Assert to Expect and use the other overload; will be removed with 1.0.0

Use this function if you want to make Assertion about a feature or you perform a type transformation or any other action which results in a sub-AssertionPlant being created and you do not require this resulting plant.

Or in other words, you do not want to make further assertions about the resulting subject in the resulting sub assertion plant.

This function can be useful in several cases. For instance:

Parameters

plant - The plant from which the AssertionPlant.subject will be used as subject of the CollectingAssertionPlant.

assertionCreator - A lambda which typically creates a sub AssertionPlant and adds assertions to it. For instance, if you create a feature assertion or a type transformation assertion, you will typically end up creating a sub assertion plant which delegates created Assertions to the CollectingAssertionPlant.

Exceptions

IllegalArgumentException - in case the given assertionCreator did not create a single assertion, did not pass it to the CollectingAssertionPlant respectively.

Return
The collected assertions as an AssertionGroup with an InvisibleAssertionGroupType.

open fun <T : Any> collect(subjectProvider: () -> T, assertionCreator: CollectingAssertionPlant<T>.() -> Unit): AssertionGroup
Deprecated: Switch from Assert to Expect and use the other overload; will be removed with 1.0.0

Use this function if you want to make Assertion about a feature or you perform a type transformation or any other action which results in a sub-AssertionPlant being created and you do not require this resulting plant.

Or in other words, you do not want to make further assertions about the resulting subject in the resulting sub assertion plant.

This function can be useful in several cases. For instance:

Parameters

subjectProvider - Provides the subject which is used as CollectingAssertionPlant.subject.

assertionCreator - A lambda which typically creates a sub AssertionPlant and adds assertions to it. For instance, if you create a feature assertion or a type transformation assertion, you will typically end up creating a sub assertion plant which delegates created Assertions to the CollectingAssertionPlant.

Exceptions

IllegalArgumentException - in case the given assertionCreator did not create a single assertion, did not pass it to the CollectingAssertionPlant respectively.

Return
The collected assertions as an AssertionGroup with an InvisibleAssertionGroupType.

abstract fun <T, A : BaseAssertionPlant<T, A>, C : BaseCollectingAssertionPlant<T, A, C>> collect(subjectProvider: () -> T, collectingPlantFactory: (() -> T) -> C, assertionCreator: C.() -> Unit): AssertionGroup
Deprecated: Switch from Assert to Expect and use the other overload; will be removed with 1.0.0

Use this function if you want to make Assertion about a feature or you perform a type transformation or any other action which results in a sub-BaseAssertionPlant being created and you do not require this resulting plant.

Or in other words, you do not want to make further assertions about the resulting subject in the resulting sub assertion plant.

This function can be useful in several cases. For instance:

Parameters

subjectProvider - Provides the subject which is used as CollectingAssertionPlantNullable.subject.

collectingPlantFactory - The factory method which creates the appropriate collecting plant which is suitable for the given assertionCreator.

assertionCreator - A lambda which typically creates a sub AssertionPlant and adds assertions to it. For instance, if you create a feature assertion or a type transformation assertion, you will typically end up creating a sub assertion plant which delegates created Assertions to the CollectingAssertionPlant.

Exceptions

IllegalArgumentException - in case the given assertionCreator did not create a single assertion, did not pass it to the BaseCollectingAssertionPlant respectively.

Return
The collected assertions as an AssertionGroup with an InvisibleAssertionGroupType.