@Test public void testFindPagsGroup() throws JsonProcessingException { String groupName = "groupname"; IPerson person = new PersonImpl(); person.setUserName(USER_NAME); person.setFullName("john doe"); Mockito.when(personManager.getPerson(req)).thenReturn(person); IPersonAttributesGroupDefinition pagsGroup = new PersonAttributesGroupDefinitionImpl(groupName, "this is awesome"); Mockito.when(pagsService.getPagsDefinitionByName(person, groupName)).thenReturn(pagsGroup); pagsRESTController.findPagsGroup(req, res, "groupname"); Mockito.verify(mapper).writeValueAsString(pagsGroup); }
@RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET) public @ResponseBody String findPagsGroup( HttpServletRequest request, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName) { res.setContentType(MediaType.APPLICATION_JSON_VALUE); String name; try { name = URLDecoder.decode(pagsGroupName, "UTF-8"); } catch (UnsupportedEncodingException e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } IPerson person = personManager.getPerson(request); IPersonAttributesGroupDefinition pagsGroup = this.pagsService.getPagsDefinitionByName(person, name); return respondPagsGroupJson(res, pagsGroup, person, HttpServletResponse.SC_FOUND); }
PagsRESTController { @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET) public @ResponseBody String findPagsGroup( HttpServletRequest request, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName) { res.setContentType(MediaType.APPLICATION_JSON_VALUE); String name; try { name = URLDecoder.decode(pagsGroupName, "UTF-8"); } catch (UnsupportedEncodingException e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } IPerson person = personManager.getPerson(request); IPersonAttributesGroupDefinition pagsGroup = this.pagsService.getPagsDefinitionByName(person, name); return respondPagsGroupJson(res, pagsGroup, person, HttpServletResponse.SC_FOUND); } }
PagsRESTController { @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET) public @ResponseBody String findPagsGroup( HttpServletRequest request, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName) { res.setContentType(MediaType.APPLICATION_JSON_VALUE); String name; try { name = URLDecoder.decode(pagsGroupName, "UTF-8"); } catch (UnsupportedEncodingException e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } IPerson person = personManager.getPerson(request); IPersonAttributesGroupDefinition pagsGroup = this.pagsService.getPagsDefinitionByName(person, name); return respondPagsGroupJson(res, pagsGroup, person, HttpServletResponse.SC_FOUND); }  }
PagsRESTController { @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET) public @ResponseBody String findPagsGroup( HttpServletRequest request, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName) { res.setContentType(MediaType.APPLICATION_JSON_VALUE); String name; try { name = URLDecoder.decode(pagsGroupName, "UTF-8"); } catch (UnsupportedEncodingException e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } IPerson person = personManager.getPerson(request); IPersonAttributesGroupDefinition pagsGroup = this.pagsService.getPagsDefinitionByName(person, name); return respondPagsGroupJson(res, pagsGroup, person, HttpServletResponse.SC_FOUND); }  @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET) @ResponseBody String findPagsGroup(
            HttpServletRequest request,
            HttpServletResponse res,
            @PathVariable("pagsGroupName") String pagsGroupName); @RequestMapping( value = "/v4-3/pags/{parentGroupName}.json", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @ResponseBody String createPagsGroup(
            HttpServletRequest request,
            HttpServletResponse res,
            @PathVariable("parentGroupName") String parentGroupName,
            @RequestBody String json); @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) @ResponseBody String updatePagsGroup(
            HttpServletRequest req,
            HttpServletResponse res,
            @PathVariable("pagsGroupName") String pagsGroupName,
            @RequestBody String json); }
PagsRESTController { @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET) public @ResponseBody String findPagsGroup( HttpServletRequest request, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName) { res.setContentType(MediaType.APPLICATION_JSON_VALUE); String name; try { name = URLDecoder.decode(pagsGroupName, "UTF-8"); } catch (UnsupportedEncodingException e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } IPerson person = personManager.getPerson(request); IPersonAttributesGroupDefinition pagsGroup = this.pagsService.getPagsDefinitionByName(person, name); return respondPagsGroupJson(res, pagsGroup, person, HttpServletResponse.SC_FOUND); }  @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET) @ResponseBody String findPagsGroup(
            HttpServletRequest request,
            HttpServletResponse res,
            @PathVariable("pagsGroupName") String pagsGroupName); @RequestMapping( value = "/v4-3/pags/{parentGroupName}.json", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @ResponseBody String createPagsGroup(
            HttpServletRequest request,
            HttpServletResponse res,
            @PathVariable("parentGroupName") String parentGroupName,
            @RequestBody String json); @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) @ResponseBody String updatePagsGroup(
            HttpServletRequest req,
            HttpServletResponse res,
            @PathVariable("pagsGroupName") String pagsGroupName,
            @RequestBody String json);  }