mirror of
https://github.com/tommyskeff/futur4j.git
synced 2026-01-18 07:16:45 +00:00
fix stream closed issue
This commit is contained in:
@@ -12,6 +12,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class PromiseTests {
|
||||
|
||||
@@ -210,4 +211,22 @@ public final class PromiseTests {
|
||||
assert promise2.getCompletion() != null && promise2.getCompletion().getException() instanceof IllegalStateException;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStream() {
|
||||
var res = promises.combine(Stream.of(1, 2, 3).map(promises::resolve)).await();
|
||||
assert res.size() == 3;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combineMappedTest() {
|
||||
var res = promises.combineMapped(List.of(1, 2, 3),
|
||||
n -> promises.start().thenSupplyDelayedAsync(() -> n * 2, 50, TimeUnit.MILLISECONDS)
|
||||
).await();
|
||||
|
||||
assert res.size() == 3;
|
||||
assert res.get(1) == 2;
|
||||
assert res.get(2) == 4;
|
||||
assert res.get(3) == 6;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user