Search in sources :

Example 6 with io.reactivex.rxjava3.exceptions

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

the class ConnectableFlowable method connect.

/**
 * Instructs the {@code ConnectableFlowable} to begin emitting the items from its underlying
 * {@link Flowable} to its {@link Subscriber}s.
 * <p>
 * To disconnect from a synchronous source, use the {@link #connect(io.reactivex.rxjava3.functions.Consumer)} method.
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>The behavior is determined by the implementor of this abstract class.</dd>
 * </dl>
 *
 * @return the subscription representing the connection
 * @see <a href="http://reactivex.io/documentation/operators/connect.html">ReactiveX documentation: Connect</a>
 */
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public final Disposable connect() {
    ConnectConsumer cc = new ConnectConsumer();
    connect(cc);
    return cc.disposable;
}
Also used : ConnectConsumer(io.reactivex.rxjava3.internal.util.ConnectConsumer)

Example 7 with io.reactivex.rxjava3.exceptions

use of io.reactivex.rxjava3.exceptions in project KaellyBot by Kaysoro.

the class AlignmentCommand method request.

@Override
public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
    String content = m.group(1).trim();
    Optional<discord4j.core.object.entity.Guild> guild = message.getGuild().blockOptional();
    Optional<Member> user = message.getAuthorAsMember().blockOptional();
    // Initialisation du Filtre
    City city = null;
    Order order = null;
    if (guild.isPresent() && user.isPresent()) {
        ServerDofus server = ServerUtils.getDofusServerFrom(Guild.getGuild(guild.get()), message.getChannel().block());
        // Consultation filtré par niveau
        if ((m = Pattern.compile(">\\s+(\\d{1,3})(\\s+.+)?").matcher(content)).matches()) {
            int level = Integer.parseInt(m.group(1));
            if (m.group(2) != null) {
                ServerUtils.ServerQuery serverQuery = ServerUtils.getServerDofusFromName(m.group(2), lg);
                if (serverQuery.hasSucceed())
                    server = serverQuery.getServer();
                else {
                    serverQuery.getExceptions().forEach(e -> e.throwException(message, this, lg, serverQuery.getServersFound()));
                    return;
                }
            } else if (server == null) {
                notFoundServer.throwException(message, this, lg);
                return;
            }
            List<EmbedCreateSpec> embeds = OrderUser.getOrdersFromLevel(guild.get().getMembers().collectList().blockOptional().orElse(Collections.emptyList()), server, level, guild.get(), lg);
            for (EmbedCreateSpec embed : embeds) message.getChannel().flatMap(chan -> chan.createEmbed(embed)).subscribe();
        } else {
            // L'utilisateur concerné est-il l'auteur de la commande ?
            if (Pattern.compile("^<@[!|&]?\\d+>").matcher(content).find()) {
                content = content.replaceFirst("<@[!|&]?\\d+>", "").trim();
                Optional<Snowflake> memberId = message.getUserMentionIds().stream().findFirst();
                if (!memberId.isPresent()) {
                    BasicDiscordException.USER_NEEDED.throwException(message, this, lg);
                    return;
                }
                user = guild.get().getMemberById(memberId.get()).blockOptional();
            }
            // Consultation des données filtrés par utilisateur
            ServerUtils.ServerQuery serverQuery = ServerUtils.getServerDofusFromName(content, lg);
            if (!serverQuery.getServersFound().isEmpty() && Pattern.compile("(.+)").matcher(content).matches() || content.isEmpty()) {
                if (serverQuery.hasSucceed())
                    server = serverQuery.getServer();
                else if (server == null) {
                    if (!content.isEmpty())
                        serverQuery.getExceptions().forEach(e -> e.throwException(message, this, lg, serverQuery.getServersFound()));
                    else
                        notFoundServer.throwException(message, this, lg);
                    return;
                }
                if (user.isPresent()) {
                    List<EmbedCreateSpec> embeds = OrderUser.getOrdersFromUser(user.get(), server, lg);
                    for (EmbedCreateSpec embed : embeds) message.getChannel().flatMap(chan -> chan.createEmbed(embed)).subscribe();
                }
            } else // Enregistrement des données
            if ((m = Pattern.compile("(\\p{L}+)\\s+(\\p{L}+)\\s+(\\d{1,3})(\\s+.+)?").matcher(content)).matches()) {
                if (user.isPresent() && message.getAuthor().isPresent() && user.get().getId().equals(message.getAuthor().get().getId())) {
                    // Parsing des données et traitement des divers exceptions
                    List<City> cities = findCity(m.group(1), lg);
                    if (checkData(cities, tooMuchCities, notFoundCity, message, lg))
                        return;
                    city = cities.get(0);
                    List<Order> orders = findOrder(m.group(2), lg);
                    if (checkData(orders, tooMuchOrders, notFoundOrder, message, lg))
                        return;
                    order = orders.get(0);
                    int level = Integer.parseInt(m.group(3));
                    if (m.group(4) != null) {
                        ServerUtils.ServerQuery query = ServerUtils.getServerDofusFromName(m.group(4), lg);
                        if (query.hasSucceed())
                            server = query.getServer();
                        else {
                            query.getExceptions().forEach(e -> e.throwException(message, this, lg, query.getServersFound()));
                            return;
                        }
                    } else if (server == null) {
                        notFoundServer.throwException(message, this, lg);
                        return;
                    }
                    if (OrderUser.containsKeys(user.get().getId().asLong(), server, city, order)) {
                        OrderUser.get(user.get().getId().asLong(), server, city, order).get(0).setLevel(level);
                        if (level != 0)
                            message.getChannel().flatMap(chan -> chan.createMessage(Translator.getLabel(lg, "align.update"))).subscribe();
                        else
                            message.getChannel().flatMap(chan -> chan.createMessage(Translator.getLabel(lg, "align.reset"))).subscribe();
                    } else {
                        new OrderUser(user.get().getId().asLong(), server, city, order, level).addToDatabase();
                        if (level != 0)
                            message.getChannel().flatMap(chan -> chan.createMessage(Translator.getLabel(lg, "align.save"))).subscribe();
                        else
                            message.getChannel().flatMap(chan -> chan.createMessage(Translator.getLabel(lg, "align.no_reset"))).subscribe();
                    }
                } else
                    badUse.throwException(message, this, lg);
            } else // Consultation filtré par cité et/ou par ordre
            if ((m = Pattern.compile("(\\p{L}+)(\\s+\\p{L}+)?(\\s+[\\p{L}|\\W]+)?").matcher(content)).matches()) {
                if (m.group(3) != null) {
                    ServerUtils.ServerQuery query = ServerUtils.getServerDofusFromName(m.group(3), lg);
                    if (query.hasSucceed())
                        server = query.getServer();
                    else {
                        query.getExceptions().forEach(e -> e.throwException(message, this, lg, query.getServersFound()));
                        return;
                    }
                }
                // On a précisé à la fois une cité et un ordre
                if (m.group(2) != null) {
                    boolean is2Server = false;
                    if (m.group(3) == null) {
                        ServerUtils.ServerQuery query = ServerUtils.getServerDofusFromName(m.group(2), lg);
                        if (query.hasSucceed()) {
                            server = query.getServer();
                            is2Server = true;
                        } else {
                            query.getExceptions().forEach(e -> e.throwException(message, this, lg, query.getServersFound()));
                            return;
                        }
                    }
                    if (is2Server) {
                        // Est-ce un ordre ? une cité ?
                        String value = m.group(1).trim();
                        List<City> cities = findCity(value, lg);
                        List<Order> orders = findOrder(value, lg);
                        if (cities.isEmpty() && orders.isEmpty()) {
                            notFoundFilter.throwException(message, this, lg);
                            return;
                        }
                        if (cities.size() > 1 || orders.size() > 1) {
                            tooMuchFilters.throwException(message, this, lg);
                            return;
                        }
                        if (cities.size() == 1)
                            city = cities.get(0);
                        if (orders.size() == 1)
                            order = orders.get(0);
                    } else {
                        List<City> cities = findCity(m.group(1).trim(), lg);
                        if (checkData(cities, tooMuchCities, notFoundCity, message, lg))
                            return;
                        city = cities.get(0);
                        List<Order> orders = findOrder(m.group(2).trim(), lg);
                        if (checkData(orders, tooMuchOrders, notFoundOrder, message, lg))
                            return;
                        order = orders.get(0);
                    }
                } else {
                    // Is an order ? a city ?
                    List<City> cities = findCity(m.group(1).trim(), lg);
                    List<Order> orders = findOrder(m.group(1).trim(), lg);
                    if (cities.isEmpty() && orders.isEmpty()) {
                        notFoundFilter.throwException(message, this, lg);
                        return;
                    }
                    if (cities.size() > 1 || orders.size() > 1) {
                        tooMuchFilters.throwException(message, this, lg);
                        return;
                    }
                    if (cities.size() == 1)
                        city = cities.get(0);
                    if (orders.size() == 1)
                        order = orders.get(0);
                }
                if (server == null) {
                    notFoundServer.throwException(message, this, lg);
                    return;
                }
                List<EmbedCreateSpec> embeds = OrderUser.getOrdersFromCityOrOrder(guild.get().getMembers().collectList().blockOptional().orElse(Collections.emptyList()), server, city, order, guild.get(), lg);
                for (EmbedCreateSpec embed : embeds) message.getChannel().flatMap(chan -> chan.createEmbed(embed)).subscribe();
            } else
                badUse.throwException(message, this, lg);
        }
    }
}
Also used : Order(enums.Order) Language(enums.Language) MessageCreateEvent(discord4j.core.event.domain.message.MessageCreateEvent) ServerUtils(util.ServerUtils) OrderUser(data.OrderUser) Snowflake(discord4j.common.util.Snowflake) FetchCommand(commands.model.FetchCommand) Guild(data.Guild) exceptions(exceptions) Normalizer(java.text.Normalizer) ArrayList(java.util.ArrayList) ServerDofus(data.ServerDofus) City(enums.City) Consumer(java.util.function.Consumer) List(java.util.List) Matcher(java.util.regex.Matcher) Message(discord4j.core.object.entity.Message) Member(discord4j.core.object.entity.Member) EmbedCreateSpec(discord4j.core.spec.EmbedCreateSpec) Order(enums.Order) Optional(java.util.Optional) Translator(util.Translator) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) OrderUser(data.OrderUser) ServerDofus(data.ServerDofus) EmbedCreateSpec(discord4j.core.spec.EmbedCreateSpec) City(enums.City) ServerUtils(util.ServerUtils) Guild(data.Guild) Snowflake(discord4j.common.util.Snowflake) ArrayList(java.util.ArrayList) List(java.util.List) Member(discord4j.core.object.entity.Member)

Example 8 with io.reactivex.rxjava3.exceptions

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

the class ExceptionHelper method flatten.

/**
 * Returns a flattened list of Throwables from tree-like CompositeException chain.
 * @param t the starting throwable
 * @return the list of Throwables flattened in a depth-first manner
 */
public static List<Throwable> flatten(Throwable t) {
    List<Throwable> list = new ArrayList<>();
    ArrayDeque<Throwable> deque = new ArrayDeque<>();
    deque.offer(t);
    while (!deque.isEmpty()) {
        Throwable e = deque.removeFirst();
        if (e instanceof CompositeException) {
            CompositeException ce = (CompositeException) e;
            List<Throwable> exceptions = ce.getExceptions();
            for (int i = exceptions.size() - 1; i >= 0; i--) {
                deque.offerFirst(exceptions.get(i));
            }
        } else {
            list.add(e);
        }
    }
    return list;
}
Also used : CompositeException(io.reactivex.rxjava3.exceptions.CompositeException)

Example 9 with io.reactivex.rxjava3.exceptions

use of io.reactivex.rxjava3.exceptions 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 10 with io.reactivex.rxjava3.exceptions

use of io.reactivex.rxjava3.exceptions 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)

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