doc / ch.tutteli.atrium.domain.creating.changers / FeatureExtractor / extract

extract

abstract fun <T, R> extract(originalAssertionContainer: Expect<T>, description: Translatable, representationForFailure: Any, featureExtraction: (T) -> Option<R>, maybeSubAssertions: Option<Expect<R>.() -> Unit>, representationInsteadOfFeature: ((R) -> Any)? = null): FeatureExpect<T, R>

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

Parameters

originalAssertionContainer - the assertion container with the current subject (before the change) -- if you use ExpectImpl.changeSubject.reported(...) within an assertion function (an extension function of Expect) then you usually pass this (so the instance of Expect) for this parameter.

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.