LoginSystem/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java
ljacqu 282f777311 #336 Create command list generator in tools
- Add new conditional template tags [...] blabla [/...]
- Create logic for generating a list of commands
2015-12-14 21:07:03 +01:00

53 lines
1.4 KiB
Java

package fr.xephi.authme.command;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
/**
* Test for {@link CommandUtils}.
*/
public class CommandUtilsTest {
@Test
public void shouldPrintLabels() {
// given
List<String> labels = Arrays.asList("authme", "help", "reload");
// when
String result = CommandUtils.labelsToString(labels);
// then
assertThat(result, equalTo("authme help reload"));
}
@Test
public void shouldReturnCommandPath() {
// given
CommandDescription base = CommandDescription.builder()
.labels("authme", "auth")
.description("Base")
.detailedDescription("Test base command.")
.executableCommand(mock(ExecutableCommand.class))
.build();
CommandDescription command = CommandDescription.builder()
.parent(base)
.labels("help", "h", "?")
.description("Child")
.detailedDescription("Test child command.")
.executableCommand(mock(ExecutableCommand.class))
.build();
// when
String commandPath = CommandUtils.constructCommandPath(command);
// then
assertThat(commandPath, equalTo("/authme help"));
}
}