doc / ch.tutteli.atrium.logic.creating.transformers / FeatureExtractor / extract

extract

abstract fun <T, R> extract(container: AssertionContainer<T>, description: Translatable, representationForFailure: Any, featureExtraction: (T) -> Option<R>, maybeSubAssertions: Option<Expect<R>.() -> Unit>, featureExpectOptions: FeatureExpectOptions<R>): FeatureExpect<T, R> (source)

Extracts a feature according to the given featureExtraction, creates an Expect for the new subject and applies maybeSubAssertions in case they are specified.

Parameters

container - the assertion container with the current subject (before the change)

description - Describes the feature

representationForFailure - Representation in case the extraction cannot be carried out.

featureExtraction - Extracts the feature where it returns the feature wrapped into a Some if the extraction as such can be carried out, otherwise None.

maybeSubAssertions - Optionally, subsequent assertions for the feature (the new subject). This is especially useful if the extraction cannot be carried out, because this way we can then already show to you (in error reporting) what you wanted to assert about the feature (which gives you more context to the error).

representationInsteadOfFeature - Per default the feature as such is used to represent itself. However, if you want a different representation, then use this parameter where passing null still means use the feature.

Return
The newly created Expect for the extracted feature.