@Test public void testGetPrincipalsGroup() throws Exception { String query = "test"; Set<JsonEntityBean> beans = new HashSet<JsonEntityBean>(); beans.add(buildJsonGroupEntityBean()); Mockito.when(groupListHelper.search(EntityEnum.GROUP.toString(), "test")).thenReturn(beans); Mockito.when(groupListHelper.search(EntityEnum.PERSON.toString(), "test")) .thenReturn(Collections.emptySet()); ModelAndView modelAndView = principalsRESTController.getPrincipals(query, req, res); List<JsonEntityBean> returnPersonEntities = (List<JsonEntityBean>) modelAndView.getModel().get("people"); List<JsonEntityBean> returnGroupEntities = (List<JsonEntityBean>) modelAndView.getModel().get("groups"); Assert.assertTrue(returnPersonEntities.isEmpty()); Assert.assertFalse(returnGroupEntities.isEmpty()); }
@PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/principals.json", method = RequestMethod.GET) public ModelAndView getPrincipals( @RequestParam(value = "q") String query, HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mv = new ModelAndView(); List<JsonEntityBean> groups = new ArrayList<JsonEntityBean>(); groups.addAll(listHelper.search(EntityEnum.GROUP.toString(), query)); Collections.sort(groups); mv.addObject("groups", groups); List<JsonEntityBean> people = new ArrayList<JsonEntityBean>(); people.addAll(listHelper.search(EntityEnum.PERSON.toString(), query)); Collections.sort(people); mv.addObject("people", people); mv.setViewName("json"); return mv; }
PrincipalsRESTController { @PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/principals.json", method = RequestMethod.GET) public ModelAndView getPrincipals( @RequestParam(value = "q") String query, HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mv = new ModelAndView(); List<JsonEntityBean> groups = new ArrayList<JsonEntityBean>(); groups.addAll(listHelper.search(EntityEnum.GROUP.toString(), query)); Collections.sort(groups); mv.addObject("groups", groups); List<JsonEntityBean> people = new ArrayList<JsonEntityBean>(); people.addAll(listHelper.search(EntityEnum.PERSON.toString(), query)); Collections.sort(people); mv.addObject("people", people); mv.setViewName("json"); return mv; } }
PrincipalsRESTController { @PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/principals.json", method = RequestMethod.GET) public ModelAndView getPrincipals( @RequestParam(value = "q") String query, HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mv = new ModelAndView(); List<JsonEntityBean> groups = new ArrayList<JsonEntityBean>(); groups.addAll(listHelper.search(EntityEnum.GROUP.toString(), query)); Collections.sort(groups); mv.addObject("groups", groups); List<JsonEntityBean> people = new ArrayList<JsonEntityBean>(); people.addAll(listHelper.search(EntityEnum.PERSON.toString(), query)); Collections.sort(people); mv.addObject("people", people); mv.setViewName("json"); return mv; }  }
PrincipalsRESTController { @PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/principals.json", method = RequestMethod.GET) public ModelAndView getPrincipals( @RequestParam(value = "q") String query, HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mv = new ModelAndView(); List<JsonEntityBean> groups = new ArrayList<JsonEntityBean>(); groups.addAll(listHelper.search(EntityEnum.GROUP.toString(), query)); Collections.sort(groups); mv.addObject("groups", groups); List<JsonEntityBean> people = new ArrayList<JsonEntityBean>(); people.addAll(listHelper.search(EntityEnum.PERSON.toString(), query)); Collections.sort(people); mv.addObject("people", people); mv.setViewName("json"); return mv; }  @Autowired(required = true) void setGroupListHelper(IGroupListHelper groupListHelper); @PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/principals.json", method = RequestMethod.GET) ModelAndView getPrincipals(
            @RequestParam(value = "q") String query,
            HttpServletRequest request,
            HttpServletResponse response); }
PrincipalsRESTController { @PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/principals.json", method = RequestMethod.GET) public ModelAndView getPrincipals( @RequestParam(value = "q") String query, HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mv = new ModelAndView(); List<JsonEntityBean> groups = new ArrayList<JsonEntityBean>(); groups.addAll(listHelper.search(EntityEnum.GROUP.toString(), query)); Collections.sort(groups); mv.addObject("groups", groups); List<JsonEntityBean> people = new ArrayList<JsonEntityBean>(); people.addAll(listHelper.search(EntityEnum.PERSON.toString(), query)); Collections.sort(people); mv.addObject("people", people); mv.setViewName("json"); return mv; }  @Autowired(required = true) void setGroupListHelper(IGroupListHelper groupListHelper); @PreAuthorize( "hasPermission('ALL', 'java.lang.String', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/principals.json", method = RequestMethod.GET) ModelAndView getPrincipals(
            @RequestParam(value = "q") String query,
            HttpServletRequest request,
            HttpServletResponse response);  }