Skip to content

Add support for flat extracting elements #424

Open
@22dasi1bwi

Description

@22dasi1bwi

I regularly find myself in a position where I have an Iterable of elements, where I want to extract a property which itself is an Iterable.

Up to this point, I needed to do the following:

assertThat(iterable).extracting { it.anotherIterable }.containsExactly(listOf(elementOne, elementTwo))

or in case of more complex logic

assertThat(iterable).transform { it.flatMap { result -> result.added + result.updated }.containsExactly(elementOne, elementTwo)

Having a function for flat mapping would ease that process:

assertThat(iterable).flatExtracting { it.anotherIterable}.containsExactly(elementOne, elementTwo)

or

assertThat(iterable).flatExtracting { result -> result.added + result.updated }.containsExactly(elementOne, elementTwo)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions