CollectionUtil { @SafeVarargs public static <T> List<T> concatList(T... newItems) { return concatList(null, newItems); }  @SafeVarargs static List<T> concatList(T... newItems); @SafeVarargs static List<T> concatList(Collection<T> collection, T... newItems);  }
@Test public void concatWithNoNewItems() { ArrayList<String> originalList = new ArrayList<>(); originalList.add("hi"); originalList.add("sup"); List<String> result = CollectionUtil.concatList(originalList); assertThat(result) .containsExactly("hi", "sup"); }
@Test public void concatWithNewItems() { ArrayList<String> originalList = new ArrayList<>(); originalList.add("hi"); originalList.add("sup"); List<String> result = CollectionUtil.concatList(originalList, "nice", "dog"); assertThat(result) .containsExactly("hi", "sup", "nice", "dog"); }
@Test public void concatWithNewItemsAndNulls() { ArrayList<String> originalList = new ArrayList<>(); originalList.add("hi"); originalList.add("sup"); List<String> result = CollectionUtil.concatList(originalList, "nice", null, "dog", null); assertThat(result) .containsExactly("hi", "sup", "nice", "dog"); }
@Test public void concatWithNullBase() { List<String> result = CollectionUtil.concatList( "nice", null, "dog", null); assertThat(result) .containsExactly("nice", "dog"); }