ValueSetController extends AbstractNodeController { @RequestMapping(value = "/valueSet/delete/{id}", method = RequestMethod.DELETE) public @ResponseBody String delete(@PathVariable("id") Long id, RedirectAttributes redirectAttribute) { LOGGER.debug("Deleting valueSet with id: " + id); ValueSetDto deleted = new ValueSetDto(); try { deleted = valueSetService.delete(id); deleted.setError(false); deleted.setSuccessMessage("ValueSet with Code: " + deleted.getCode() + " and Name: " + deleted.getName() + " is deleted Successfully."); } catch (ValueSetNotFoundException e) { LOGGER.debug(e.getMessage()); deleted.setError(true); deleted.setErrorMessage(e.getMessage()); throw new AjaxException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage()); } redirectAttribute.addFlashAttribute(MODEL_ATTIRUTE_VALUESETDTO, deleted); if(deleted.isError == false){ return deleted.getSuccessMessage(); }else{ throw new AjaxException(HttpStatus.INTERNAL_SERVER_ERROR, deleted.getErrorMessage()); } }  @RequestMapping(value = "/valueSet/batchUpload", method = RequestMethod.POST) String batchUpload(HttpServletRequest request, @RequestParam("batch_file") MultipartFile file,
			RedirectAttributes redirectAttribute); @RequestMapping(value = "/valueSet/delete/{id}", method = RequestMethod.DELETE) @ResponseBody String delete(@PathVariable("id") Long id,
			RedirectAttributes redirectAttribute); @RequestMapping("/valueSet/ajaxGetPagedValueSets/pageNumber/{pageNumber}") @ResponseStatus(HttpStatus.OK) @ResponseBody Map<String, Object> getAllConceptCodes(@PathVariable("pageNumber") String pageNumber); @RequestMapping("/valueSet/ajaxSearchValueSet/pageNumber/{pageNumber}/searchCategory/{searchCategory}/searchTerm/{searchTerm}/valueSetCategory/{valueSetCategory}") @ResponseStatus(HttpStatus.OK) @ResponseBody Map<String, Object> searchValueSet(
			@PathVariable("searchCategory") String searchCategory,
			@PathVariable("searchTerm") String searchTerm,
			@PathVariable("valueSetCategory") String valueSetCategory,
			@PathVariable("pageNumber") String pageNumber); @RequestMapping(value = REQUEST_MAPPING_LIST, method = RequestMethod.GET) String showCreateValueSetForm(Model model,
			@RequestParam(value = "panelState", required = false, defaultValue = "") String panelState); @RequestMapping(value = "/valueSet/edit/{id}", method = RequestMethod.GET) String showEditValueSetForm(@PathVariable("id") Long id,
			Model model, RedirectAttributes attributes); @RequestMapping(value = "/valueSet/create", method = RequestMethod.POST) String submitCreateValueSetForm(
			@Valid @ModelAttribute(MODEL_ATTIRUTE_VALUESETDTO) ValueSetDto created,
			RedirectAttributes redirectAttribute, Model model); @RequestMapping(value = "/valueSet/edit/{id}", method = RequestMethod.POST) String submitEditValueSetForm(
			@ModelAttribute(MODEL_ATTIRUTE_VALUESETDTO) ValueSetDto updated,
			RedirectAttributes attributes,
			@PathVariable("id") Long id); @RequestMapping(value = "valueSetAdd.html", method = RequestMethod.GET) String valueSetAddForm(Model model, HttpServletRequest request);  }
@Test public void testDeleteValueSet() throws Exception{ ValueSetDto deleted=new ValueSetDto(); deleted.setCode("TESTCODE"); deleted.setName("Test Name"); when(valueSetService.delete(anyLong())).thenReturn(deleted); mockMvc.perform(delete("/sysadmin/valueSet/delete/1")) .andExpect(content().string("ValueSet with Code: TESTCODE and Name: Test Name is deleted Successfully.")); }
@Test public void testDeleteValueSet_throwException() throws Exception{ when(valueSetService.delete(anyLong())).thenThrow(new ValueSetNotFoundException()); mockMvc.perform(delete("/sysadmin/valueSet/delete/1")) .andExpect(status().isInternalServerError()); }
@Test public void testDeleteValueSet_withPost() throws Exception{ ValueSetDto deleted=new ValueSetDto(); when(valueSetService.delete(anyLong())).thenReturn(deleted); mockMvc.perform(post("/sysadmin/valueSet/delete/1")) .andExpect(status().isMethodNotAllowed()); }