Why does this not compile, oh, what to do?
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItems;
ArrayList<
ArrayList expected = new ArrayList();
expected.add(1);
expected.add(2);
hasItems(expected);
hasItems(T..t) is being expanded by the compiler to:
hasItems(new ArrayList[]{expected});
You are passing a single element array containing an ArrayList. If you change the ArrayList to an Array, then your code will work.
Integer[] expected = new Integer[]{1, 2};
hasItems(expected);
This will be expanded to:
hasItems(1, 2);