@Test
  public void updateNonExistingBlogEntry() throws Exception {
    when(service.updateBlogEntry(eq(1L), any(BlogEntry.class))).thenReturn(null);

    mockMvc
        .perform(
            put("/rest/blog-entries/1")
                .content("{\"title\":\"Test Title\"}")
                .contentType(MediaType.APPLICATION_JSON))
        .andExpect(status().isNotFound());
  }
  @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 updateExistingBlogEntry() throws Exception {
    BlogEntry updatedEntry = new BlogEntry();
    updatedEntry.setId(1L);
    updatedEntry.setTitle("Test Title");

    when(service.updateBlogEntry(eq(1L), any(BlogEntry.class))).thenReturn(updatedEntry);

    mockMvc
        .perform(
            put("/rest/blog-entries/1")
                .content("{\"title\":\"Test Title\"}")
                .contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.title", is(updatedEntry.getTitle())))
        .andExpect(jsonPath("$.links[*].href", hasItem(endsWith("/blog-entries/1"))))
        .andExpect(status().isOk());
  }
  @Test
  public void getExistingBlogEntry() throws Exception {
    BlogEntry entry = new BlogEntry();
    entry.setId(1L);
    entry.setTitle("Test Title");

    Blog blog = new Blog();
    blog.setId(1L);

    entry.setBlog(blog);

    when(service.findBlogEntry(1L)).thenReturn(entry);

    mockMvc
        .perform(get("/rest/blog-entries/1"))
        .andExpect(jsonPath("$.title", is(entry.getTitle())))
        .andExpect(
            jsonPath(
                "$.links[*].href", hasItems(endsWith("/blogs/1"), endsWith("/blog-entries/1"))))
        .andExpect(jsonPath("$.links[*].rel", hasItems(is("self"), is("blog"))))
        .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());
  }