Search in sources :

Example 1 with Command

use of commands.model.Command in project KaellyBot by Kaysoro.

the class CommandPatternTest method testCommandCommand.

public void testCommandCommand() {
    Command cmd = new CommandCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "cmd CommandForbidden true").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "cmd CommandForbidden on").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "cmd CommandForbidden 0").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "cmd CommandForbidden false").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "cmd CommandForbidden off").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "cmd CommandForbidden 1").find());
    assertFalse(pattern.matcher(Constants.prefixCommand + "cmd").find());
    assertFalse(pattern.matcher(Constants.prefixCommand + "cmd CommandForbidden").find());
}
Also used : Pattern(java.util.regex.Pattern) Command(commands.model.Command)

Example 2 with Command

use of commands.model.Command in project KaellyBot by Kaysoro.

the class CommandPatternTest method testPortalCommand.

public void testPortalCommand() {
    Command cmd = new PortalCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "pos").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "pos dimension").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "pos dimensiôn").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "pos dimension [1,-1]").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "pos dimension -1 1").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "pos dimension 1,-1 1").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "pos dimension [1,-1] 1").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "pos dimension 1").find());
}
Also used : Pattern(java.util.regex.Pattern) Command(commands.model.Command)

Example 3 with Command

use of commands.model.Command in project KaellyBot by Kaysoro.

the class CommandPatternTest method testHelpCommand.

public void testHelpCommand() {
    Command cmd = new HelpCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "help").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "help help").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "help hélp").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "help !help").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "help !help2").find());
}
Also used : Pattern(java.util.regex.Pattern) Command(commands.model.Command)

Example 4 with Command

use of commands.model.Command in project KaellyBot by Kaysoro.

the class CommandPatternTest method testTutorialCommand.

public void testTutorialCommand() {
    Command cmd = new TutorialCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "tuto test").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "tuto tést test").find());
    assertFalse(pattern.matcher(Constants.prefixCommand + "tuto").find());
}
Also used : Pattern(java.util.regex.Pattern) Command(commands.model.Command)

Example 5 with Command

use of commands.model.Command in project KaellyBot by Kaysoro.

the class CommandPatternTest method testMapCommand.

public void testMapCommand() {
    Command cmd = new MapCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "map").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "map I II III").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "map 1 2 3").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "map i ii iii").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "map 1 ii III").find());
    assertFalse(pattern.matcher(Constants.prefixCommand + "map un deûx trôis").find());
}
Also used : Pattern(java.util.regex.Pattern) Command(commands.model.Command)

Aggregations

Command (commands.model.Command)32 Pattern (java.util.regex.Pattern)28 AbstractCommand (commands.model.AbstractCommand)4 Language (enums.Language)4 Matcher (java.util.regex.Matcher)4 ArrayList (java.util.ArrayList)2 AboutCommand (commands.classic.AboutCommand)1 CommandForbidden (data.CommandForbidden)1 Guild (data.Guild)1