// Path: src/main/java/org/reactivejournal/impl/rxjava/RxJavaPlayer.java
// public class RxJavaPlayer<T> {
//     private ReactivePlayer reactivePlayer;
// 
//     public RxJavaPlayer(ReactiveJournal reactiveJournal){
//         reactivePlayer = reactiveJournal.createReactivePlayer();
//     }
// 
//     public Flowable<T> play(PlayOptions options){
//         return Flowable.fromPublisher(reactivePlayer.play(options));
//     }
// }
// 
// Path: src/main/java/org/reactivejournal/util/DSUtil.java
// public class DSUtil {
//     public static void sleep(int ms) {
//         try {
//             Thread.sleep(ms);
//         } catch (InterruptedException e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public static void exitAfter(int timeMs) {
//         new Thread(()->{
//             sleep(timeMs);
//             System.out.println("Exiting after waiting " + timeMs + "ms");
//             System.exit(0);
//         }).start();
//     }
// }


import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import org.junit.Assert;
import org.junit.Test;
import org.reactivejournal.impl.rxjava.RxJavaPlayer;
import org.reactivejournal.util.DSUtil;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
        AtomicInteger onNext = new AtomicInteger(0);
        AtomicInteger onComplete = new AtomicInteger(0);
        AtomicInteger onError = new AtomicInteger(0);

        long[] gapBetweenOneAndTwo = new long[1];
        long[] startTime = new long[1];

        recordedObservable.subscribe(i -> {
                    String s = (String) i;
                    if (s.equals("one")) {
                        startTime[0] = System.currentTimeMillis();
                        onNext.incrementAndGet();
                    }
                    if (s.equals("two")) {
                        gapBetweenOneAndTwo[0] = System.currentTimeMillis() - startTime[0];
                        onNext.incrementAndGet();
                    }
                },
                e -> {
                    onError.incrementAndGet();
                },
                () -> onComplete.incrementAndGet());

        Assert.assertEquals(2, onNext.get());
        Assert.assertEquals(0, onError.get());
        Assert.assertEquals(1, onComplete.get());
        System.out.println("Gap with actual was " + gapBetweenOneAndTwo[0]);
        Assert.assertTrue(gapBetweenOneAndTwo[0] > 900);


// Path: src/main/java/org/reactivejournal/impl/rxjava/RxJavaPlayer.java
// public class RxJavaPlayer<T> {
//     private ReactivePlayer reactivePlayer;
// 
//     public RxJavaPlayer(ReactiveJournal reactiveJournal){
//         reactivePlayer = reactiveJournal.createReactivePlayer();
//     }
// 
//     public Flowable<T> play(PlayOptions options){
//         return Flowable.fromPublisher(reactivePlayer.play(options));
//     }
// }
// 
// Path: src/main/java/org/reactivejournal/util/DSUtil.java
// public class DSUtil {
//     public static void sleep(int ms) {
//         try {
//             Thread.sleep(ms);
//         } catch (InterruptedException e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public static void exitAfter(int timeMs) {
//         new Thread(()->{
//             sleep(timeMs);
//             System.out.println("Exiting after waiting " + timeMs + "ms");
//             System.exit(0);
//         }).start();
//     }
// }


// Path: src/test/java/org/reactivejournal/impl/ReactiveReplayRateTest.java
import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import org.junit.Assert;
import org.junit.Test;
import org.reactivejournal.impl.rxjava.RxJavaPlayer;
import org.reactivejournal.util.DSUtil;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

        AtomicInteger onNext = new AtomicInteger(0);
        AtomicInteger onComplete = new AtomicInteger(0);
        AtomicInteger onError = new AtomicInteger(0);

        long[] gapBetweenOneAndTwo = new long[1];
        long[] startTime = new long[1];

        recordedObservable.subscribe(i -> {
                    String s = (String) i;
                    if (s.equals("one")) {
                        startTime[0] = System.currentTimeMillis();
                        onNext.incrementAndGet();
                    }
                    if (s.equals("two")) {
                        gapBetweenOneAndTwo[0] = System.currentTimeMillis() - startTime[0];
                        onNext.incrementAndGet();
                    }
                },
                e -> {
                    onError.incrementAndGet();
                },
                () -> onComplete.incrementAndGet());

        Assert.assertEquals(2, onNext.get());
        Assert.assertEquals(0, onError.get());
        Assert.assertEquals(1, onComplete.get());
        System.out.println("Gap with actual was " + gapBetweenOneAndTwo[0]);
        Assert.assertTrue(gapBetweenOneAndTwo[0] > 900);


        rxPlayer = new RxJavaPlayer(reactiveJournal);