StringUtils { public static String listToString(List<String> strings) { return Arrays.toString(Iterables.toArray(strings, String.class)); } private  StringUtils(); static String[] split(String text, String pattern); static String listToString(List<String> strings);  }
@Test void listToStringShouldThrowWhenListIsNull() { assertThatThrownBy(() -> StringUtils.listToString(null)) .isInstanceOf(NullPointerException.class); }
@Test void listToStringShouldReturnOnlyBracketsWhenListIsEmpty() { String listToString = StringUtils.listToString(ImmutableList.<String>of()); assertThat(listToString).isEqualTo("[]"); }
@Test void listToStringShouldReturnOneElementWhenListContainsOneElement() { String listToString = StringUtils.listToString(ImmutableList.of("first")); assertThat(listToString).isEqualTo("[first]"); }
@Test void listToStringShouldReturnSeparatedElementsWhenListContainsMultipleElements() { String listToString = StringUtils.listToString(ImmutableList.of("first", "second", "fourth")); assertThat(listToString).isEqualTo("[first, second, fourth]"); }
@Test void listToStringShouldThrowWhenListContainsANullElement() { assertThatThrownBy(() -> StringUtils.listToString(ImmutableList.of("first", null, "fourth"))) .isInstanceOf(NullPointerException.class); }