ImportFileScanner { public static List<FileSet> getFileSets(List<File> files) { TreeMap<String, FileSet> items = new TreeMap<String, FileSet>(createCzechCollator()); for (File file : files) { String filename = getName(file); filename = repairFilename(filename); FileSet itemFiles = items.get(filename); if (itemFiles == null) { itemFiles = new FileSet(filename); items.put(filename, itemFiles); } itemFiles.getFiles().add(new FileEntry(file)); } return new ArrayList<FileSet>(items.values()); }  List<Folder> findSubfolders(File folder, ImportHandler importer); List<File> findDigitalContent(File folder); static List<FileSet> getFileSets(List<File> files); static final String IMPORT_STATE_FILENAME; }
@Test public void testGetFileSets() throws Exception { File f2 = tmpFolder.newFile("f2.ext"); File f1ext1 = tmpFolder.newFile("f1.ds.ext1"); File f1ext2 = tmpFolder.newFile("f1.ext2"); ImportFileScanner instance = new ImportFileScanner(); List<File> files = instance.findDigitalContent(tmpFolder.getRoot()); assertEquals(3, files.size()); List<FileSet> fileSets = ImportFileScanner.getFileSets(files); assertNotNull(fileSets); assertEquals(2, fileSets.size()); FileSet fs1 = fileSets.get(0); assertEquals("f1", fs1.getName()); assertArrayEquals(new Object[] {f1ext1, f1ext2}, asFiles(fs1.getFiles())); FileSet fs2 = fileSets.get(1); assertEquals("f2", fs2.getName()); assertArrayEquals(new Object[] {f2}, asFiles(fs2.getFiles())); }