Create test for CommandManager; fix javadoc in CommandDescription
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link CommandManager}.
|
||||
*/
|
||||
public class CommandManagerTest {
|
||||
|
||||
@Test
|
||||
public void shouldInitializeCommands() {
|
||||
// given/when
|
||||
CommandManager manager = new CommandManager(true);
|
||||
int commandCount = manager.getCommandDescriptionCount();
|
||||
List<CommandDescription> commands = manager.getCommandDescriptions();
|
||||
|
||||
// then
|
||||
// It obviously doesn't make sense to test much of the concrete data
|
||||
// that is being initialized; we just want to guarantee with this test
|
||||
// that data is indeed being initialized and we take a few "probes"
|
||||
assertThat(commandCount, equalTo(9));
|
||||
assertThat(commandsIncludeLabel(commands, "authme"), equalTo(true));
|
||||
assertThat(commandsIncludeLabel(commands, "register"), equalTo(true));
|
||||
assertThat(commandsIncludeLabel(commands, "help"), equalTo(false));
|
||||
}
|
||||
|
||||
private static boolean commandsIncludeLabel(Iterable<CommandDescription> commands, String label) {
|
||||
for (CommandDescription command : commands) {
|
||||
if (command.getLabels().contains(label)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user