@Test public void testGetPersonNull() { Mockito.when(personManager.getPerson(req)).thenReturn(null); ModelAndView modelAndView = peopleRESTController.getPerson(USER_NAME, req, res); Assert.assertEquals(null, modelAndView); }
@RequestMapping(value = "/people/{username}.json", method = RequestMethod.GET) public ModelAndView getPerson( @PathVariable String username, HttpServletRequest request, HttpServletResponse response) { final IPerson searcher = personManager.getPerson((HttpServletRequest) request); if (searcher == null) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return null; } final IPersonAttributes person = lookupHelper.findPerson(searcher, username); final ModelAndView mv = new ModelAndView(); mv.addObject("person", person); mv.setViewName("json"); return mv; }
PeopleRESTController { @RequestMapping(value = "/people/{username}.json", method = RequestMethod.GET) public ModelAndView getPerson( @PathVariable String username, HttpServletRequest request, HttpServletResponse response) { final IPerson searcher = personManager.getPerson((HttpServletRequest) request); if (searcher == null) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return null; } final IPersonAttributes person = lookupHelper.findPerson(searcher, username); final ModelAndView mv = new ModelAndView(); mv.addObject("person", person); mv.setViewName("json"); return mv; } }
PeopleRESTController { @RequestMapping(value = "/people/{username}.json", method = RequestMethod.GET) public ModelAndView getPerson( @PathVariable String username, HttpServletRequest request, HttpServletResponse response) { final IPerson searcher = personManager.getPerson((HttpServletRequest) request); if (searcher == null) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return null; } final IPersonAttributes person = lookupHelper.findPerson(searcher, username); final ModelAndView mv = new ModelAndView(); mv.addObject("person", person); mv.setViewName("json"); return mv; }  }
PeopleRESTController { @RequestMapping(value = "/people/{username}.json", method = RequestMethod.GET) public ModelAndView getPerson( @PathVariable String username, HttpServletRequest request, HttpServletResponse response) { final IPerson searcher = personManager.getPerson((HttpServletRequest) request); if (searcher == null) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return null; } final IPersonAttributes person = lookupHelper.findPerson(searcher, username); final ModelAndView mv = new ModelAndView(); mv.addObject("person", person); mv.setViewName("json"); return mv; }  @Autowired void setPersonManager(IPersonManager personManager); @Autowired(required = true) void setPersonLookupHelper(PersonLookupHelperImpl lookupHelper); @RequestMapping(value = "/people.json", method = RequestMethod.GET) ModelAndView getPeople(
            @RequestParam("searchTerms[]") List<String> searchTerms,
            HttpServletRequest request,
            HttpServletResponse response); @RequestMapping(value = "/people/{username}.json", method = RequestMethod.GET) ModelAndView getPerson(
            @PathVariable String username,
            HttpServletRequest request,
            HttpServletResponse response); }
PeopleRESTController { @RequestMapping(value = "/people/{username}.json", method = RequestMethod.GET) public ModelAndView getPerson( @PathVariable String username, HttpServletRequest request, HttpServletResponse response) { final IPerson searcher = personManager.getPerson((HttpServletRequest) request); if (searcher == null) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return null; } final IPersonAttributes person = lookupHelper.findPerson(searcher, username); final ModelAndView mv = new ModelAndView(); mv.addObject("person", person); mv.setViewName("json"); return mv; }  @Autowired void setPersonManager(IPersonManager personManager); @Autowired(required = true) void setPersonLookupHelper(PersonLookupHelperImpl lookupHelper); @RequestMapping(value = "/people.json", method = RequestMethod.GET) ModelAndView getPeople(
            @RequestParam("searchTerms[]") List<String> searchTerms,
            HttpServletRequest request,
            HttpServletResponse response); @RequestMapping(value = "/people/{username}.json", method = RequestMethod.GET) ModelAndView getPerson(
            @PathVariable String username,
            HttpServletRequest request,
            HttpServletResponse response);  }