Search in sources :

Example 31 with Command

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

the class CommandPatternTest method testJobCommand.

public void testJobCommand() {
    Command cmd = new JobCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "job job").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "job job 1").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "job job 78").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "job job 200").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "job pêcheur 200").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "job forgeur d'épée 200").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "job -all 200").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "job").find());
}
Also used : Pattern(java.util.regex.Pattern) Command(commands.model.Command)

Example 32 with Command

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

the class CommandPatternTest method testAdminCommand.

// ADMIN COMMANDS
public void testAdminCommand() {
    Command cmd = new AdminCommand();
    Pattern pattern = Pattern.compile("^" + Constants.prefixCommand + cmd.getName() + cmd.getPattern() + "$");
    assertTrue(pattern.matcher(Constants.prefixCommand + "admin").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "admin help").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "admin hélp").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "admin !help").find());
    assertTrue(pattern.matcher(Constants.prefixCommand + "admin !help2").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