Create test for CommandManager; fix javadoc in CommandDescription

This commit is contained in:
ljacqu
2015-11-21 22:32:16 +01:00
parent efb57989ed
commit cd728b569e
2 changed files with 99 additions and 74 deletions
@@ -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;
}
}