Minor: Rename StringUtils#isEmpty to #isBlank
- Better fits the naming used by other tools and also the JDK (String#isBlank as of JDK 11)
This commit is contained in:
@@ -138,11 +138,11 @@ public class CommandInitializerTest {
|
||||
String forCommandText = " for command with labels '" + command.getLabels() + "'";
|
||||
|
||||
assertThat("has description" + forCommandText,
|
||||
StringUtils.isEmpty(command.getDescription()), equalTo(false));
|
||||
StringUtils.isBlank(command.getDescription()), equalTo(false));
|
||||
assertThat("short description doesn't end in '.'" + forCommandText,
|
||||
command.getDescription().endsWith("."), equalTo(false));
|
||||
assertThat("has detailed description" + forCommandText,
|
||||
StringUtils.isEmpty(command.getDetailedDescription()), equalTo(false));
|
||||
StringUtils.isBlank(command.getDetailedDescription()), equalTo(false));
|
||||
assertThat("detailed description ends in '.'" + forCommandText,
|
||||
command.getDetailedDescription().endsWith("."), equalTo(true));
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ConverterCommandTest {
|
||||
// when / then
|
||||
for (Map.Entry<String, Class<? extends Converter>> entry : ConverterCommand.CONVERTERS.entrySet()) {
|
||||
assertThat("Name is not null or empty",
|
||||
StringUtils.isEmpty(entry.getKey()), equalTo(false));
|
||||
StringUtils.isBlank(entry.getKey()), equalTo(false));
|
||||
|
||||
assertThat("Converter class is unique for each entry",
|
||||
classes.add(entry.getValue()), equalTo(true));
|
||||
|
||||
+2
-2
@@ -23,14 +23,14 @@ public class HelpMessageAndHelpSectionConsistencyTest {
|
||||
// when / then
|
||||
for (HelpMessage message : HelpMessage.values()) {
|
||||
assertThat("Key for message '" + message + "' is empty",
|
||||
StringUtils.isEmpty(message.getKey()), equalTo(false));
|
||||
StringUtils.isBlank(message.getKey()), equalTo(false));
|
||||
if (!keys.add(message.getKey())) {
|
||||
fail("Key for message '" + message + "' is already used elsewhere");
|
||||
}
|
||||
}
|
||||
for (HelpSection section : HelpSection.values()) {
|
||||
assertThat("Key for section '" + section + "' is empty",
|
||||
StringUtils.isEmpty(section.getKey()), equalTo(false));
|
||||
StringUtils.isBlank(section.getKey()), equalTo(false));
|
||||
if (!keys.add(section.getKey())) {
|
||||
fail("Key for section '" + section + "' is already used elsewhere");
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class MessageKeyTest {
|
||||
String key = messageKey.getKey();
|
||||
if (!keys.add(key)) {
|
||||
fail("Found key '" + messageKey.getKey() + "' twice!");
|
||||
} else if (StringUtils.isEmpty(key)) {
|
||||
} else if (StringUtils.isBlank(key)) {
|
||||
fail("Key for message key '" + messageKey + "' is empty");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class MessagesFileConsistencyTest {
|
||||
final String key = messageKey.getKey();
|
||||
final String message = reader.getString(key);
|
||||
|
||||
if (StringUtils.isEmpty(message)) {
|
||||
if (StringUtils.isBlank(message)) {
|
||||
errors.add("Messages file should have message for key '" + key + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class YamlTextFileCheckerTest {
|
||||
private void checkFile(File file, String mandatoryKey, List<String> errors) {
|
||||
try {
|
||||
PropertyReader reader = new YamlFileReader(file);
|
||||
if (StringUtils.isEmpty(reader.getString(mandatoryKey))) {
|
||||
if (StringUtils.isBlank(reader.getString(mandatoryKey))) {
|
||||
errors.add("Message for '" + mandatoryKey + "' is empty");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -74,9 +74,9 @@ public class HashAlgorithmIntegrationTest {
|
||||
}
|
||||
HashedPassword hashedPassword = method.computeHash("pwd", "name");
|
||||
assertThat("Salt should not be null if method.hasSeparateSalt(), and vice versa. Method: '"
|
||||
+ method + "'", StringUtils.isEmpty(hashedPassword.getSalt()), equalTo(!method.hasSeparateSalt()));
|
||||
+ method + "'", StringUtils.isBlank(hashedPassword.getSalt()), equalTo(!method.hasSeparateSalt()));
|
||||
assertThat("Hash should not be empty for method '" + method + "'",
|
||||
StringUtils.isEmpty(hashedPassword.getHash()), equalTo(false));
|
||||
StringUtils.isBlank(hashedPassword.getHash()), equalTo(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,15 +49,15 @@ public class StringUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCheckIsEmptyUtil() {
|
||||
public void shouldCheckIfIsBlankString() {
|
||||
// Should be true for null/empty/whitespace
|
||||
assertTrue(StringUtils.isEmpty(null));
|
||||
assertTrue(StringUtils.isEmpty(""));
|
||||
assertTrue(StringUtils.isEmpty(" \t"));
|
||||
assertTrue(StringUtils.isBlank(null));
|
||||
assertTrue(StringUtils.isBlank(""));
|
||||
assertTrue(StringUtils.isBlank(" \t"));
|
||||
|
||||
// Should be false if string has content
|
||||
assertFalse(StringUtils.isEmpty("P"));
|
||||
assertFalse(StringUtils.isEmpty(" test"));
|
||||
assertFalse(StringUtils.isBlank("P"));
|
||||
assertFalse(StringUtils.isBlank(" test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user