@Test public void delete_TodoEntryFound_ShouldReturnDeletedTodoEntryAsJsonDocument() throws Exception { TodoDTO deletedTodoEntry = new TodoDTOBuilder() .creationTime(CREATION_TIME) .description(DESCRIPTION) .id(ID) .modificationTime(MODIFICATION_TIME) .title(TITLE) .build(); when(todoCrudServiceMock.delete(ID)).thenReturn(deletedTodoEntry); mockMvc.perform(delete("/api/todo/{id}", ID)) .andExpect(status().isOk()) .andExpect(content().contentType(WebTestConstants.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$.id", is(ID.intValue()))) .andExpect(jsonPath("$.creationTime", is(CREATION_TIME))) .andExpect(jsonPath("$.description", is(DESCRIPTION))) .andExpect(jsonPath("$.modificationTime", is(MODIFICATION_TIME))) .andExpect(jsonPath("$.title", is(TITLE))); verify(todoCrudServiceMock, times(1)).delete(ID); verifyNoMoreInteractions(todoCrudServiceMock); verifyZeroInteractions(todoSearchServiceMock); }
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public TodoDTO delete(@PathVariable("id") Long id) { LOGGER.info("Deleting todo entry with id: {}", id); TodoDTO deleted = crudService.delete(id); LOGGER.info("Deleted todo entry: {}", deleted); return deleted; }
TodoController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public TodoDTO delete(@PathVariable("id") Long id) { LOGGER.info("Deleting todo entry with id: {}", id); TodoDTO deleted = crudService.delete(id); LOGGER.info("Deleted todo entry: {}", deleted); return deleted; } }
TodoController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public TodoDTO delete(@PathVariable("id") Long id) { LOGGER.info("Deleting todo entry with id: {}", id); TodoDTO deleted = crudService.delete(id); LOGGER.info("Deleted todo entry: {}", deleted); return deleted; } @Autowired  TodoController(TodoCrudService crudService, TodoSearchService searchService); }
TodoController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public TodoDTO delete(@PathVariable("id") Long id) { LOGGER.info("Deleting todo entry with id: {}", id); TodoDTO deleted = crudService.delete(id); LOGGER.info("Deleted todo entry: {}", deleted); return deleted; } @Autowired  TodoController(TodoCrudService crudService, TodoSearchService searchService); @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) TodoDTO add(@RequestBody @Valid TodoDTO dto); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) TodoDTO delete(@PathVariable("id") Long id); @RequestMapping(method = RequestMethod.GET) List<TodoDTO> findAll(); @RequestMapping(value = "/{id}", method = RequestMethod.GET) TodoDTO findById(@PathVariable("id") Long id); @RequestMapping(value = "/search", method = RequestMethod.GET) Page<TodoDTO> findBySearchTerm(@RequestParam("searchTerm") String searchTerm, Pageable pageable); @RequestMapping(value = "/{id}", method = RequestMethod.PUT) TodoDTO update(@PathVariable("id") Long id, @RequestBody @Valid TodoDTO dto); }
TodoController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public TodoDTO delete(@PathVariable("id") Long id) { LOGGER.info("Deleting todo entry with id: {}", id); TodoDTO deleted = crudService.delete(id); LOGGER.info("Deleted todo entry: {}", deleted); return deleted; } @Autowired  TodoController(TodoCrudService crudService, TodoSearchService searchService); @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) TodoDTO add(@RequestBody @Valid TodoDTO dto); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) TodoDTO delete(@PathVariable("id") Long id); @RequestMapping(method = RequestMethod.GET) List<TodoDTO> findAll(); @RequestMapping(value = "/{id}", method = RequestMethod.GET) TodoDTO findById(@PathVariable("id") Long id); @RequestMapping(value = "/search", method = RequestMethod.GET) Page<TodoDTO> findBySearchTerm(@RequestParam("searchTerm") String searchTerm, Pageable pageable); @RequestMapping(value = "/{id}", method = RequestMethod.PUT) TodoDTO update(@PathVariable("id") Long id, @RequestBody @Valid TodoDTO dto);  }