Search in sources :

Example 11 with io.reactivex.rxjava3.exceptions

use of io.reactivex.rxjava3.exceptions 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)8 RxMethod (io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod)6 Pattern (java.util.regex.Pattern)3 TestException (io.reactivex.rxjava3.exceptions.TestException)2 FetchCommand (commands.model.FetchCommand)1 Guild (data.Guild)1 OrderUser (data.OrderUser)1 ServerDofus (data.ServerDofus)1 Snowflake (discord4j.common.util.Snowflake)1 MessageCreateEvent (discord4j.core.event.domain.message.MessageCreateEvent)1 Member (discord4j.core.object.entity.Member)1 Message (discord4j.core.object.entity.Message)1 EmbedCreateSpec (discord4j.core.spec.EmbedCreateSpec)1 City (enums.City)1 Language (enums.Language)1 Order (enums.Order)1 exceptions (exceptions)1 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)1 CompositeException (io.reactivex.rxjava3.exceptions.CompositeException)1 ConnectConsumer (io.reactivex.rxjava3.internal.util.ConnectConsumer)1