Remove StringUtils#join in favor of String#join (Java 8)

This commit is contained in:
ljacqu
2016-10-02 12:44:10 +02:00
parent e07c685d2a
commit 71ac86ff02
19 changed files with 27 additions and 181 deletions
@@ -296,17 +296,12 @@ public class CommandInitializerTest {
* @return List of all bindings that lead to the command
*/
private static List<String> getAbsoluteLabels(CommandDescription command) {
String parentPath = "";
CommandDescription elem = command.getParent();
while (elem != null) {
parentPath = elem.getLabels().get(0) + " " + parentPath;
elem = elem.getParent();
}
parentPath = parentPath.trim();
CommandDescription parent = command.getParent();
String parentPath = (parent == null) ? "" : parent.getLabels().get(0) + " ";
List<String> bindings = new ArrayList<>(command.getLabels().size());
for (String label : command.getLabels()) {
bindings.add(StringUtils.join(" ", parentPath, label));
bindings.add(parentPath + label);
}
return bindings;
}
@@ -3,10 +3,6 @@ package fr.xephi.authme.command;
import fr.xephi.authme.TestHelper;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
@@ -15,42 +11,6 @@ import static org.junit.Assert.assertThat;
*/
public class CommandUtilsTest {
@Test
public void shouldPrintPartsForStringRepresentation() {
// given
Iterable<String> parts = Arrays.asList("some", "parts", "for", "test");
// when
String str = CommandUtils.labelsToString(parts);
// then
assertThat(str, equalTo("some parts for test"));
}
@Test
public void shouldPrintEmptyStringForNoArguments() {
// given
List<String> parts = Collections.emptyList();
// when
String str = CommandUtils.labelsToString(parts);
// then
assertThat(str, equalTo(""));
}
@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