Remove old methods in Messages and add StringUtils tests
StringUtils - merge the two join methods to one common implementation with two interface; add tests Messages - remove the methods taking a String as code after the kind refactoring by @DNx5
This commit is contained in:
@@ -65,7 +65,7 @@ public class StringUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldJoinString() {
|
||||
public void shouldJoinStrings() {
|
||||
// given
|
||||
List<String> elements = Arrays.asList("test", "for", null, "join", "StringUtils");
|
||||
|
||||
@@ -76,6 +76,18 @@ public class StringUtilsTest {
|
||||
assertThat(result, equalTo("test, for, join, StringUtils"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldJoinStringArray() {
|
||||
// given
|
||||
String[] elements = {"A", "test", "sentence", "for", "the join", null, "method"};
|
||||
|
||||
// when
|
||||
String result = StringUtils.join("_", elements);
|
||||
|
||||
// then
|
||||
assertThat(result, equalTo("A_test_sentence_for_the join_method"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotHaveDelimiter() {
|
||||
// given
|
||||
@@ -88,6 +100,15 @@ public class StringUtilsTest {
|
||||
assertThat(result, equalTo("hello"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldJoinWithNullDelimiter() {
|
||||
// given/when
|
||||
String result = StringUtils.join(null, "A", "Few", "Words", "\n", "To", "Join");
|
||||
|
||||
// then
|
||||
assertThat(result, equalTo("AFewWordsToJoin"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFormatException() {
|
||||
// given
|
||||
|
||||
Reference in New Issue
Block a user