FirewallDictionaryController { @RequestMapping(value = {"/fw_dictionary/save_prefixList"}, method = {RequestMethod.POST}) public ModelAndView savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); try { boolean fromAPI = utils.isRequestFromAPI(request); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); PrefixList prefixList; if (fromAPI) { prefixList = mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class); } else { prefixList = mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class); } List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class); boolean duplicateflag = false; if (!duplicateData.isEmpty()) { PrefixList data = (PrefixList) duplicateData.get(0); if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { prefixList.setId(data.getId()); } else if ((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || (request.getParameter(operation) == null && (data.getId() != prefixList.getId()))) { duplicateflag = true; } } String responseString = null; if (!duplicateflag) { if (prefixList.getId() == 0) { commonClassDao.save(prefixList); } else { commonClassDao.update(prefixList); } responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class)); } else { responseString = duplicateResponseString; } if (fromAPI) { return utils.getResultForApi(responseString); } else { utils.setResponseData(response, pfListDatas, responseString); } } catch (Exception e) { utils.setErrorResponseData(response, e); } return null; } @Autowired  FirewallDictionaryController(CommonClassDao commonClassDao);  FirewallDictionaryController(); static void setCommonClassDao(CommonClassDao clDao); @RequestMapping( value = {"/get_PrefixListDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getPrefixListDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping( value = {"/get_PrefixListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getPrefixListDictionaryEntityData(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_prefixList"}, method = {RequestMethod.POST}) ModelAndView savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_PrefixList"}, method = {RequestMethod.POST}) void removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/validate_prefixList"}, method = {RequestMethod.POST}) void validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_PortListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getPortListDictionaryEntityData(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_portName"}, method = {RequestMethod.POST}) ModelAndView savePortListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_PortList"}, method = {RequestMethod.POST}) void removePortListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_ProtocolListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getProtocolListDictionaryEntityData(HttpServletResponse response); @RequestMapping( value = {"/get_ProtocolListDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getProtocolListDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_protocolList"}, method = {RequestMethod.POST}) ModelAndView saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_protocol"}, method = {RequestMethod.POST}) void removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_AddressGroupDictionaryDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getAddressGroupDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping( value = {"/get_AddressGroupData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getAddressGroupDictionaryEntityData(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_addressGroup"}, method = {RequestMethod.POST}) ModelAndView saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_AddressGroup"}, method = {RequestMethod.POST}) void removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_ActionListDictionaryDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getActionListDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping( value = {"/get_ActionListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getActionListDictionaryEntityData(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_ActionList"}, method = {RequestMethod.POST}) ModelAndView saveActionListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_ActionList"}, method = {RequestMethod.POST}) void removeActionListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_ServiceGroupData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getServiceGroupDictionaryEntityData(HttpServletResponse response); @RequestMapping( value = {"/get_ServiceGroupDictionaryDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getServiceGroupDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_serviceGroup"}, method = {RequestMethod.POST}) ModelAndView saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_serviceGroup"}, method = {RequestMethod.POST}) void removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_SecurityZoneDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getSecurityZoneDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping( value = {"/get_SecurityZoneData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getSecurityZoneDictionaryEntityData(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_securityZone"}, method = {RequestMethod.POST}) ModelAndView saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_securityZone"}, method = {RequestMethod.POST}) void removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_ServiceListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getServiceListDictionaryEntityData(HttpServletResponse response); @RequestMapping( value = {"/get_ServiceListDictionaryDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getServiceListDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_serviceList"}, method = {RequestMethod.POST}) ModelAndView saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_serviceList"}, method = {RequestMethod.POST}) void removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_ZoneData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getZoneDictionaryEntityData(HttpServletResponse response); @RequestMapping( value = {"/get_ZoneDictionaryDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getZoneDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_zoneName"}, method = {RequestMethod.POST}) ModelAndView saveZoneDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_zone"}, method = {RequestMethod.POST}) void removeZoneDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_TermListDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getTermListDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping( value = {"/get_TermListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getTermListDictionaryEntityData(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_termList"}, method = {RequestMethod.POST}) ModelAndView saveTermListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_termList"}, method = {RequestMethod.POST}) void removeTermListDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_FWDictionaryListDataByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getFWDictListDictionaryEntityDataByName(HttpServletResponse response); @RequestMapping( value = {"/get_FWDictionaryListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getFWDictionaryListEntityData(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_FWDictionaryList"}, method = {RequestMethod.POST}) ModelAndView saveFWDictionaryList(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_FWDictionaryList"}, method = {RequestMethod.POST}) void removeFWDictionaryList(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_TagPickerNameByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getTagPickerNameEntityDataByName(HttpServletResponse response); @RequestMapping( value = {"/get_TagPickerListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getTagPickerDictionaryEntityData(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_fwTagPicker"}, method = {RequestMethod.POST}) ModelAndView saveFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_tagPicker"}, method = {RequestMethod.POST}) void removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_TagListData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getTagDictionaryEntityData(HttpServletResponse response); @RequestMapping( value = {"/get_TagNameByName"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getTagNameEntityDataByName(HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/save_fwTag"}, method = {RequestMethod.POST}) ModelAndView saveFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/fw_dictionary/remove_tagList"}, method = {RequestMethod.POST}) void removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response);  }
@Test public void testSavePrefixListDictionary() { jsonString = "{\"userid\":\"demo\",\"prefixListDictionaryData\":" + "{\"description\":\"test\",\"prefixListName\":\"Test\"}}"; testSave(PrefixList.class, "prefixListDictionaryDatas", "prefixListName", () -> controller.savePrefixListDictionary(request, response)); }
@Test public void testUpdatePrefixListDictionary() { jsonString = "{\"userid\":\"demo\",\"prefixListDictionaryData\":{\"id\":1,\"description\":" + "\"test\",\"prefixListName\":\"Test\"}}"; testUpdate(PrefixList.class, "prefixListDictionaryDatas", "prefixListName", () -> controller.savePrefixListDictionary(request, response)); }