Small cleanups / changes amassed over time
- Small javadoc fixes - Simplifications - Move logException method from StringUtils to ExceptionUtils
This commit is contained in:
@@ -30,21 +30,9 @@ public class CodeClimateConfigTest {
|
||||
assertThat(excludePaths, not(empty()));
|
||||
removeTestsExclusionOrThrow(excludePaths);
|
||||
for (String path : excludePaths) {
|
||||
verifySourceFileExists(path);
|
||||
}
|
||||
}
|
||||
|
||||
private static void verifySourceFileExists(String path) {
|
||||
// Note ljacqu 20170323: In the future, we could have legitimate exclusions that don't fulfill these checks,
|
||||
// in which case this test needs to be adapted accordingly.
|
||||
if (!path.startsWith(TestHelper.SOURCES_FOLDER)) {
|
||||
fail("Unexpected path '" + path + "': expected to start with sources folder");
|
||||
} else if (!path.endsWith(".java")) {
|
||||
fail("Expected path '" + path + "' to end with '.java'");
|
||||
}
|
||||
|
||||
if (!new File(path).exists()) {
|
||||
fail("Path '" + path + "' does not exist!");
|
||||
if (!new File(path).exists()) {
|
||||
fail("Path '" + path + "' does not exist!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package fr.xephi.authme.message;
|
||||
|
||||
import fr.xephi.authme.TestHelper;
|
||||
import fr.xephi.authme.command.help.HelpSection;
|
||||
import fr.xephi.authme.util.ExceptionUtils;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -85,7 +86,7 @@ public class YamlTextFileCheckerTest {
|
||||
errors.add("Message for '" + mandatoryKey + "' is empty");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errors.add("Could not load file: " + StringUtils.formatException(e));
|
||||
errors.add("Could not load file: " + ExceptionUtils.formatException(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.TestHelper;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.Matchers.sameInstance;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -58,4 +60,16 @@ public class ExceptionUtilsTest {
|
||||
// given / when / then
|
||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(ExceptionUtils.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFormatException() {
|
||||
// given
|
||||
MalformedURLException ex = new MalformedURLException("Unrecognized URL format");
|
||||
|
||||
// when
|
||||
String result = ExceptionUtils.formatException(ex);
|
||||
|
||||
// then
|
||||
assertThat(result, equalTo("[MalformedURLException]: Unrecognized URL format"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package fr.xephi.authme.util;
|
||||
import fr.xephi.authme.TestHelper;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
@@ -63,18 +61,6 @@ public class StringUtilsTest {
|
||||
assertFalse(StringUtils.isEmpty(" test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFormatException() {
|
||||
// given
|
||||
MalformedURLException ex = new MalformedURLException("Unrecognized URL format");
|
||||
|
||||
// when
|
||||
String result = StringUtils.formatException(ex);
|
||||
|
||||
// then
|
||||
assertThat(result, equalTo("[MalformedURLException]: Unrecognized URL format"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetDifferenceWithNullString() {
|
||||
// given/when/then
|
||||
|
||||
Reference in New Issue
Block a user