FolderLoaderUtils { public static <E extends Folderable> void createFolders(Bundle bundle, File rootDir, Map<String, E> folderableMap) { final File policyRootDir = getPolicyRootDir(rootDir); if (policyRootDir == null) return; final Map<String, Folder> folderMap = bundle.getFolders(); final Folder rootFolder = folderMap.computeIfAbsent( getPath(policyRootDir, policyRootDir), key -> createFolder(policyRootDir.getName(), key, null) ); folderableMap.forEach((folderablePath, folderable) -> { final String pathExcludingService = FilenameUtils.getFullPath(folderablePath); if (isEmpty(pathExcludingService)) { folderable.setParentFolder(rootFolder); } else { createFoldersAlongPath(pathExcludingService, folderMap, rootFolder); folderable.setParentFolder(folderMap.get(pathExcludingService)); } }); } private  FolderLoaderUtils(); static void createFolders(Bundle bundle, File rootDir, Map<String, E> folderableMap); static final String SOAP_RESOURCES_FOLDER; }
@Test void createFoldersTest() { String path = "a/b/c/"; Folder root = createFolder("root", "", null); Map<String, Folder> folderMap = new HashedMap<>(); createFoldersAlongPath(path, folderMap, root); assertEquals(3, folderMap.size()); verifyFolder("a/", root, folderMap); verifyFolder("a/b/", folderMap.get("a/"), folderMap); verifyFolder("a/b/c/", folderMap.get("a/b/"), folderMap); }