Class ConcurrentResults<T>
- java.lang.Object
-
- com.github.robtimus.junit.support.concurrent.ConcurrentResults<T>
-
- Type Parameters:
T
- The type of result.
public final class ConcurrentResults<T> extends Object
A class that represents the results produced by aConcurrentRunner
.For each instance of this class, only one method should be called. Calling more than one method will cause an exception to be thrown.
- Author:
- Rob Spoor
- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
andAssertNoFailures()
Asserts that noExecutable
orThrowingSupplier
threw an error or exception.<R> R
andCollectResults(Collector<T,?,R> collector)
Collects the results produced by theConcurrentRunner
that created this object.List<T>
andListResults()
Returns a list with the results produced by theConcurrentRunner
that created this object.Stream<T>
andStreamResults()
Returns a stream with the results produced by theConcurrentRunner
that created this object.
-
-
-
Method Detail
-
andStreamResults
public Stream<T> andStreamResults()
Returns a stream with the results produced by theConcurrentRunner
that created this object.If any
Executable
orThrowingSupplier
threw an error or exception, the returned stream will throw an error or exception when a terminal operator is executed.- Returns:
- A stream with the results produced by the
ConcurrentRunner
that created this object.
-
andCollectResults
public <R> R andCollectResults(Collector<T,?,R> collector)
Collects the results produced by theConcurrentRunner
that created this object.This method is similar to calling
andStreamResults()
and then collecting the results using the given collector. The main difference is that this method will report every error and exception that was thrown instead of only the first.- Type Parameters:
R
- The result type of the collector.- Parameters:
collector
- The collector to use.- Returns:
- The result of applying the given collector to the results produced by the
ConcurrentRunner
that created this object. - Throws:
NullPointerException
- If the given collector isnull
.
-
andListResults
public List<T> andListResults()
Returns a list with the results produced by theConcurrentRunner
that created this object.This method is shorthand for calling
andCollectResults(Collector)
with a collector that returns a list. Whether or not this list is modifiable is unspecified.- Returns:
- A list with the results produced by the
ConcurrentRunner
that created this object.
-
andAssertNoFailures
public void andAssertNoFailures()
Asserts that noExecutable
orThrowingSupplier
threw an error or exception. If anyExecutable
orThrowingSupplier
threw an error or exception, this method will throw an error or exception.
-
-