@Test public void deleteTest() throws Exception { MvcResult andReturn = this.mockMvc .perform(MockMvcRequestBuilders.get(DEMAND_RESPONSE_EVENT_URL + event1.getId()).with(adminSession)) .andExpect(MockMvcResultMatchers.status().is(HttpStatus.OK_200)).andReturn(); DemandResponseEventReadDto dto = convertMvcResultToDemandResponseDto(andReturn); assertNotNull(dto); this.mockMvc .perform(MockMvcRequestBuilders.delete(DEMAND_RESPONSE_EVENT_URL + event1.getId()).with(adminSession)) .andExpect(MockMvcResultMatchers.status().is(HttpStatus.OK_200)); this.mockMvc .perform(MockMvcRequestBuilders.delete(DEMAND_RESPONSE_EVENT_URL + event1.getId()).with(adminSession)) .andExpect(MockMvcResultMatchers.status().is(HttpStatus.NOT_FOUND_404)); andReturn = this.mockMvc .perform(MockMvcRequestBuilders.delete(DEMAND_RESPONSE_EVENT_URL + "999").with(adminSession)) .andExpect(MockMvcResultMatchers.status().is(HttpStatus.NOT_FOUND_404)).andReturn(); MockHttpServletResponse mockHttpServletResponse = andReturn.getResponse(); assertEquals("", mockHttpServletResponse.getContentAsString()); }
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody public void delete(@PathVariable(value = "id") Long id, HttpServletResponse response) { boolean delete = demandResponseEventService.delete(id); if (!delete) { response.setStatus(HttpStatus.NOT_FOUND_404); } }
DemandResponseController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody public void delete(@PathVariable(value = "id") Long id, HttpServletResponse response) { boolean delete = demandResponseEventService.delete(id); if (!delete) { response.setStatus(HttpStatus.NOT_FOUND_404); } } }
DemandResponseController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody public void delete(@PathVariable(value = "id") Long id, HttpServletResponse response) { boolean delete = demandResponseEventService.delete(id); if (!delete) { response.setStatus(HttpStatus.NOT_FOUND_404); } }  }
DemandResponseController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody public void delete(@PathVariable(value = "id") Long id, HttpServletResponse response) { boolean delete = demandResponseEventService.delete(id); if (!delete) { response.setStatus(HttpStatus.NOT_FOUND_404); } }  @RequestMapping(value = "/search", method = RequestMethod.POST) @ResponseBody List<DemandResponseEventReadDto> search(@RequestBody List<DemandResponseEventFilter> filters,
			@RequestParam(value = "start", required = false) Long start,
			@RequestParam(value = "end", required = false) Long end,
			@RequestParam(value = "page", required = false) Integer page,
			@RequestParam(value = "size", required = false) Integer size, HttpServletResponse response); @RequestMapping(value = "/", method = RequestMethod.POST) @ResponseBody DemandResponseEventReadDto create(@Valid @RequestBody DemandResponseEventCreateDto event,
			HttpServletResponse response, BindingResult result); @RequestMapping(value = "/{id}", method = RequestMethod.PUT) @ResponseBody DemandResponseEventReadDto update(@PathVariable(value = "id") Long id,
			@Valid @RequestBody DemandResponseEventUpdateDto event, HttpServletResponse response,
			BindingResult result); @RequestMapping(value = "/{id}/publish", method = RequestMethod.POST) @ResponseBody DemandResponseEventReadDto publish(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}/active", method = RequestMethod.POST) @ResponseBody DemandResponseEventReadDto active(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}/cancel", method = RequestMethod.POST) @ResponseBody DemandResponseEventReadDto cancel(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody DemandResponseEventReadDto read(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody void delete(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}/venResponse", method = RequestMethod.GET) @ResponseBody List<VenDemandResponseEventDto> readVenDemandResponseEvent(@PathVariable(value = "id") Long id,
			HttpServletResponse response); @RequestMapping(value = "/{id}/venResponse/{username}", method = RequestMethod.GET) @ResponseBody VenDemandResponseEventDto readVenDemandResponseEvent(@PathVariable(value = "id") Long id,
			@PathVariable(value = "username") String username, HttpServletResponse response); }
DemandResponseController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody public void delete(@PathVariable(value = "id") Long id, HttpServletResponse response) { boolean delete = demandResponseEventService.delete(id); if (!delete) { response.setStatus(HttpStatus.NOT_FOUND_404); } }  @RequestMapping(value = "/search", method = RequestMethod.POST) @ResponseBody List<DemandResponseEventReadDto> search(@RequestBody List<DemandResponseEventFilter> filters,
			@RequestParam(value = "start", required = false) Long start,
			@RequestParam(value = "end", required = false) Long end,
			@RequestParam(value = "page", required = false) Integer page,
			@RequestParam(value = "size", required = false) Integer size, HttpServletResponse response); @RequestMapping(value = "/", method = RequestMethod.POST) @ResponseBody DemandResponseEventReadDto create(@Valid @RequestBody DemandResponseEventCreateDto event,
			HttpServletResponse response, BindingResult result); @RequestMapping(value = "/{id}", method = RequestMethod.PUT) @ResponseBody DemandResponseEventReadDto update(@PathVariable(value = "id") Long id,
			@Valid @RequestBody DemandResponseEventUpdateDto event, HttpServletResponse response,
			BindingResult result); @RequestMapping(value = "/{id}/publish", method = RequestMethod.POST) @ResponseBody DemandResponseEventReadDto publish(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}/active", method = RequestMethod.POST) @ResponseBody DemandResponseEventReadDto active(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}/cancel", method = RequestMethod.POST) @ResponseBody DemandResponseEventReadDto cancel(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody DemandResponseEventReadDto read(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody void delete(@PathVariable(value = "id") Long id, HttpServletResponse response); @RequestMapping(value = "/{id}/venResponse", method = RequestMethod.GET) @ResponseBody List<VenDemandResponseEventDto> readVenDemandResponseEvent(@PathVariable(value = "id") Long id,
			HttpServletResponse response); @RequestMapping(value = "/{id}/venResponse/{username}", method = RequestMethod.GET) @ResponseBody VenDemandResponseEventDto readVenDemandResponseEvent(@PathVariable(value = "id") Long id,
			@PathVariable(value = "username") String username, HttpServletResponse response);  }