Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

using combinable matchers with streams #24

@adrian-herscu

Description

@adrian-herscu

This one works:

        assertThat(Stream.of(7, 3, 1, 4, 1), anyMatch(greaterThan(5)));

but now... there is another requirement!!!
The stream must not contain any zeros.
So I tried:

        assertThat(Stream.of(7, 3, 1, 4, 1),
            both(allMatch(is(not(0))))
              .and(anyMatch(greaterThan(5))));

which fails with IllegalStateException: stream has already been operated upon or closed

Seems that the both matcher causes the stream to be operated twice.
Other issue? Anyway to overcome this?

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