### Question:
CompoundList { public static <S> List<S> of(S left, List<? extends S> right) { if (right.isEmpty()) { return Collections.singletonList(left); } else { List<S> list = new ArrayList<S>(1 + right.size()); list.add(left); list.addAll(right); return list; } } private  CompoundList(); static List<S> of(S left, List<? extends S> right); static List<S> of(List<? extends S> left, S right); static List<S> of(List<? extends S> left, List<? extends S> right); static List<S> of(List<? extends S> left, List<? extends S> middle, List<? extends S> right);  }### Answer:
@Test public void testElementAndList() throws Exception { List<Object> list = CompoundList.of(first, Arrays.asList(second, third, forth)); assertThat(list.size(), is(4)); assertThat(list.get(0), is(first)); assertThat(list.get(1), is(second)); assertThat(list.get(2), is(third)); assertThat(list.get(3), is(forth)); }
@Test public void testListAndElement() throws Exception { List<Object> list = CompoundList.of(Arrays.asList(first, second, third), forth); assertThat(list.size(), is(4)); assertThat(list.get(0), is(first)); assertThat(list.get(1), is(second)); assertThat(list.get(2), is(third)); assertThat(list.get(3), is(forth)); }
@Test public void testListAndList() throws Exception { List<Object> list = CompoundList.of(Arrays.asList(first, second), Arrays.asList(third, forth)); assertThat(list.size(), is(4)); assertThat(list.get(0), is(first)); assertThat(list.get(1), is(second)); assertThat(list.get(2), is(third)); assertThat(list.get(3), is(forth)); }
@Test public void testListAndListAndList() throws Exception { List<Object> list = CompoundList.of(Collections.singletonList(first), Collections.singletonList(second), Collections.singletonList(third)); assertThat(list.size(), is(3)); assertThat(list.get(0), is(first)); assertThat(list.get(1), is(second)); assertThat(list.get(2), is(third)); }