package com.tisawesomeness.minecord.util;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class DiscordTest {

    private static final String ID = "292279711034245130";
    private static final String MENTION = "<@" + ID + ">";
    private static final String NICK_MENTION = "<@!" + ID + ">";

    private static final Discord.ParseOptions NORMAL = Discord.parseOptionsBuilder()
            .respondToMentions(true, ID)
            .build();
    private static final Discord.ParseOptions NO_MENTIONS = Discord.parseOptionsBuilder().build();
    private static final Discord.ParseOptions OPTIONAL_PREFIX = Discord.parseOptionsBuilder()
            .respondToMentions(true, ID)
            .prefixRequired(false)
            .build();

    @Test
    @DisplayName("Command parsing removes literal prefix")
    public void testParsePrefix() {
        assertThat(Discord.parseCommand("&ping", "&", NORMAL))
                .contains("ping");
    }
    @Test
    @DisplayName("Command parsing removes literal prefix plus space")
    public void testParsePrefixSpace() {
        assertThat(Discord.parseCommand("& ping", "&", NORMAL))
                .contains("ping");
    }
    @Test
    @DisplayName("Command parsing removes mention")
    public void testParseMention() {
        assertThat(Discord.parseCommand(MENTION + " ping", "&", NORMAL))
                .contains("ping");
    }
    @Test
    @DisplayName("Command parsing removes nick mention")
    public void testParseNickMention() {
        assertThat(Discord.parseCommand(NICK_MENTION + " ping", "&", NORMAL))
                .contains("ping");
    }
    @Test
    @DisplayName("Command parsing removes literal prefix even when string empty")
    public void testParsePrefixEmpty() {
        assertThat(Discord.parseCommand("&", "&", NORMAL))
                .contains("");
    }
    @Test
    @DisplayName("Command parsing removes literal prefix plus space even when string empty")
    public void testParsePrefixEmptySpace() {
        assertThat(Discord.parseCommand("& ", "&", NORMAL))
                .contains("");
    }
    @Test
    @DisplayName("Command parsing removes mention even when string empty")
    public void testParseMentionEmpty() {
        assertThat(Discord.parseCommand(MENTION, "&", NORMAL))
                .contains("");
    }
    @Test
    @DisplayName("Command parsing removes nick mention even when string empty")
    public void testParseNickMentionEmpty() {
        assertThat(Discord.parseCommand(NICK_MENTION, "&", NORMAL))
                .contains("");
    }

    @Test
    @DisplayName("Command parsing fails when no prefix")
    public void testParseNoPrefix() {
        assertThat(Discord.parseCommand("ping", "&", NO_MENTIONS))
                .isEmpty();
    }
    @Test
    @DisplayName("Command parsing does not remove mention when disabled")
    public void testParseMentionDisabled() {
        assertThat(Discord.parseCommand(MENTION + " ping", "&", NO_MENTIONS))
                .isEmpty();
    }
    @Test
    @DisplayName("Command parsing does not remove nick mention when disabled")
    public void testParseNickMentionDisabled() {
        assertThat(Discord.parseCommand(NICK_MENTION + " ping", "&", NO_MENTIONS))
                .isEmpty();
    }

    @Test
    @DisplayName("Command parsing removes literal prefix even when prefix optional")
    public void testParsePrefixOptional() {
        assertThat(Discord.parseCommand("&ping", "&", OPTIONAL_PREFIX))
                .contains("ping");
    }
    @Test
    @DisplayName("Command parsing removes literal prefix  plus spaceeven when prefix optional")
    public void testParsePrefixOptionalSpace() {
        assertThat(Discord.parseCommand("& ping", "&", OPTIONAL_PREFIX))
                .contains("ping");
    }
    @Test
    @DisplayName("Command parsing removes mention even when prefix optional")
    public void testParseMentionOptional() {
        assertThat(Discord.parseCommand(MENTION + " ping", "&", OPTIONAL_PREFIX))
                .contains("ping");
    }
    @Test
    @DisplayName("Command parsing removes nick mention even when prefix optional")
    public void testParseNickMentionOptional() {
        assertThat(Discord.parseCommand(NICK_MENTION + " ping", "&", OPTIONAL_PREFIX))
                .contains("ping");
    }
    @Test
    @DisplayName("Command parsing doesn't require prefix when prefix optional")
    public void testParseNoPrefixOptional() {
        assertThat(Discord.parseCommand("ping", "&", OPTIONAL_PREFIX))
                .contains("ping");
    }

}

@@ -171,16 +171,82 @@
 ertThat;
+%0Aimport static org.assertj.core.api.Assertions.assertThatThrownBy;
 %0A%0Apublic
@@ -690,32 +690,195 @@
 lder().build();%0A
+    private static final Discord.ParseOptions MANUAL_NO_MENTIONS = Discord.parseOptionsBuilder()%0A            .respondToMentions(false, null)%0A            .build();%0A
     private stat
@@ -3566,32 +3566,295 @@
 isEmpty();%0A    %7D
+%0A    @Test%0A    @DisplayName(%22Command parsing does not remove mention when disabled manually%22)%0A    public void testParseMentionDisabledManual() %7B%0A        assertThat(Discord.parseCommand(MENTION + %22 ping%22, %22&%22, MANUAL_NO_MENTIONS))%0A                .isEmpty();%0A    %7D
 %0A%0A    @Test%0A    
@@ -5135,10 +5135,311 @@
 %0A    %7D%0A%0A
+    @Test%0A    @DisplayName(%22Providing a null self id when responding to mentions throws NPE%22)%0A    public void testParseBuilderNullSelfId() %7B%0A        assertThatThrownBy(() -%3E Discord.parseOptionsBuilder().respondToMentions(true, null))%0A                .isInstanceOf(NullPointerException.class);%0A    %7D%0A%0A
 %7D%0A

Test discord parse builder edge cases