@Test public void testDeleteValueSetForm_throwException() throws Exception{ when(valueSetCategoryService.delete(anyLong())).thenThrow(new ValueSetCategoryNotFoundException()); mockMvc.perform(post("/sysadmin/valueSetCategory/delete/1")) .andExpect(view().name("redirect:../../valueSetCategoryList")); }
@RequestMapping(value = "/valueSetCategory/delete/{id}", method = RequestMethod.POST) public String delete(@PathVariable("id") Long id, RedirectAttributes redirectAttribute) { LOGGER.debug("Deleting valueSetCategory with id: " + id); ValueSetCategoryDto deleted = new ValueSetCategoryDto(); try { deleted = valueSetCategoryService.delete(id); deleted.setError(false); deleted.setSuccessMessage(" ValueSetCategory with Code: " + deleted.getCode() + " and Name: " + deleted.getName() + " is deleted Successfully. "); } catch (ValueSetCategoryNotFoundException e) { LOGGER.debug("No valueSetCategory found with id: " + id); deleted.setError(true); deleted.setErrorMessage(ERROR_MESSAGE_KEY_DELETED_VALUESETCATEGORY_WAS_NOT_FOUND); } redirectAttribute.addFlashAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO, deleted); return createRedirectViewPath(REDIRECT_ID_MAPPING_LIST); }
ValueSetCategoryController extends AbstractNodeController { @RequestMapping(value = "/valueSetCategory/delete/{id}", method = RequestMethod.POST) public String delete(@PathVariable("id") Long id, RedirectAttributes redirectAttribute) { LOGGER.debug("Deleting valueSetCategory with id: " + id); ValueSetCategoryDto deleted = new ValueSetCategoryDto(); try { deleted = valueSetCategoryService.delete(id); deleted.setError(false); deleted.setSuccessMessage(" ValueSetCategory with Code: " + deleted.getCode() + " and Name: " + deleted.getName() + " is deleted Successfully. "); } catch (ValueSetCategoryNotFoundException e) { LOGGER.debug("No valueSetCategory found with id: " + id); deleted.setError(true); deleted.setErrorMessage(ERROR_MESSAGE_KEY_DELETED_VALUESETCATEGORY_WAS_NOT_FOUND); } redirectAttribute.addFlashAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO, deleted); return createRedirectViewPath(REDIRECT_ID_MAPPING_LIST); } }
ValueSetCategoryController extends AbstractNodeController { @RequestMapping(value = "/valueSetCategory/delete/{id}", method = RequestMethod.POST) public String delete(@PathVariable("id") Long id, RedirectAttributes redirectAttribute) { LOGGER.debug("Deleting valueSetCategory with id: " + id); ValueSetCategoryDto deleted = new ValueSetCategoryDto(); try { deleted = valueSetCategoryService.delete(id); deleted.setError(false); deleted.setSuccessMessage(" ValueSetCategory with Code: " + deleted.getCode() + " and Name: " + deleted.getName() + " is deleted Successfully. "); } catch (ValueSetCategoryNotFoundException e) { LOGGER.debug("No valueSetCategory found with id: " + id); deleted.setError(true); deleted.setErrorMessage(ERROR_MESSAGE_KEY_DELETED_VALUESETCATEGORY_WAS_NOT_FOUND); } redirectAttribute.addFlashAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO, deleted); return createRedirectViewPath(REDIRECT_ID_MAPPING_LIST); }  }
ValueSetCategoryController extends AbstractNodeController { @RequestMapping(value = "/valueSetCategory/delete/{id}", method = RequestMethod.POST) public String delete(@PathVariable("id") Long id, RedirectAttributes redirectAttribute) { LOGGER.debug("Deleting valueSetCategory with id: " + id); ValueSetCategoryDto deleted = new ValueSetCategoryDto(); try { deleted = valueSetCategoryService.delete(id); deleted.setError(false); deleted.setSuccessMessage(" ValueSetCategory with Code: " + deleted.getCode() + " and Name: " + deleted.getName() + " is deleted Successfully. "); } catch (ValueSetCategoryNotFoundException e) { LOGGER.debug("No valueSetCategory found with id: " + id); deleted.setError(true); deleted.setErrorMessage(ERROR_MESSAGE_KEY_DELETED_VALUESETCATEGORY_WAS_NOT_FOUND); } redirectAttribute.addFlashAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO, deleted); return createRedirectViewPath(REDIRECT_ID_MAPPING_LIST); }  @RequestMapping(value = REQUEST_MAPPING_LIST, method = RequestMethod.GET) String showCreateValueSetForm(Model model, HttpServletRequest request); @RequestMapping(value = "valueSetCategoryAdd.html", method = RequestMethod.GET) String valueSetCategoryAddForm(Model model,
			HttpServletRequest request); @RequestMapping(value = "/valueSetCategory/create", method = RequestMethod.POST) String submitCreateValueSetForm(
			@Valid @ModelAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO) ValueSetCategoryDto created,
			RedirectAttributes redirectAttribute, Model model); @RequestMapping(value = "/valueSetCategory/delete/{id}", method = RequestMethod.POST) String delete(@PathVariable("id") Long id,
			RedirectAttributes redirectAttribute); @RequestMapping(value = "/valueSetCategory/edit/{id}", method = RequestMethod.GET) String showEditValueSetCategoryForm(@PathVariable("id") Long id,
			Model model, RedirectAttributes attributes); @RequestMapping(value = "/valueSetCategory/edit/{id}", method = RequestMethod.POST) String submitEditValueSetCategoryForm(
			@ModelAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO) ValueSetCategoryDto updated,
			@PathVariable("id") Long id); }
ValueSetCategoryController extends AbstractNodeController { @RequestMapping(value = "/valueSetCategory/delete/{id}", method = RequestMethod.POST) public String delete(@PathVariable("id") Long id, RedirectAttributes redirectAttribute) { LOGGER.debug("Deleting valueSetCategory with id: " + id); ValueSetCategoryDto deleted = new ValueSetCategoryDto(); try { deleted = valueSetCategoryService.delete(id); deleted.setError(false); deleted.setSuccessMessage(" ValueSetCategory with Code: " + deleted.getCode() + " and Name: " + deleted.getName() + " is deleted Successfully. "); } catch (ValueSetCategoryNotFoundException e) { LOGGER.debug("No valueSetCategory found with id: " + id); deleted.setError(true); deleted.setErrorMessage(ERROR_MESSAGE_KEY_DELETED_VALUESETCATEGORY_WAS_NOT_FOUND); } redirectAttribute.addFlashAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO, deleted); return createRedirectViewPath(REDIRECT_ID_MAPPING_LIST); }  @RequestMapping(value = REQUEST_MAPPING_LIST, method = RequestMethod.GET) String showCreateValueSetForm(Model model, HttpServletRequest request); @RequestMapping(value = "valueSetCategoryAdd.html", method = RequestMethod.GET) String valueSetCategoryAddForm(Model model,
			HttpServletRequest request); @RequestMapping(value = "/valueSetCategory/create", method = RequestMethod.POST) String submitCreateValueSetForm(
			@Valid @ModelAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO) ValueSetCategoryDto created,
			RedirectAttributes redirectAttribute, Model model); @RequestMapping(value = "/valueSetCategory/delete/{id}", method = RequestMethod.POST) String delete(@PathVariable("id") Long id,
			RedirectAttributes redirectAttribute); @RequestMapping(value = "/valueSetCategory/edit/{id}", method = RequestMethod.GET) String showEditValueSetCategoryForm(@PathVariable("id") Long id,
			Model model, RedirectAttributes attributes); @RequestMapping(value = "/valueSetCategory/edit/{id}", method = RequestMethod.POST) String submitEditValueSetCategoryForm(
			@ModelAttribute(MODEL_ATTIRUTE_VALUESETCATEGORYDTO) ValueSetCategoryDto updated,
			@PathVariable("id") Long id);  }