Skip to content

Commit

Permalink
test(UniToPublisherTest): use Uni delay instead of manual delay
Browse files Browse the repository at this point in the history
This is an old TODO!
  • Loading branch information
jponge committed Mar 17, 2024
1 parent 402fd72 commit 4301829
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
import static org.assertj.core.api.Assertions.fail;

import java.io.IOException;
import java.util.concurrent.*;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Flow.Publisher;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.jupiter.api.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;

import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.subscribers.TestSubscriber;
Expand Down Expand Up @@ -144,16 +151,9 @@ public void testCancellationBetweenSubscriptionAndRequest() {

@Test
public void testCancellationBetweenRequestAndValue() {
// TODO This is a very broken implementation of "delay" - to be replace once delay is implemented
executor = Executors.newFixedThreadPool(1);
Publisher<Integer> publisher = Uni.createFrom().item(1).emitOn(executor).map(x -> {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return x;
}).convert().toPublisher();
Publisher<Integer> publisher = Uni.createFrom().item(1)
.onItem().delayIt().by(Duration.ofMillis(100))
.convert().toPublisher();

assertThat(publisher).isNotNull();
TestSubscriber<Integer> test = Flowable.fromPublisher(AdaptersToReactiveStreams.publisher(publisher)).test(0);
Expand Down

0 comments on commit 4301829

Please sign in to comment.