PageTreeController { @RequestMapping(value="/application/json", method=RequestMethod.POST) @ResponseBody @PreAuthorize("permitAll") public List<ProjectTreeNode> getApplicationChildren(Authentication authentication) throws IOException { return nodesProvider.getApplicationChildren(getAuthentication(authentication)); }  @RequestMapping(value="/application/json", method=RequestMethod.POST) @ResponseBody @PreAuthorize("permitAll") List<ProjectTreeNode> getApplicationChildren(Authentication authentication); @RequestMapping(value="/project/{name:" + DocumentrConstants.PROJECT_NAME_PATTERN + "}/json", method=RequestMethod.POST, produces="application/json") @ResponseBody @PreAuthorize("permitAll") List<BranchTreeNode> getProjectChildren(@PathVariable String name, Authentication authentication); @RequestMapping(value="/branch/{projectName:" + DocumentrConstants.PROJECT_NAME_PATTERN + "}/" + "{name:" + DocumentrConstants.BRANCH_NAME_PATTERN + "}/json", method=RequestMethod.POST, produces="application/json") @ResponseBody @PreAuthorize("permitAll") List<PageTreeNode> getBranchChildren(@PathVariable String projectName, @PathVariable String name,
			@RequestParam(required=false) Set<String> checkBranchPermissions, Authentication authentication); @RequestMapping(value="/page/{projectName:" + DocumentrConstants.PROJECT_NAME_PATTERN + "}/" + "{branchName:" + DocumentrConstants.BRANCH_NAME_PATTERN + "}/" + "{path:" + DocumentrConstants.PAGE_PATH_URL_PATTERN + "}/json", method=RequestMethod.POST, produces="application/json") @ResponseBody @PreAuthorize("permitAll") List<AbstractTreeNode> getPageChildren(@PathVariable String projectName, @PathVariable String branchName,
			@PathVariable String path, @RequestParam(required=false) Set<String> checkBranchPermissions,
			@RequestParam(required=false) boolean pages, @RequestParam(required=false) boolean attachments,
			Authentication authentication);  }
@Test public void getApplicationChildren() throws IOException { when(repoManager.listProjects()).thenReturn( Lists.newArrayList("project1", "project2", "inaccessible")); when(permissionEvaluator.hasAnyProjectPermission(authentication, Permission.VIEW)).thenReturn(true); when(permissionEvaluator.hasProjectPermission( same(authentication), notEq("inaccessible"), same(Permission.VIEW))) .thenReturn(true); when(permissionEvaluator.hasProjectPermission( same(authentication), eq("inaccessible"), same(Permission.VIEW))) .thenReturn(false); List<ProjectTreeNode> result = pageTreeController.getApplicationChildren(authentication); Function<ProjectTreeNode, String> function = new Function<ProjectTreeNode, String>() { @Override public String apply(ProjectTreeNode node) { return node.getName(); } }; Set<String> projects = Sets.newHashSet(Lists.transform(result, function)); assertEquals(Sets.newHashSet("project1", "project2"), projects); }