mirror of
https://github.com/tommyskeff/futur4j.git
synced 2026-01-18 07:16:45 +00:00
release v2.3.4
remove basic wrapper methods
This commit is contained in:
@@ -3,8 +3,6 @@ package dev.tommyjs.futur.promise;
|
||||
import dev.tommyjs.futur.executor.PromiseExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.redisson.api.RFuture;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -148,21 +146,11 @@ public abstract class AbstractPromiseFactory<F> implements PromiseFactory {
|
||||
return promise;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> @NotNull Promise<T> wrapMono(@NotNull Mono<T> mono) {
|
||||
return wrap(mono.toFuture());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> @NotNull Promise<T> wrap(@NotNull CompletableFuture<T> future) {
|
||||
return wrap(future, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> @NotNull Promise<T> wrapRedisson(@NotNull RFuture<T> future) {
|
||||
return wrap(future, future);
|
||||
}
|
||||
|
||||
private <T> @NotNull Promise<T> wrap(@NotNull CompletionStage<T> completion, Future<T> future) {
|
||||
Promise<T> promise = unresolved();
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ package dev.tommyjs.futur.promise;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.redisson.api.RFuture;
|
||||
import org.slf4j.Logger;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -89,10 +87,6 @@ public interface PromiseFactory {
|
||||
return race(false, promises);
|
||||
}
|
||||
|
||||
<T> @NotNull Promise<T> wrapMono(@NotNull Mono<T> mono);
|
||||
|
||||
<T> @NotNull Promise<T> wrapRedisson(@NotNull RFuture<T> future);
|
||||
|
||||
<T> @NotNull Promise<T> wrap(@NotNull CompletableFuture<T> future);
|
||||
|
||||
default @NotNull Promise<Void> start() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.tommyjs.futur;
|
||||
|
||||
import dev.tommyjs.futur.executor.PromiseExecutor;
|
||||
import dev.tommyjs.futur.executor.SinglePoolExecutor;
|
||||
import dev.tommyjs.futur.impl.SimplePromiseFactory;
|
||||
import dev.tommyjs.futur.promise.Promise;
|
||||
@@ -8,11 +7,9 @@ import dev.tommyjs.futur.promise.PromiseFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -22,22 +19,9 @@ public final class PromiseTests {
|
||||
private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(5);
|
||||
private final PromiseFactory pfac = new SimplePromiseFactory<>(new SinglePoolExecutor(executor), logger);
|
||||
|
||||
@Test
|
||||
public void testMono() {
|
||||
Exception value = new Exception("Test Error");
|
||||
|
||||
var error = pfac.wrapMono(Mono.error(value));
|
||||
assert Objects.requireNonNull(error.getCompletion()).isError();
|
||||
assert error.getCompletion().getException() == value;
|
||||
|
||||
var resolved = pfac.wrapMono(Mono.just(value));
|
||||
assert !Objects.requireNonNull(resolved.getCompletion()).isError();
|
||||
assert resolved.getCompletion().getResult() == value;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShutdown() {
|
||||
executor.close();
|
||||
executor.shutdown();
|
||||
Promise<?> promise = pfac.resolve(null).thenSupplyAsync(() -> null);
|
||||
try {
|
||||
promise.await();
|
||||
|
||||
Reference in New Issue
Block a user