PageTreeController { @RequestMapping(value="/project/{name:" + DocumentrConstants.PROJECT_NAME_PATTERN + "}/json", method=RequestMethod.POST, produces="application/json") @ResponseBody @PreAuthorize("permitAll") public List<BranchTreeNode> getProjectChildren(@PathVariable String name, Authentication authentication) throws IOException { return nodesProvider.getProjectChildren(name, 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 getProjectChildren() throws IOException { when(repoManager.listProjectBranches("project")).thenReturn( Lists.newArrayList("branch1", "branch2", "inaccessible")); when(permissionEvaluator.hasAnyBranchPermission(authentication, "project", Permission.VIEW)).thenReturn(true); when(permissionEvaluator.hasBranchPermission( same(authentication), eq("project"), notEq("inaccessible"), same(Permission.VIEW))) .thenReturn(true); when(permissionEvaluator.hasBranchPermission( same(authentication), eq("project"), eq("inaccessible"), same(Permission.VIEW))) .thenReturn(false); List<BranchTreeNode> result = pageTreeController.getProjectChildren("project", authentication); Function<BranchTreeNode, String> function = new Function<BranchTreeNode, String>() { @Override public String apply(BranchTreeNode node) { return node.getProjectName() + "/" + node.getName(); } }; Set<String> branches = Sets.newHashSet(Lists.transform(result, function)); assertEquals(Sets.newHashSet("project/branch1", "project/branch2"), branches); }