#336 Create command list generator in tools

- Add new conditional template tags [...] blabla [/...]
- Create logic for generating a list of commands
This commit is contained in:
ljacqu
2015-12-14 21:07:03 +01:00
parent 0fdc8d2810
commit 282f777311
9 changed files with 157 additions and 11 deletions
@@ -0,0 +1,52 @@
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"));
}
}