@Test void whenDeletingAnExistingWord_return204() throws Exception { String word = "hello"; WordRequest wordRequest = new WordRequest(word); String json = MAPPER.writeValueAsString(wordRequest); MockHttpServletRequestBuilder create = MockMvcRequestBuilders .post("/words") .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) .content(json); MockHttpServletResponse createResponse = mockMvc.perform(create).andReturn().getResponse(); assertThat(createResponse.getStatus(), is(HttpStatus.CREATED.value())); JsonNode createResponseBody = JsonHelpers.getResponseBody(createResponse); String wordId = createResponseBody.get("id").asText(); MockHttpServletRequestBuilder delete = MockMvcRequestBuilders .delete(String.format("/words/%s", wordId)) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON); MockHttpServletResponse response = mockMvc.perform(delete).andReturn().getResponse(); assertThat(response.getStatus(), is(HttpStatus.NO_CONTENT.value())); }
@DeleteMapping("/{id}") public ResponseEntity<WordResponse> delete(@PathVariable UUID id) { LOGGER.info("Delete word with ID: {}", id); words.remove(id); return ResponseEntity.noContent().build(); }
WordController { @DeleteMapping("/{id}") public ResponseEntity<WordResponse> delete(@PathVariable UUID id) { LOGGER.info("Delete word with ID: {}", id); words.remove(id); return ResponseEntity.noContent().build(); } }
WordController { @DeleteMapping("/{id}") public ResponseEntity<WordResponse> delete(@PathVariable UUID id) { LOGGER.info("Delete word with ID: {}", id); words.remove(id); return ResponseEntity.noContent().build(); }  }
WordController { @DeleteMapping("/{id}") public ResponseEntity<WordResponse> delete(@PathVariable UUID id) { LOGGER.info("Delete word with ID: {}", id); words.remove(id); return ResponseEntity.noContent().build(); }  @PostMapping ResponseEntity<WordResponse> create(@Valid @RequestBody WordRequest request); @GetMapping("/{id}") ResponseEntity<WordResponse> read(@PathVariable UUID id); @PutMapping("/{id}") ResponseEntity<WordResponse> update(@PathVariable UUID id,
                                               @Valid @RequestBody WordRequest request); @DeleteMapping("/{id}") ResponseEntity<WordResponse> delete(@PathVariable UUID id); @DeleteMapping() ResponseEntity<WordResponse> deleteAll(); }
WordController { @DeleteMapping("/{id}") public ResponseEntity<WordResponse> delete(@PathVariable UUID id) { LOGGER.info("Delete word with ID: {}", id); words.remove(id); return ResponseEntity.noContent().build(); }  @PostMapping ResponseEntity<WordResponse> create(@Valid @RequestBody WordRequest request); @GetMapping("/{id}") ResponseEntity<WordResponse> read(@PathVariable UUID id); @PutMapping("/{id}") ResponseEntity<WordResponse> update(@PathVariable UUID id,
                                               @Valid @RequestBody WordRequest request); @DeleteMapping("/{id}") ResponseEntity<WordResponse> delete(@PathVariable UUID id); @DeleteMapping() ResponseEntity<WordResponse> deleteAll();  }