UtilHandler { @POST @Path("/getChildFolders") @Produces(APPLICATION_JSON) public Collection<Folder> getChildFolders(@FormParam("path") final String parentPath) { Collection<Folder> folders = new ArrayList<>(); if (parentPath == null || "none".equals(parentPath)) { File userHomeDir = new File(USER_HOME.getValue()); folders.add(new Folder(userHomeDir.getName(), userHomeDir.getAbsolutePath())); FileSystems.getDefault().getRootDirectories() .forEach(root -> folders.add(new Folder(root.toString(), root.toString()))); } else { folders.addAll(listChildren(parentPath, false).stream() .map(child -> new Folder(child.getName(), child.getAbsolutePath())) .collect(toList())); } return folders; } @Inject  UtilHandler(final VersionManager versionManager); @GET @Path("/getVersion") @Produces(TEXT_PLAIN) String getVersion(); @GET @Path("/getReleaseInfo") @Produces(APPLICATION_JSON) ReleaseInfo getReleaseInfo(); @POST @Path("/getChildFolders") @Produces(APPLICATION_JSON) Collection<Folder> getChildFolders(@FormParam("path") final String parentPath);  }
@Test public void testGetChildFolders() { VersionManager versionManager = createMock(VersionManager.class); replay(versionManager); UtilHandler utilHandler = new UtilHandler(versionManager); Collection<UtilHandler.Folder> folders = utilHandler.getChildFolders("/"); assertNotNull(folders); verify(versionManager); }
@Test public void testGetChildFoldersNull() { VersionManager versionManager = createMock(VersionManager.class); replay(versionManager); UtilHandler utilHandler = new UtilHandler(versionManager); Collection<UtilHandler.Folder> folders = utilHandler.getChildFolders(null); assertNotNull(folders); verify(versionManager); }
@Test public void testGetChildFoldersNone() { VersionManager versionManager = createMock(VersionManager.class); replay(versionManager); UtilHandler utilHandler = new UtilHandler(versionManager); Collection<UtilHandler.Folder> folders = utilHandler.getChildFolders("none"); assertNotNull(folders); verify(versionManager); }