void () { final ArrayList<Integer> list1 = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5)); final Iterator<Integer> iterator = compose(Collections.singletonList(list1.iterator())); try { iterator.next(); iterator.remove(); iterator.remove(); // wrong, next() should be called inside fail(); } catch (IllegalStateException e) { // ok } }