@Test public void testUpdateGroup404() throws JsonProcessingException { String response = pagsRESTController.updatePagsGroup(req, res, "groupName", null); String expectedResponse = "{ 'error': 'Not found' }"; Assert.assertEquals(expectedResponse, response); org.junit.Assert.assertEquals(404, res.getStatus()); }
@RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) public @ResponseBody String updatePagsGroup( HttpServletRequest req, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName, @RequestBody String json) { 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() + "' }"; } IPersonAttributesGroupDefinition inpt; try { inpt = objectMapper.readValue(json, PersonAttributesGroupDefinitionImpl.class); } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } if (inpt == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } if (!name.equals(inpt.getName())) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': 'Group name in URL parameter must match name in JSON payload' }"; } IPerson person = personManager.getPerson(req); IPersonAttributesGroupDefinition rslt; try { IPersonAttributesGroupDefinition currentDef = pagsService.getPagsDefinitionByName(person, name); if (currentDef == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } currentDef.setDescription(inpt.getDescription()); for (IPersonAttributesGroupTestGroupDefinition testGroupDef : inpt.getTestGroups()) { testGroupDef.setGroup(currentDef); } currentDef.setTestGroups(inpt.getTestGroups()); rslt = pagsService.updatePagsDefinition(person, currentDef); } catch (IllegalArgumentException iae) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': '" + iae.getMessage() + "' }"; } catch (RuntimeAuthorizationException rae) { res.setStatus(HttpServletResponse.SC_FORBIDDEN); return "{ 'error': 'not authorized' }"; } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } return respondPagsGroupJson(res, rslt, person, HttpServletResponse.SC_ACCEPTED); }
PagsRESTController { @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) public @ResponseBody String updatePagsGroup( HttpServletRequest req, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName, @RequestBody String json) { 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() + "' }"; } IPersonAttributesGroupDefinition inpt; try { inpt = objectMapper.readValue(json, PersonAttributesGroupDefinitionImpl.class); } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } if (inpt == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } if (!name.equals(inpt.getName())) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': 'Group name in URL parameter must match name in JSON payload' }"; } IPerson person = personManager.getPerson(req); IPersonAttributesGroupDefinition rslt; try { IPersonAttributesGroupDefinition currentDef = pagsService.getPagsDefinitionByName(person, name); if (currentDef == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } currentDef.setDescription(inpt.getDescription()); for (IPersonAttributesGroupTestGroupDefinition testGroupDef : inpt.getTestGroups()) { testGroupDef.setGroup(currentDef); } currentDef.setTestGroups(inpt.getTestGroups()); rslt = pagsService.updatePagsDefinition(person, currentDef); } catch (IllegalArgumentException iae) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': '" + iae.getMessage() + "' }"; } catch (RuntimeAuthorizationException rae) { res.setStatus(HttpServletResponse.SC_FORBIDDEN); return "{ 'error': 'not authorized' }"; } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } return respondPagsGroupJson(res, rslt, person, HttpServletResponse.SC_ACCEPTED); } }
PagsRESTController { @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) public @ResponseBody String updatePagsGroup( HttpServletRequest req, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName, @RequestBody String json) { 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() + "' }"; } IPersonAttributesGroupDefinition inpt; try { inpt = objectMapper.readValue(json, PersonAttributesGroupDefinitionImpl.class); } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } if (inpt == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } if (!name.equals(inpt.getName())) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': 'Group name in URL parameter must match name in JSON payload' }"; } IPerson person = personManager.getPerson(req); IPersonAttributesGroupDefinition rslt; try { IPersonAttributesGroupDefinition currentDef = pagsService.getPagsDefinitionByName(person, name); if (currentDef == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } currentDef.setDescription(inpt.getDescription()); for (IPersonAttributesGroupTestGroupDefinition testGroupDef : inpt.getTestGroups()) { testGroupDef.setGroup(currentDef); } currentDef.setTestGroups(inpt.getTestGroups()); rslt = pagsService.updatePagsDefinition(person, currentDef); } catch (IllegalArgumentException iae) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': '" + iae.getMessage() + "' }"; } catch (RuntimeAuthorizationException rae) { res.setStatus(HttpServletResponse.SC_FORBIDDEN); return "{ 'error': 'not authorized' }"; } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } return respondPagsGroupJson(res, rslt, person, HttpServletResponse.SC_ACCEPTED); }  }
PagsRESTController { @RequestMapping( value = "/v4-3/pags/{pagsGroupName}.json", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) public @ResponseBody String updatePagsGroup( HttpServletRequest req, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName, @RequestBody String json) { 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() + "' }"; } IPersonAttributesGroupDefinition inpt; try { inpt = objectMapper.readValue(json, PersonAttributesGroupDefinitionImpl.class); } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } if (inpt == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } if (!name.equals(inpt.getName())) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': 'Group name in URL parameter must match name in JSON payload' }"; } IPerson person = personManager.getPerson(req); IPersonAttributesGroupDefinition rslt; try { IPersonAttributesGroupDefinition currentDef = pagsService.getPagsDefinitionByName(person, name); if (currentDef == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } currentDef.setDescription(inpt.getDescription()); for (IPersonAttributesGroupTestGroupDefinition testGroupDef : inpt.getTestGroups()) { testGroupDef.setGroup(currentDef); } currentDef.setTestGroups(inpt.getTestGroups()); rslt = pagsService.updatePagsDefinition(person, currentDef); } catch (IllegalArgumentException iae) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': '" + iae.getMessage() + "' }"; } catch (RuntimeAuthorizationException rae) { res.setStatus(HttpServletResponse.SC_FORBIDDEN); return "{ 'error': 'not authorized' }"; } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } return respondPagsGroupJson(res, rslt, person, HttpServletResponse.SC_ACCEPTED); }  @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.PUT) public @ResponseBody String updatePagsGroup( HttpServletRequest req, HttpServletResponse res, @PathVariable("pagsGroupName") String pagsGroupName, @RequestBody String json) { 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() + "' }"; } IPersonAttributesGroupDefinition inpt; try { inpt = objectMapper.readValue(json, PersonAttributesGroupDefinitionImpl.class); } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } if (inpt == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } if (!name.equals(inpt.getName())) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': 'Group name in URL parameter must match name in JSON payload' }"; } IPerson person = personManager.getPerson(req); IPersonAttributesGroupDefinition rslt; try { IPersonAttributesGroupDefinition currentDef = pagsService.getPagsDefinitionByName(person, name); if (currentDef == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': 'Not found' }"; } currentDef.setDescription(inpt.getDescription()); for (IPersonAttributesGroupTestGroupDefinition testGroupDef : inpt.getTestGroups()) { testGroupDef.setGroup(currentDef); } currentDef.setTestGroups(inpt.getTestGroups()); rslt = pagsService.updatePagsDefinition(person, currentDef); } catch (IllegalArgumentException iae) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); return "{ 'error': '" + iae.getMessage() + "' }"; } catch (RuntimeAuthorizationException rae) { res.setStatus(HttpServletResponse.SC_FORBIDDEN); return "{ 'error': 'not authorized' }"; } catch (Exception e) { res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return "{ 'error': '" + e.toString() + "' }"; } return respondPagsGroupJson(res, rslt, person, HttpServletResponse.SC_ACCEPTED); }  @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);  }