@Test void whenDeletingAnNonExistingBook_return204() throws Exception { String bookId = UUID.randomUUID().toString(); MockHttpServletRequestBuilder delete = MockMvcRequestBuilders .delete(String.format("/books/%s", bookId)) .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<Book> delete(@PathVariable UUID id) { LOGGER.info("Delete book with ID: {}", id); Book removedBook = books.remove(id); LOGGER.info("Book deleted: {}", removedBook); return ResponseEntity.noContent().build(); }
BookController { @DeleteMapping("/{id}") public ResponseEntity<Book> delete(@PathVariable UUID id) { LOGGER.info("Delete book with ID: {}", id); Book removedBook = books.remove(id); LOGGER.info("Book deleted: {}", removedBook); return ResponseEntity.noContent().build(); } }
BookController { @DeleteMapping("/{id}") public ResponseEntity<Book> delete(@PathVariable UUID id) { LOGGER.info("Delete book with ID: {}", id); Book removedBook = books.remove(id); LOGGER.info("Book deleted: {}", removedBook); return ResponseEntity.noContent().build(); }  }
BookController { @DeleteMapping("/{id}") public ResponseEntity<Book> delete(@PathVariable UUID id) { LOGGER.info("Delete book with ID: {}", id); Book removedBook = books.remove(id); LOGGER.info("Book deleted: {}", removedBook); return ResponseEntity.noContent().build(); }  @PostMapping ResponseEntity<Book> create(@Valid @RequestBody BookRequest request); @GetMapping("/{id}") ResponseEntity<Book> read(@PathVariable UUID id); @GetMapping ResponseEntity<Book> readByTitle(@RequestParam String title); @PutMapping("/{id}") ResponseEntity<Book> update(@PathVariable UUID id,
                                       @Valid @RequestBody BookRequest request); @DeleteMapping("/{id}") ResponseEntity<Book> delete(@PathVariable UUID id); @DeleteMapping() ResponseEntity<Book> deleteAll(); }
BookController { @DeleteMapping("/{id}") public ResponseEntity<Book> delete(@PathVariable UUID id) { LOGGER.info("Delete book with ID: {}", id); Book removedBook = books.remove(id); LOGGER.info("Book deleted: {}", removedBook); return ResponseEntity.noContent().build(); }  @PostMapping ResponseEntity<Book> create(@Valid @RequestBody BookRequest request); @GetMapping("/{id}") ResponseEntity<Book> read(@PathVariable UUID id); @GetMapping ResponseEntity<Book> readByTitle(@RequestParam String title); @PutMapping("/{id}") ResponseEntity<Book> update(@PathVariable UUID id,
                                       @Valid @RequestBody BookRequest request); @DeleteMapping("/{id}") ResponseEntity<Book> delete(@PathVariable UUID id); @DeleteMapping() ResponseEntity<Book> deleteAll();  }