mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-28 05:05:14 +01:00
Add test to verify the format of command labels
- Fix test class throwing NPE when run isolation -> attempts to get Logger from Wrapper
This commit is contained in:
parent
485b6934e6
commit
44eef346b9
@ -1,6 +1,7 @@
|
|||||||
package fr.xephi.authme.command;
|
package fr.xephi.authme.command;
|
||||||
|
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
|
import fr.xephi.authme.util.WrapperMock;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
@ -20,7 +22,7 @@ import static org.junit.Assert.fail;
|
|||||||
/**
|
/**
|
||||||
* Test for {@link CommandInitializer} to guarantee the integrity of the defined commands.
|
* Test for {@link CommandInitializer} to guarantee the integrity of the defined commands.
|
||||||
*/
|
*/
|
||||||
public class CommandManagerTest {
|
public class CommandInitializerTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the maximum allowed depths for nesting CommandDescription instances.
|
* Defines the maximum allowed depths for nesting CommandDescription instances.
|
||||||
@ -32,6 +34,7 @@ public class CommandManagerTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initializeCommandManager() {
|
public static void initializeCommandManager() {
|
||||||
|
WrapperMock.createInstance();
|
||||||
commands = CommandInitializer.getBaseCommands();
|
commands = CommandInitializer.getBaseCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +86,27 @@ public class CommandManagerTest {
|
|||||||
walkThroughCommands(commands, connectionTester);
|
walkThroughCommands(commands, connectionTester);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldUseProperLowerCaseLabels() {
|
||||||
|
// given
|
||||||
|
final Pattern invalidPattern = Pattern.compile("\\s");
|
||||||
|
BiConsumer labelFormatTester = new BiConsumer() {
|
||||||
|
@Override
|
||||||
|
public void accept(CommandDescription command, int depth) {
|
||||||
|
for (String label : command.getLabels()) {
|
||||||
|
if (!label.equals(label.toLowerCase())) {
|
||||||
|
fail("Label '" + label + "' should be lowercase");
|
||||||
|
} else if (invalidPattern.matcher(label).matches()) {
|
||||||
|
fail("Label '" + label + "' has whitespace");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// when/then
|
||||||
|
walkThroughCommands(commands, labelFormatTester);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldNotDefineSameLabelTwice() {
|
public void shouldNotDefineSameLabelTwice() {
|
||||||
// given
|
// given
|
Loading…
Reference in New Issue
Block a user