Search in sources :

Example 16 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class FlowableDoOnUnsubscribeTest method doOnUnSubscribeWorksWithRefCount.

@Test
public void doOnUnSubscribeWorksWithRefCount() throws Exception {
    int subCount = 3;
    final CountDownLatch upperLatch = new CountDownLatch(1);
    final CountDownLatch lowerLatch = new CountDownLatch(1);
    final CountDownLatch onNextLatch = new CountDownLatch(subCount);
    final AtomicInteger upperCount = new AtomicInteger();
    final AtomicInteger lowerCount = new AtomicInteger();
    Flowable<Long> longs = Flowable.interval(50, TimeUnit.MILLISECONDS).doOnCancel(new Action() {

        @Override
        public void run() {
            // Test that upper stream will be notified for un-subscription
            upperLatch.countDown();
            upperCount.incrementAndGet();
        }
    }).doOnNext(new Consumer<Long>() {

        @Override
        public void accept(Long aLong) {
            // Ensure there is at least some onNext events before un-subscription happens
            onNextLatch.countDown();
        }
    }).doOnCancel(new Action() {

        @Override
        public void run() {
            // Test that lower stream will be notified for un-subscription
            lowerLatch.countDown();
            lowerCount.incrementAndGet();
        }
    }).publish().refCount();
    List<Disposable> subscriptions = new ArrayList<>();
    List<TestSubscriber<Long>> subscribers = new ArrayList<>();
    for (int i = 0; i < subCount; ++i) {
        TestSubscriber<Long> subscriber = new TestSubscriber<>();
        longs.subscribe(subscriber);
        subscriptions.add(Disposable.fromSubscription(subscriber));
        subscribers.add(subscriber);
    }
    onNextLatch.await();
    for (int i = 0; i < subCount; ++i) {
        subscriptions.get(i).dispose();
    // Test that unsubscribe() method is not affected in any way
    }
    upperLatch.await();
    lowerLatch.await();
    assertEquals("There should exactly 1 un-subscription events for upper stream", 1, upperCount.get());
    assertEquals("There should exactly 1 un-subscription events for lower stream", 1, lowerCount.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 17 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class FlowableDoOnUnsubscribeTest method doOnUnsubscribe.

@Test
public void doOnUnsubscribe() throws Exception {
    int subCount = 3;
    final CountDownLatch upperLatch = new CountDownLatch(subCount);
    final CountDownLatch lowerLatch = new CountDownLatch(subCount);
    final CountDownLatch onNextLatch = new CountDownLatch(subCount);
    final AtomicInteger upperCount = new AtomicInteger();
    final AtomicInteger lowerCount = new AtomicInteger();
    Flowable<Long> longs = Flowable.interval(50, TimeUnit.MILLISECONDS).doOnCancel(new Action() {

        @Override
        public void run() {
            // Test that upper stream will be notified for un-subscription
            // from a child subscriber
            upperLatch.countDown();
            upperCount.incrementAndGet();
        }
    }).doOnNext(new Consumer<Long>() {

        @Override
        public void accept(Long aLong) {
            // Ensure there is at least some onNext events before un-subscription happens
            onNextLatch.countDown();
        }
    }).doOnCancel(new Action() {

        @Override
        public void run() {
            // Test that lower stream will be notified for a direct un-subscription
            lowerLatch.countDown();
            lowerCount.incrementAndGet();
        }
    });
    List<Disposable> subscriptions = new ArrayList<>();
    List<TestSubscriber<Long>> subscribers = new ArrayList<>();
    for (int i = 0; i < subCount; ++i) {
        TestSubscriber<Long> subscriber = new TestSubscriber<>();
        subscriptions.add(Disposable.fromSubscription(subscriber));
        longs.subscribe(subscriber);
        subscribers.add(subscriber);
    }
    onNextLatch.await();
    for (int i = 0; i < subCount; ++i) {
        subscriptions.get(i).dispose();
    // Test that unsubscribe() method is not affected in any way
    }
    upperLatch.await();
    lowerLatch.await();
    assertEquals(String.format("There should exactly %d un-subscription events for upper stream", subCount), subCount, upperCount.get());
    assertEquals(String.format("There should exactly %d un-subscription events for lower stream", subCount), subCount, lowerCount.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 18 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class JavadocWording method maybeDocRefersToMaybeTypes.

@Test
public void maybeDocRefersToMaybeTypes() throws Exception {
    List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("Maybe"), "Maybe");
    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("onNext", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher") && !m.signature.contains("Flowable") && !m.signature.contains("Observable") && !m.signature.contains("ObservableSource")) {
                        e.append("java.lang.RuntimeException: Maybe doc mentions onNext but no Flowable/Observable in signature\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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("Subscriber", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher") && !m.signature.contains("Flowable") && !m.signature.contains("TestSubscriber")) {
                        e.append("java.lang.RuntimeException: Maybe doc mentions Subscriber but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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(" Subscription", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher") && !m.signature.contains("Flowable")) {
                        e.append("java.lang.RuntimeException: Maybe doc mentions Subscription but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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") && !m.signature.contains("TestObserver")) {
                        if (idx < 5 || !m.javadoc.substring(idx - 5, idx + 8).equals("MaybeObserver")) {
                            e.append("java.lang.RuntimeException: Maybe doc mentions Observer but not using Observable\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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("Publisher", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher")) {
                        if (idx == 0 || !m.javadoc.substring(idx - 1, idx + 9).equals("(Publisher")) {
                            e.append("java.lang.RuntimeException: Maybe doc mentions Publisher but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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("Flowable", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Flowable")) {
                        Pattern p = Pattern.compile("@see\\s+#[A-Za-z0-9 _.,()]*Flowable");
                        if (!p.matcher(m.javadoc).find()) {
                            e.append("java.lang.RuntimeException: Maybe doc mentions Flowable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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("Single", jdx);
                if (idx >= 0 && m.javadoc.indexOf("Single#", jdx) != idx) {
                    int j = m.javadoc.indexOf("#toSingle", jdx);
                    int k = m.javadoc.indexOf("{@code Single", jdx);
                    if (!m.signature.contains("Single") && (j + 3 != idx && k + 7 != idx)) {
                        e.append("java.lang.RuntimeException: Maybe doc mentions Single but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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("SingleSource", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("SingleSource")) {
                        e.append("java.lang.RuntimeException: Maybe doc mentions SingleSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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")) {
                        Pattern p = Pattern.compile("@see\\s+#[A-Za-z0-9 _.,()]*Observable");
                        if (!p.matcher(m.javadoc).find()) {
                            e.append("java.lang.RuntimeException: Maybe doc mentions Observable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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: Maybe doc mentions ObservableSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            checkAtReturnAndSignatureMatch("Maybe", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
            aOrAn(e, m, "Maybe");
            missingClosingDD(e, m, "Maybe", "io.reactivex.rxjava3.core");
            backpressureMentionedWithoutAnnotation(e, m, "Maybe");
        }
    }
    if (e.length() != 0) {
        System.out.println(e);
        fail(e.toString());
    }
}
Also used : RxMethod(io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod) Pattern(java.util.regex.Pattern) Test(org.junit.Test)

Example 19 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class JavadocWording method singleDocRefersToSingleTypes.

@Test
public void singleDocRefersToSingleTypes() throws Exception {
    List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("Single"), "Single");
    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("onNext", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher") && !m.signature.contains("Flowable") && !m.signature.contains("Observable") && !m.signature.contains("ObservableSource")) {
                        e.append("java.lang.RuntimeException: Single doc mentions onNext but no Flowable/Observable in signature\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.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("Subscriber", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher") && !m.signature.contains("Flowable") && !m.signature.contains("TestSubscriber")) {
                        e.append("java.lang.RuntimeException: Single doc mentions Subscriber but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.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(" Subscription", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Flowable") && !m.signature.contains("Publisher")) {
                        e.append("java.lang.RuntimeException: Single doc mentions Subscription but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.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") && !m.signature.contains("TestObserver")) {
                        if (idx < 6 || !m.javadoc.substring(idx - 6, idx + 8).equals("SingleObserver")) {
                            e.append("java.lang.RuntimeException: Single doc mentions Observer but not using Observable\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.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("Publisher", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher")) {
                        if (idx == 0 || !m.javadoc.substring(idx - 1, idx + 9).equals("(Publisher")) {
                            e.append("java.lang.RuntimeException: Single doc mentions Publisher but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.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(" Flowable", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Flowable")) {
                        e.append("java.lang.RuntimeException: Single doc mentions Flowable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.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(" Maybe", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Maybe")) {
                        e.append("java.lang.RuntimeException: Single doc mentions Maybe but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.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(" MaybeSource", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("MaybeSource")) {
                        e.append("java.lang.RuntimeException: Single doc mentions SingleSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Maybe.method(Maybe.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: Single doc mentions Observable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.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: Single doc mentions ObservableSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Single.method(Single.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            checkAtReturnAndSignatureMatch("Single", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
            aOrAn(e, m, "Single");
            missingClosingDD(e, m, "Single", "io.reactivex.rxjava3.core");
            backpressureMentionedWithoutAnnotation(e, m, "Single");
        }
    }
    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 20 with io.reactivex.rxjava3.subscribers

use of io.reactivex.rxjava3.subscribers in project RxJava by ReactiveX.

the class JavadocWording method completableDocRefersToCompletableTypes.

@Test
public void completableDocRefersToCompletableTypes() throws Exception {
    List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("Completable"), "Completable");
    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("onNext", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher") && !m.signature.contains("Flowable") && !m.signature.contains("Observable") && !m.signature.contains("ObservableSource")) {
                        e.append("java.lang.RuntimeException: Completable doc mentions onNext but no Flowable/Observable in signature\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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("Subscriber", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher") && !m.signature.contains("Flowable") && !m.signature.contains("TestSubscriber")) {
                        e.append("java.lang.RuntimeException: Completable doc mentions Subscriber but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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(" Subscription", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Flowable") && !m.signature.contains("Publisher")) {
                        e.append("java.lang.RuntimeException: Completable doc mentions Subscription but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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") && !m.signature.contains("TestObserver")) {
                        if (idx < 11 || !m.javadoc.substring(idx - 11, idx + 8).equals("CompletableObserver")) {
                            e.append("java.lang.RuntimeException: Completable doc mentions Observer but not using Observable\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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("Publisher", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Publisher")) {
                        if (idx == 0 || !m.javadoc.substring(idx - 1, idx + 9).equals("(Publisher")) {
                            e.append("java.lang.RuntimeException: Completable doc mentions Publisher but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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("Flowable", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Flowable")) {
                        Pattern p = Pattern.compile("@see\\s+#[A-Za-z0-9 _.,()]*Flowable");
                        if (!p.matcher(m.javadoc).find()) {
                            e.append("java.lang.RuntimeException: Completable doc mentions Flowable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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("Single", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("Single")) {
                        Pattern p = Pattern.compile("@see\\s+#[A-Za-z0-9 _.,()]*Single");
                        if (!p.matcher(m.javadoc).find()) {
                            e.append("java.lang.RuntimeException: Completable doc mentions Single but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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("SingleSource", jdx);
                if (idx >= 0) {
                    if (!m.signature.contains("SingleSource")) {
                        Pattern p = Pattern.compile("@see\\s+#[A-Za-z0-9 _.,()]*SingleSource");
                        if (!p.matcher(m.javadoc).find()) {
                            e.append("java.lang.RuntimeException: Completable doc mentions SingleSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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")) {
                        Pattern p = Pattern.compile("@see\\s+#[A-Za-z0-9 _.,()]*Observable");
                        if (!p.matcher(m.javadoc).find()) {
                            e.append("java.lang.RuntimeException: Completable doc mentions Observable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.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")) {
                        Pattern p = Pattern.compile("@see\\s+#[A-Za-z0-9 _.,()]*ObservableSource");
                        if (!p.matcher(m.javadoc).find()) {
                            e.append("java.lang.RuntimeException: Completable doc mentions ObservableSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Completable.method(Completable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
                        }
                    }
                    jdx = idx + 6;
                } else {
                    break;
                }
            }
            checkAtReturnAndSignatureMatch("Completable", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
            aOrAn(e, m, "Completable");
            missingClosingDD(e, m, "Completable", "io.reactivex.rxjava3.core");
            backpressureMentionedWithoutAnnotation(e, m, "Completable");
        }
    }
    if (e.length() != 0) {
        System.out.println(e);
        fail(e.toString());
    }
}
Also used : RxMethod(io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod) Pattern(java.util.regex.Pattern) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)19 RxMethod (io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod)6 TestException (io.reactivex.rxjava3.exceptions.TestException)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)4 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)4 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)3 TestObserver (io.reactivex.rxjava3.observers.TestObserver)3 Disposable (io.reactivex.rxjava3.disposables.Disposable)2 Pattern (java.util.regex.Pattern)2 Subscriber (org.reactivestreams.Subscriber)2 SchedulerMultiWorkerSupport (io.reactivex.rxjava3.internal.schedulers.SchedulerMultiWorkerSupport)1 ConnectConsumer (io.reactivex.rxjava3.internal.util.ConnectConsumer)1 ConditionalSubscriber (io.reactivex.rxjava3.operators.ConditionalSubscriber)1 InOrder (org.mockito.InOrder)1