Create test for HelpSyntaxHelperTest

(cherry picked from commit 9a6e96d)
This commit is contained in:
ljacqu
2015-11-21 11:16:31 +01:00
parent e65319d42c
commit 115680a363
5 changed files with 164 additions and 25 deletions
@@ -681,6 +681,7 @@ public class CommandDescription {
*
* @param maximumArguments True if there is an argument maximum, based on the number of registered arguments.
*/
// TODO ljacqu 20151121: Rename the setter
public void setMaximumArguments(boolean maximumArguments) {
this.noArgumentMaximum = !maximumArguments;
}
@@ -54,6 +54,7 @@ public class CommandManager {
/**
* Register all commands.
*/
// TODO ljacqu 20151121: Create a builder class for CommandDescription
@SuppressWarnings({ "serial" })
public void registerCommands() {
// Register the base AuthMe Reloaded command
@@ -9,7 +9,11 @@ import fr.xephi.authme.util.ListUtils;
/**
*/
public class HelpSyntaxHelper {
public final class HelpSyntaxHelper {
private HelpSyntaxHelper() {
// Helper class
}
/**
* Get the proper syntax for a command.
@@ -19,8 +23,8 @@ public class HelpSyntaxHelper {
* @param alternativeLabel The alternative label to use for this command syntax.
* @param highlight True to highlight the important parts of this command.
*
* @return The command with proper syntax. */
* @return The command with proper syntax.
*/
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
public static String getCommandSyntax(CommandDescription commandDescription, CommandParts commandReference, String alternativeLabel, boolean highlight) {
// Create a string builder to build the command
@@ -35,9 +39,9 @@ public class HelpSyntaxHelper {
String commandLabel = helpCommandReference.get(helpCommandReference.getCount() - 1);
// Check whether the alternative label should be used
if(alternativeLabel != null)
if(alternativeLabel.trim().length() > 0)
commandLabel = alternativeLabel;
if (alternativeLabel != null && alternativeLabel.trim().length() > 0) {
commandLabel = alternativeLabel;
}
// Show the important bit of the command, highlight this part if required
sb.append(ListUtils.implode(parentCommand, (highlight ? ChatColor.YELLOW + "" + ChatColor.BOLD : "") + commandLabel, " "));
@@ -37,25 +37,6 @@ public class ListUtils {
return sb.toString();
}
/**
* Implode two lists of elements into a single string, with a specified separator.
*
* @param elements The first list of elements to implode.
* @param otherElements The second list of elements to implode.
* @param separator The separator to use.
*
* @return The result string. */
public static String implode(List<String> elements, List<String> otherElements, String separator) {
// Combine the lists
List<String> combined = new ArrayList<>();
combined.addAll(elements);
combined.addAll(otherElements);
// Implode and return the result
return implode(combined, separator);
}
/**
* Implode two elements into a single string, with a specified separator.
*