add toFuture method

This commit is contained in:
WhatCats
2024-04-08 10:05:05 +02:00
parent 54d7b02675
commit e8512df504
3 changed files with 31 additions and 4 deletions

View File

@@ -48,6 +48,21 @@ public final class PromiseTests {
assert !finished.get();
}
@Test
public void testToFuture() throws InterruptedException {
assert pfac.resolve(true).toFuture().getNow(false);
assert pfac.error(new Exception("Test")).toFuture().isCompletedExceptionally();
var finished = new AtomicBoolean();
pfac.start()
.thenRunDelayedAsync(() -> finished.set(true), 50, TimeUnit.MILLISECONDS)
.toFuture()
.cancel(true);
Thread.sleep(100L);
assert !finished.get();
}
@Test
public void testCombineUtil() throws TimeoutException {
pfac.all(