Search in sources :

Example 1 with ParallelFlowable

use of io.reactivex.rxjava3.parallel.ParallelFlowable in project RxJava by ReactiveX.

the class JavadocWording method flowableDocRefersToFlowableTypes.

@Test
public void flowableDocRefersToFlowableTypes() throws Exception {
    List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("Flowable"), "Flowable");
    assertFalse(list.isEmpty());
    StringBuilder e = new StringBuilder();
    for (RxMethod m : list) {
        int jdx;
        if (m.javadoc != null) {
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf("onSuccess", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions onSuccess\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf(" Observer", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("ObservableSource") && !m.signature.contains("Observable")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions Observer but not using Observable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf(" SingleObserver", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("SingleSource") && !m.signature.contains("Single")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions SingleObserver but not using Single\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf(" MaybeObserver", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("MaybeSource") && !m.signature.contains("Maybe")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions MaybeObserver but not using Maybe\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf(" Disposable", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Observable") && !m.signature.contains("ObservableSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource") && !m.signature.contains("Completable") && !m.signature.contains("CompletableSource") && !m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Disposable") && !m.signature.contains("void subscribe")) {
                        CharSequence subSequence = m.javadoc.subSequence(idx - 6, idx + 11);
                        if (idx < 6 || !subSequence.equals("{@link Disposable")) {
                            e.append("java.lang.RuntimeException: Flowable doc mentions Disposable but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                        }
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf("Observable", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Observable")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions Observable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf("ObservableSource", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("ObservableSource")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions ObservableSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            checkAtReturnAndSignatureMatch("Flowable", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "ConnectableFlowable", "ParallelFlowable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
            aOrAn(e, m, "Flowable");
            missingClosingDD(e, m, "Flowable", "io.reactivex.rxjava3.core");
            backpressureMentionedWithoutAnnotation(e, m, "Flowable");
        }
    }
    if (e.length() != 0) {
        System.out.println(e);
        fail(e.toString());
    }
}
Also used : RxMethod(io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod) Test(org.junit.Test)

Example 2 with ParallelFlowable

use of io.reactivex.rxjava3.parallel.ParallelFlowable in project RxJava by ReactiveX.

the class JavadocWording method parallelFlowableDocRefersToCorrectTypes.

@Test
public void parallelFlowableDocRefersToCorrectTypes() throws Exception {
    List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("ParallelFlowable", "io.reactivex.rxjava3.parallel"), "ParallelFlowable");
    assertFalse(list.isEmpty());
    StringBuilder e = new StringBuilder();
    for (RxMethod m : list) {
        int jdx;
        if (m.javadoc != null) {
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf("onSuccess", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions onSuccess\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf(" Observer", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("ObservableSource") && !m.signature.contains("Observable")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions Observer but not using Observable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf(" SingleObserver", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("SingleSource") && !m.signature.contains("Single")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions SingleObserver but not using Single\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf(" MaybeObserver", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("MaybeSource") && !m.signature.contains("Maybe")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions MaybeObserver but not using Maybe\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf(" Disposable", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Observable") && !m.signature.contains("ObservableSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource") && !m.signature.contains("Completable") && !m.signature.contains("CompletableSource") && !m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Disposable")) {
                        CharSequence subSequence = m.javadoc.subSequence(idx - 6, idx + 11);
                        if (idx < 6 || !subSequence.equals("{@link Disposable")) {
                            e.append("java.lang.RuntimeException: Flowable doc mentions Disposable but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                        }
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf("Observable", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Observable")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions Observable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            jdx = 0;
            for (; ; ) {
                int idx = m.javadoc.indexOf("ObservableSource", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("ObservableSource")) {
                        e.append("java.lang.RuntimeException: Flowable doc mentions ObservableSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            checkAtReturnAndSignatureMatch("ParallelFlowable", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "ConnectableFlowable", "ParallelFlowable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
            aOrAn(e, m, "ParallelFlowable");
            missingClosingDD(e, m, "ParallelFlowable", "io.reactivex.rxjava3.parallel");
            backpressureMentionedWithoutAnnotation(e, m, "ParallelFlowable");
        }
    }
    if (e.length() != 0) {
        System.out.println(e);
        fail(e.toString());
    }
}
Also used : RxMethod(io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod) Test(org.junit.Test)

Example 3 with ParallelFlowable

use of io.reactivex.rxjava3.parallel.ParallelFlowable in project RxJava by ReactiveX.

the class ParallelJoinTest method overflowSlowpathDelayError.

@Test
public void overflowSlowpathDelayError() {
    @SuppressWarnings("unchecked") final Subscriber<? super Integer>[] subs = new Subscriber[1];
    TestSubscriber<Integer> ts = new TestSubscriber<Integer>(1) {

        @Override
        public void onNext(Integer t) {
            super.onNext(t);
            if (t == 1) {
                subs[0].onNext(2);
                subs[0].onNext(3);
            }
        }
    };
    new ParallelFlowable<Integer>() {

        @Override
        public void subscribe(Subscriber<? super Integer>[] subscribers) {
            subs[0] = subscribers[0];
            subscribers[0].onSubscribe(new BooleanSubscription());
            subscribers[0].onNext(1);
        }

        @Override
        public int parallelism() {
            return 1;
        }
    }.sequentialDelayError(1).subscribe(ts);
    ts.request(1);
    ts.assertFailure(MissingBackpressureException.class, 1, 2);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Subscriber(org.reactivestreams.Subscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 4 with ParallelFlowable

use of io.reactivex.rxjava3.parallel.ParallelFlowable in project RxJava by ReactiveX.

the class ParallelJoinTest method overflowSlowpath.

@Test
public void overflowSlowpath() {
    @SuppressWarnings("unchecked") final Subscriber<? super Integer>[] subs = new Subscriber[1];
    TestSubscriber<Integer> ts = new TestSubscriber<Integer>(1) {

        @Override
        public void onNext(Integer t) {
            super.onNext(t);
            subs[0].onNext(2);
            subs[0].onNext(3);
        }
    };
    new ParallelFlowable<Integer>() {

        @Override
        public void subscribe(Subscriber<? super Integer>[] subscribers) {
            subs[0] = subscribers[0];
            subscribers[0].onSubscribe(new BooleanSubscription());
            subscribers[0].onNext(1);
        }

        @Override
        public int parallelism() {
            return 1;
        }
    }.sequential(1).subscribe(ts);
    ts.assertFailure(MissingBackpressureException.class, 1);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Subscriber(org.reactivestreams.Subscriber) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 5 with ParallelFlowable

use of io.reactivex.rxjava3.parallel.ParallelFlowable in project RxJava by ReactiveX.

the class ParallelJoinTest method overflowFastpathDelayError.

@Test
public void overflowFastpathDelayError() {
    new ParallelFlowable<Integer>() {

        @Override
        public void subscribe(Subscriber<? super Integer>[] subscribers) {
            subscribers[0].onSubscribe(new BooleanSubscription());
            subscribers[0].onNext(1);
            subscribers[0].onNext(2);
        }

        @Override
        public int parallelism() {
            return 1;
        }
    }.sequentialDelayError(1).test(0).requestMore(1).assertFailure(MissingBackpressureException.class, 1);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)4 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)2 RxMethod (io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod)2 Subscriber (org.reactivestreams.Subscriber)2