parent
b8481873e9
commit
2635faa934
|
@ -27,15 +27,13 @@ class ListToStringUnitTest {
|
||||||
List<String> arraysAsList = Arrays.asList("ONE", "TWO", "THREE");
|
List<String> arraysAsList = Arrays.asList("ONE", "TWO", "THREE");
|
||||||
|
|
||||||
StringJoiner stringJoiner = new StringJoiner(",");
|
StringJoiner stringJoiner = new StringJoiner(",");
|
||||||
arraysAsList.stream()
|
arraysAsList.forEach(stringJoiner::add);
|
||||||
.forEach(v -> stringJoiner.add(v));
|
|
||||||
String commaSeparatedString = stringJoiner.toString();
|
String commaSeparatedString = stringJoiner.toString();
|
||||||
|
|
||||||
assertThat(commaSeparatedString).isEqualTo("ONE,TWO,THREE");
|
assertThat(commaSeparatedString).isEqualTo("ONE,TWO,THREE");
|
||||||
|
|
||||||
StringJoiner stringJoinerWithDelimiterPrefixSuffix = new StringJoiner(",", "[", "]");
|
StringJoiner stringJoinerWithDelimiterPrefixSuffix = new StringJoiner(",", "[", "]");
|
||||||
arraysAsList.stream()
|
arraysAsList.forEach(stringJoinerWithDelimiterPrefixSuffix::add);
|
||||||
.forEach(v -> stringJoinerWithDelimiterPrefixSuffix.add(v));
|
|
||||||
String commaSeparatedStringWithDelimiterPrefixSuffix = stringJoinerWithDelimiterPrefixSuffix.toString();
|
String commaSeparatedStringWithDelimiterPrefixSuffix = stringJoinerWithDelimiterPrefixSuffix.toString();
|
||||||
|
|
||||||
assertThat(commaSeparatedStringWithDelimiterPrefixSuffix).isEqualTo("[ONE,TWO,THREE]");
|
assertThat(commaSeparatedStringWithDelimiterPrefixSuffix).isEqualTo("[ONE,TWO,THREE]");
|
||||||
|
|
Loading…
Reference in New Issue