Search in sources :

Example 21 with Command

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

the class CommandPatternTest method testSetCommand.

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

Example 22 with Command

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

the class CommandPatternTest method testDistCommand.

public void testDistCommand() {
    Command cmd = new DistanceCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "dist [20,20]").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "dist [20 20]").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "dist [2, -20]").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "dist -20 20").find());
    assertFalse(pattern.matcher(Constants.prefixCommand + "dist").find());
}
Also used : Pattern(java.util.regex.Pattern) Command(commands.model.Command)

Example 23 with Command

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

the class CommandPatternTest method testRSSCommand.

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

Example 24 with Command

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

the class CommandPatternTest method testTalkCommand.

public void testTalkCommand() {
    Command cmd = new TalkCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "talk test").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "talk 5681 test").find());
    assertFalse(pattern.matcher(Constants.prefixCommand + "talk").find());
}
Also used : Pattern(java.util.regex.Pattern) Command(commands.model.Command)

Example 25 with Command

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

the class CommandPatternTest method testServerCommand.

public void testServerCommand() {
    Command cmd = new ServerCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "server").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "server dofus").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "server -reset").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