Reputation: 360
I'm having
ArrayList<Executable>( () -> assertTrue(true), ... )
now I'm trying to convert it into an Stream<Executable>
to use assertAll Method.
public static void assertAll(Stream<Executable> executables)
throws MultipleFailuresError
How can I convert a ArrayList<Executable>
(if there is no cleaner way than ArrayList) into a Stream<Executable>
?
Upvotes: 2
Views: 3072
Reputation: 72854
Just call the stream()
method which is inherited by all classes implementing Collection
:
assertAll(executableList.stream());
Note that if you already have the elements of the ArrayList
readily available, you can already pass them to assertAll
, as there is an overloaded method that takes varargs input:
assertAll(() -> assertTrue(true), ...)
This way there is no need to create an ArrayList
or Stream
.
Upvotes: 4