DictionaryChunksWrapper implements Iterator<byte[]> { @Override public byte[] next() { if (iteratorIndex >= dictionaryChunks.get(outerIndex).size()) { iteratorIndex = 0; outerIndex++; } byte[] value = dictionaryChunks.get(outerIndex).get(iteratorIndex); currentIndex++; iteratorIndex++; return value; } DictionaryChunksWrapper(List<List<byte[]>> dictionaryChunks); @Override boolean hasNext(); @Override byte[] next(); @Override void remove(); int getSize();  }
@Test public void testNext() throws Exception { List<byte[]> actual = new ArrayList<>(); while (dictionaryChunksWrapper.hasNext()) { actual.add(dictionaryChunksWrapper.next()); } Assert.assertEquals(expectedData.size(), actual.size()); for (int i = 0; i < expectedData.size(); i++) { Assert.assertArrayEquals(actual.get(i), expectedData.get(i)); } }