doc / ch.tutteli.atrium.api.fluent.en_GB / entries

entries

fun <E : Any, T : Iterable<E?>> IterableContains.CheckerOption<E?, T, InAnyOrderSearchBehaviour>.entries(assertionCreatorOrNull: (Expect<E>.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?): Expect<T>

Finishes the specification of the sophisticated contains assertion where an entry shall be searched which either holds all assertions assertionCreatorOrNull creates or needs to be null in case assertionCreatorOrNull is defined as null -- likewise an entry (can be the same) is searched for each of the otherAssertionCreatorsOrNulls.

Parameters

assertionCreatorOrNull - The identification lambda which creates the assertions which the entry we are looking for has to hold; or in other words, the function which defines whether an entry is the one we are looking for or not. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls - Additional identification lambdas which each identify (separately) an entry which we are looking for (see assertionCreatorOrNull for more information).

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InAnyOrderOnlySearchBehaviour>.entries(assertionCreatorOrNull: (Expect<E>.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?): Expect<T>

Finishes the specification of the sophisticated contains assertion where an entry needs to be contained in the Iterable which holds all assertions assertionCreatorOrNull creates or needs to be null in case assertionCreatorOrNull is defined as null -- likewise an entry for each otherAssertionCreatorsOrNulls needs to be contained in the Iterable where it does not matter in which order the entries appear but only as many entries should be returned by the Iterable as assertion creators are defined.

Notice, that a first-wins strategy applies which means your assertion creator lambdas -- which kind of serve as identification lambdas -- should be ordered in such a way that the most specific identification lambda appears first, not that a less specific lambda wins. For instance, given a setOf(1, 2) you should not search for entries({ isGreaterThan(0) }, { toBe(1) }) but for entries({ toBe(1) }, { isGreaterThan(0) }) otherwise isGreaterThan(0) matches 1 before toBe(1) would match it. As a consequence toBe(1) could only match the entry which is left -- in this case 2 -- and of course this would fail.

Note that we might change the signature of this function with the next version which will cause a binary backward compatibility break (see #292 for more information)

Parameters

assertionCreatorOrNull - The identification lambda which creates the assertions which the entry we are looking for has to hold; or in other words, the function which defines whether an entry is the one we are looking for or not. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls - Additional identification lambdas which each identify (separately) an entry which we are looking for (see assertionCreatorOrNull for more information).

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InOrderOnlySearchBehaviour>.entries(assertionCreatorOrNull: (Expect<E>.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?): Expect<T>

Finishes the specification of the sophisticated contains assertion where the Iterable needs to contain only an entry which holds all assertions assertionCreatorOrNull creates or is null in case assertionCreatorOrNull is defined as null and likewise a further entry for each otherAssertionCreatorsOrNulls (if given) whereas the entries have to appear in the specified order.

Note that we might change the signature of this function with the next version which will cause a binary backward compatibility break (see #292 for more information)

Parameters

assertionCreatorOrNull - The identification lambda which creates the assertions which the entry we are looking for has to hold; or in other words, the function which defines whether an entry is the one we are looking for or not. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls - Additional identification lambdas which each identify (separately) an entry which we are looking for (see assertionCreatorOrNull for more information).

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

fun <E : Any, T> IterableLikeContains.CheckerStep<out E?, T, InAnyOrderSearchBehaviour>.entries(assertionCreatorOrNull: (Expect<E>.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (an IterableLike) needs to contain an entry for assertionCreatorOrNull as well as for the otherAssertionCreatorsOrNulls where it does not matter in which order they appear -- an entry is contained if it either holds all assertions assertionCreatorOrNull creates or needs to be null in case assertionCreatorOrNull is defined as null.

Parameters

assertionCreatorOrNull - The identification lambda which creates the assertions which the entry we are looking for has to hold; or in other words, the function which defines whether an entry is the one we are looking for or not. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls - Additional identification lambdas which each identify (separately) an entry which we are looking for (see assertionCreatorOrNull for more information).

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.14.0 -- API existed for Iterable but not for IterableLike.

fun <E : Any, T> IterableLikeContains.EntryPointStep<out E?, T, InAnyOrderOnlySearchBehaviour>.entries(assertionCreatorOrNull: (Expect<E>.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (an IterableLike) needs to contain only an entry for assertionCreatorOrNull as well as for the otherAssertionCreatorsOrNulls where it does not matter in which order they appear -- an entry is contained if it either holds all assertions assertionCreatorOrNull creates or needs to be null in case assertionCreatorOrNull is defined as null.

Notice, that a first-wins strategy applies which means your assertion creator lambdas -- which kind of serve as identification lambdas -- should be ordered in such a way that the most specific identification lambda appears first, not that a less specific lambda wins. For instance, given a setOf(1, 2) you should not search for entries({ isGreaterThan(0) }, { toBe(1) }) but for entries({ toBe(1) }, { isGreaterThan(0) }) otherwise isGreaterThan(0) matches 1 before toBe(1) would match it. As a consequence toBe(1) could only match the entry which is left -- in this case 2 -- and of course this would fail.

Note that we might change the signature of this function with the next version which will cause a binary backward compatibility break (see #292 for more information)

Parameters

assertionCreatorOrNull - The identification lambda which creates the assertions which the entry we are looking for has to hold; or in other words, the function which defines whether an entry is the one we are looking for or not. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls - Additional identification lambdas which each identify (separately) an entry which we are looking for (see assertionCreatorOrNull for more information).

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.14.0 -- API existed for Iterable but not for IterableLike.

fun <E : Any, T> IterableLikeContains.EntryPointStep<out E?, T, InOrderOnlySearchBehaviour>.entries(assertionCreatorOrNull: (Expect<E>.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (an IterableLike) needs to contain only an entry for assertionCreatorOrNull as well as for the otherAssertionCreatorsOrNulls in the specified order -- an entry is contained if it either holds all assertions assertionCreatorOrNull creates or needs to be null in case assertionCreatorOrNull is defined as null.

Note that we might change the signature of this function with the next version which will cause a binary backward compatibility break (see #292 for more information)

Parameters

assertionCreatorOrNull - The identification lambda which creates the assertions which the entry we are looking for has to hold; or in other words, the function which defines whether an entry is the one we are looking for or not. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls - Additional identification lambdas which each identify (separately) an entry which we are looking for (see assertionCreatorOrNull for more information).

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.14.0 -- API existed for Iterable but not for IterableLike.

fun <K, V, T> MapLikeContains.EntryPointStep<K, V, T, InAnyOrderSearchBehaviour>.entries(keyValuePair: Pair<K, V>, vararg otherPairs: Pair<K, V>): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (a MapLike) needs to contain the given keyValuePair as well as the otherPairs where it does not matter in which order they appear.

Notice, that it does not search for unique matches. Meaning, if the map is mapOf('a' to 1) and keyValuePair is defined as 'a' to 1 and one of the otherPairs is defined as 'a' to 1 as well, then both match, even though they match the same entry.

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.15.0

inline fun <K, reified V : Any, T> MapLikeContains.EntryPointStep<K, out V?, T, InAnyOrderSearchBehaviour>.entries(keyValue: KeyValue<K, V>, vararg otherKeyValues: KeyValue<K, V>): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (a MapLike) needs to contain the given keyValue as well as the otherKeyValues where it does not matter in which order they appear -- an entry is contained if it has a key as defined by keyValue's KeyValue.key and a corresponding value which either holds all assertions keyValue's KeyValue.valueAssertionCreatorOrNull creates or needs to be null in case KeyValue.valueAssertionCreatorOrNull is defined as null.

Notice, that it does not search for unique matches. Meaning, if the map is mapOf('a' to 1) and keyValue is defined as Key('a') { isGreaterThan(0) } and one of the otherKeyValues is defined as Key('a') { isLessThan(2) } , then both match, even though they match the same entry.

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.15.0

fun <K, V, T> MapLikeContains.EntryPointStep<K, V, T, InAnyOrderOnlySearchBehaviour>.entries(keyValuePair: Pair<K, V>, vararg otherPairs: Pair<K, V>): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (a MapLike) needs to contain only the given keyValuePair as well as the otherPairs where it does not matter in which order they appear.

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.15.0

inline fun <K, reified V : Any, T> MapLikeContains.EntryPointStep<K, out V?, T, InAnyOrderOnlySearchBehaviour>.entries(keyValue: KeyValue<K, V>, vararg otherKeyValues: KeyValue<K, V>): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (a MapLike) needs to contain only the given keyValue as well as the otherKeyValues where it does not matter in which order they appear -- an entry is contained if it has a key as defined by keyValue's KeyValue.key and a corresponding value which either holds all assertions keyValue's KeyValue.valueAssertionCreatorOrNull creates or needs to be null in case KeyValue.valueAssertionCreatorOrNull is defined as null.

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.15.0

fun <K, V, T> MapLikeContains.EntryPointStep<K, V, T, InOrderOnlySearchBehaviour>.entries(keyValuePair: Pair<K, V>, vararg otherPairs: Pair<K, V>): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (a MapLike) needs to contain only the given keyValuePair as well as the otherPairs in the specified order.

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.15.0

inline fun <K, reified V : Any, T> MapLikeContains.EntryPointStep<K, out V?, T, InOrderOnlySearchBehaviour>.entries(keyValue: KeyValue<K, V>, vararg otherKeyValues: KeyValue<K, V>): Expect<T>

Finishes the specification of the sophisticated contains assertion where the subject (a MapLike) needs to contain only the given keyValue as well as the otherKeyValues in the specified order -- an entry is contained if it has a key as defined by keyValue's KeyValue.key and a corresponding value which either holds all assertions keyValue's KeyValue.valueAssertionCreatorOrNull creates or needs to be null in case KeyValue.valueAssertionCreatorOrNull is defined as null.

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

Since
0.15.0