@Test public void deleteExistingBlogEntry() throws Exception { BlogEntry deletedBlogEntry = new BlogEntry(); deletedBlogEntry.setId(1L); deletedBlogEntry.setTitle("Test Title"); when(service.deleteBlogEntry(1L)).thenReturn(deletedBlogEntry); mockMvc .perform(delete("/rest/blog-entries/1")) .andExpect(jsonPath("$.title", is(deletedBlogEntry.getTitle()))) .andExpect(jsonPath("$.links[*].href", hasItem(endsWith("/blog-entries/1")))) .andExpect(status().isOk()); }
@Test public void deleteNonExistingBlogEntry() throws Exception { when(service.deleteBlogEntry(1L)).thenReturn(null); mockMvc.perform(delete("/rest/blog-entries/1")).andExpect(status().isNotFound()); }