@Test public void testNegativeCase3() throws IOException { thrown.expect(NullPointerException.class); apController.removePDPGroup(null, null); }
@SuppressWarnings("unchecked") @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException { try { response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); PolicyController controller = getPolicyControllerInstance(); this.container = new PDPGroupContainer(controller.getPapEngine()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); final StdPDPGroup group = mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class); final JsonNode removePolicyData = root.get("data"); String userId = UserUtils.getUserSession(request).getOrgUserId(); logger.info( "**********************Logging UserID while Removing Policy from PDP Group*********************"); logger.info("UserId: " + userId + "PDP Group Data: " + root.get("activePdpGroup").toString() + "Remove Policy Data: " + root.get("data")); logger.info( "**********************************************************************************************"); policyContainer = new PdpPolicyContainer(group); if (removePolicyData.size() > 0) { IntStream.range(0, removePolicyData.size()).mapToObj(i -> removePolicyData.get(i).toString()) .forEach(polData -> this.policyContainer.removeItem(polData)); Set<PDPPolicy> changedPolicies = new HashSet<>((Collection<PDPPolicy>) this.policyContainer.getItemIds()); StdPDPGroup updatedGroupObject = new StdPDPGroup(group.getId(), group.isDefaultGroup(), group.getName(), group.getDescription(), null); updatedGroupObject.setPolicies(changedPolicies); updatedGroupObject.setOnapPdps(group.getOnapPdps()); updatedGroupObject.setPipConfigs(group.getPipConfigs()); updatedGroupObject.setStatus(group.getStatus()); updatedGroupObject.setOperation("delete"); this.container.updateGroup(updatedGroupObject, userId); } response.setContentType(PolicyUtils.APPLICATION_JSON); refreshGroups(); response.getWriter().write(new JSONObject(new JsonMessage(mapper.writeValueAsString(groups))).toString()); } catch (Exception e) { logger.error(e); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); } return null; }
AutoPushController extends RestrictedBaseController { @SuppressWarnings("unchecked") @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException { try { response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); PolicyController controller = getPolicyControllerInstance(); this.container = new PDPGroupContainer(controller.getPapEngine()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); final StdPDPGroup group = mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class); final JsonNode removePolicyData = root.get("data"); String userId = UserUtils.getUserSession(request).getOrgUserId(); logger.info( "**********************Logging UserID while Removing Policy from PDP Group*********************"); logger.info("UserId: " + userId + "PDP Group Data: " + root.get("activePdpGroup").toString() + "Remove Policy Data: " + root.get("data")); logger.info( "**********************************************************************************************"); policyContainer = new PdpPolicyContainer(group); if (removePolicyData.size() > 0) { IntStream.range(0, removePolicyData.size()).mapToObj(i -> removePolicyData.get(i).toString()) .forEach(polData -> this.policyContainer.removeItem(polData)); Set<PDPPolicy> changedPolicies = new HashSet<>((Collection<PDPPolicy>) this.policyContainer.getItemIds()); StdPDPGroup updatedGroupObject = new StdPDPGroup(group.getId(), group.isDefaultGroup(), group.getName(), group.getDescription(), null); updatedGroupObject.setPolicies(changedPolicies); updatedGroupObject.setOnapPdps(group.getOnapPdps()); updatedGroupObject.setPipConfigs(group.getPipConfigs()); updatedGroupObject.setStatus(group.getStatus()); updatedGroupObject.setOperation("delete"); this.container.updateGroup(updatedGroupObject, userId); } response.setContentType(PolicyUtils.APPLICATION_JSON); refreshGroups(); response.getWriter().write(new JSONObject(new JsonMessage(mapper.writeValueAsString(groups))).toString()); } catch (Exception e) { logger.error(e); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); } return null; } }
AutoPushController extends RestrictedBaseController { @SuppressWarnings("unchecked") @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException { try { response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); PolicyController controller = getPolicyControllerInstance(); this.container = new PDPGroupContainer(controller.getPapEngine()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); final StdPDPGroup group = mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class); final JsonNode removePolicyData = root.get("data"); String userId = UserUtils.getUserSession(request).getOrgUserId(); logger.info( "**********************Logging UserID while Removing Policy from PDP Group*********************"); logger.info("UserId: " + userId + "PDP Group Data: " + root.get("activePdpGroup").toString() + "Remove Policy Data: " + root.get("data")); logger.info( "**********************************************************************************************"); policyContainer = new PdpPolicyContainer(group); if (removePolicyData.size() > 0) { IntStream.range(0, removePolicyData.size()).mapToObj(i -> removePolicyData.get(i).toString()) .forEach(polData -> this.policyContainer.removeItem(polData)); Set<PDPPolicy> changedPolicies = new HashSet<>((Collection<PDPPolicy>) this.policyContainer.getItemIds()); StdPDPGroup updatedGroupObject = new StdPDPGroup(group.getId(), group.isDefaultGroup(), group.getName(), group.getDescription(), null); updatedGroupObject.setPolicies(changedPolicies); updatedGroupObject.setOnapPdps(group.getOnapPdps()); updatedGroupObject.setPipConfigs(group.getPipConfigs()); updatedGroupObject.setStatus(group.getStatus()); updatedGroupObject.setOperation("delete"); this.container.updateGroup(updatedGroupObject, userId); } response.setContentType(PolicyUtils.APPLICATION_JSON); refreshGroups(); response.getWriter().write(new JSONObject(new JsonMessage(mapper.writeValueAsString(groups))).toString()); } catch (Exception e) { logger.error(e); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); } return null; }  }
AutoPushController extends RestrictedBaseController { @SuppressWarnings("unchecked") @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException { try { response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); PolicyController controller = getPolicyControllerInstance(); this.container = new PDPGroupContainer(controller.getPapEngine()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); final StdPDPGroup group = mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class); final JsonNode removePolicyData = root.get("data"); String userId = UserUtils.getUserSession(request).getOrgUserId(); logger.info( "**********************Logging UserID while Removing Policy from PDP Group*********************"); logger.info("UserId: " + userId + "PDP Group Data: " + root.get("activePdpGroup").toString() + "Remove Policy Data: " + root.get("data")); logger.info( "**********************************************************************************************"); policyContainer = new PdpPolicyContainer(group); if (removePolicyData.size() > 0) { IntStream.range(0, removePolicyData.size()).mapToObj(i -> removePolicyData.get(i).toString()) .forEach(polData -> this.policyContainer.removeItem(polData)); Set<PDPPolicy> changedPolicies = new HashSet<>((Collection<PDPPolicy>) this.policyContainer.getItemIds()); StdPDPGroup updatedGroupObject = new StdPDPGroup(group.getId(), group.isDefaultGroup(), group.getName(), group.getDescription(), null); updatedGroupObject.setPolicies(changedPolicies); updatedGroupObject.setOnapPdps(group.getOnapPdps()); updatedGroupObject.setPipConfigs(group.getPipConfigs()); updatedGroupObject.setStatus(group.getStatus()); updatedGroupObject.setOperation("delete"); this.container.updateGroup(updatedGroupObject, userId); } response.setContentType(PolicyUtils.APPLICATION_JSON); refreshGroups(); response.getWriter().write(new JSONObject(new JsonMessage(mapper.writeValueAsString(groups))).toString()); } catch (Exception e) { logger.error(e); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); } return null; }  PolicyController getPolicyController(); void setPolicyController(PolicyController policyController); synchronized void refreshGroups(); @RequestMapping( value = {"/get_AutoPushPoliciesContainerData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getPolicyGroupContainerData(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/auto_Push/PushPolicyToPDP.htm"}, method = {RequestMethod.POST}) ModelAndView pushPolicyToPDPGroup(HttpServletRequest request, HttpServletResponse response); @SuppressWarnings("unchecked") @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response); }
AutoPushController extends RestrictedBaseController { @SuppressWarnings("unchecked") @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException { try { response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); PolicyController controller = getPolicyControllerInstance(); this.container = new PDPGroupContainer(controller.getPapEngine()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); final StdPDPGroup group = mapper.readValue(root.get("activePdpGroup").toString(), StdPDPGroup.class); final JsonNode removePolicyData = root.get("data"); String userId = UserUtils.getUserSession(request).getOrgUserId(); logger.info( "**********************Logging UserID while Removing Policy from PDP Group*********************"); logger.info("UserId: " + userId + "PDP Group Data: " + root.get("activePdpGroup").toString() + "Remove Policy Data: " + root.get("data")); logger.info( "**********************************************************************************************"); policyContainer = new PdpPolicyContainer(group); if (removePolicyData.size() > 0) { IntStream.range(0, removePolicyData.size()).mapToObj(i -> removePolicyData.get(i).toString()) .forEach(polData -> this.policyContainer.removeItem(polData)); Set<PDPPolicy> changedPolicies = new HashSet<>((Collection<PDPPolicy>) this.policyContainer.getItemIds()); StdPDPGroup updatedGroupObject = new StdPDPGroup(group.getId(), group.isDefaultGroup(), group.getName(), group.getDescription(), null); updatedGroupObject.setPolicies(changedPolicies); updatedGroupObject.setOnapPdps(group.getOnapPdps()); updatedGroupObject.setPipConfigs(group.getPipConfigs()); updatedGroupObject.setStatus(group.getStatus()); updatedGroupObject.setOperation("delete"); this.container.updateGroup(updatedGroupObject, userId); } response.setContentType(PolicyUtils.APPLICATION_JSON); refreshGroups(); response.getWriter().write(new JSONObject(new JsonMessage(mapper.writeValueAsString(groups))).toString()); } catch (Exception e) { logger.error(e); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); } return null; }  PolicyController getPolicyController(); void setPolicyController(PolicyController policyController); synchronized void refreshGroups(); @RequestMapping( value = {"/get_AutoPushPoliciesContainerData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getPolicyGroupContainerData(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/auto_Push/PushPolicyToPDP.htm"}, method = {RequestMethod.POST}) ModelAndView pushPolicyToPDPGroup(HttpServletRequest request, HttpServletResponse response); @SuppressWarnings("unchecked") @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response);  }