ChangedList implements Serializable { public synchronized List<File> peek(int maxFiles) { List<File> files = new LinkedList<File>(); Iterator<Entry<String, ChangedFile>> it = this.fileList.entrySet().iterator(); int count = 0; while (it.hasNext() && count < maxFiles) { files.add(it.next().getValue().getFile()); count++; } return files; } private  ChangedList(); static synchronized ChangedList getInstance(); void setFileExclusionManager(FileExclusionManager fileExclusionManager); boolean addChangedFile(final File changedFile); int getListSize(); int getListSizeIncludingReservedFiles(); void addListener(ChangedListListener listener); void removeListener(ChangedListListener listener); synchronized void clear(); synchronized ChangedFile reserve(); long getVersion(); long persist(File persistFile); synchronized void restore(File persistFile, List<File> contentDirs); synchronized List<File> peek(int maxFiles); void shutdown();  }
@Test public void testPeek() throws Exception { int fileCount = 100; List<File> files = new ArrayList<File>(fileCount); for (int i = 0; i < fileCount; i++) { File f = new File("changedListTest-" + i + ".tmp"); files.add(f); changedList.addChangedFile(f); } Assert.assertEquals(fileCount, changedList.getListSize()); List<File> peekedFiles = changedList.peek(fileCount - 1); for (int i = 0; i < peekedFiles.size(); i++) { Assert.assertEquals(files.get(i), peekedFiles.get(i)); } }