@Test
  public void testUpdatePosting() throws DataNotFoundException {
    String newTitle = "The new title.";
    String newTags = "#update";

    postingService.writePosting("first_blog", testMixedPosting1);

    Posting originPosting = postingService.findPosting("first_blog", 1);
    originPosting.setContents(mixedContent2);
    originPosting.setTitle(newTitle);
    originPosting.setTags(newTags);

    postingService.updatePosting("first_blog", originPosting);

    Posting changedPosting = postingService.findPosting("first_blog", 1);
    assertEquals(newTitle, changedPosting.getTitle());
    assertEquals(newTags, changedPosting.getTags());
    PostingContent changedContents = changedPosting.getContents();
    assertEquals(mixedContent2.getTextContent(), changedContents.getTextContent());
    String[] newFiles = mixedContent2.getFilePaths();
    String[] changedFiles = changedContents.getFilePaths();
    for (int i = 0; i < newFiles.length; i++) {
      assertEquals(newFiles[i], changedFiles[i]);
    }

    postingService.removePosting("first_blog", 1);
  }
  @Test
  public void testReadPosting() throws DataNotFoundException {
    postingService.writePosting("first_blog", testMixedPosting2);
    postingService.writePosting("first_blog", testSinglePosting2);
    postingService.writePosting("first_blog", testTextPosting2);

    int readCount = 0;
    for (int i = 0; i < 4; i++) {
      postingService.readPosting("first_blog", 1);
      readCount++;
    }
    Posting tempPosting = postingService.findPosting("first_blog", 1);
    assertEquals(tempPosting.getReadCount(), readCount);
  }
  @Test
  public void testLikes() throws DataNotFoundException {
    postingService.writePosting("first_blog", testMixedPosting1);
    postingService.writePosting("first_blog", testTextPosting1);
    postingService.writePosting("first_blog", testSinglePosting1);
    postingService.writePosting("first_blog", testMixedPosting2);

    postingService.addLikes(testMember2, "first_blog", 1);
    postingService.addLikes(testMember2, "first_blog", 2);
    postingService.addLikes(testMember2, "first_blog", 3);
    postingService.addLikes(testMember2, "first_blog", 4);
    Posting posting = postingService.findPosting("first_blog", 1);
    assertEquals(posting.getLikes(), 1);

    Posting[] likePostings = postingService.getLikedPostings(testMember2);
    assertEquals(4, likePostings.length);

    postingService.cancelLikes(testMember2, "first_blog", 1);
    postingService.cancelLikes(testMember2, "first_blog", 2);
    postingService.cancelLikes(testMember2, "first_blog", 3);
    postingService.cancelLikes(testMember2, "first_blog", 4);
    posting = postingService.findPosting("first_blog", 1);
    assertEquals(posting.getLikes(), 0);
  }
  @Test
  public void testReply() throws DataNotFoundException {
    postingService.writePosting("first_blog", testMixedPosting1);

    postingService.replyPosting("first_blog", reply1, 1);
    postingService.replyPosting("first_blog", reply2, 1);
    postingService.replyPosting("first_blog", reply3, 1);

    Posting[] replies = postingService.getReplies("first_blog", 1);
    assertEquals(3, replies.length);
    assertEquals(reply1.getWriter(), replies[0].getWriter());
    assertEquals(reply1.getContentType(), replies[0].getContentType());
    assertEquals(reply1.getExposure(), replies[0].getExposure());
    assertEquals(reply1.getTags(), replies[0].getTags());
    assertEquals(reply1.getPostingType(), replies[0].getPostingType());
    assertEquals(reply1.getReblogOption(), replies[0].getReblogOption());

    postingService.removePosting("first_blog", 1);
  }
  @Test
  public void testReblog() throws DataNotFoundException {
    postingService.writePosting("first_blog", testMixedPosting1);
    postingService.reblog(testMember2, "first_blog", 1, "third_blog");

    Posting reblogedPosting = postingService.findPosting("third_blog", 1);
    assertEquals(reblogedPosting.getTitle(), testMixedPosting1.getTitle());
    assertEquals(
        reblogedPosting.getWriter(),
        testMixedPosting1.getWriter() + " >> " + testMember2.getName());
    assertEquals(reblogedPosting.getContentType(), testMixedPosting1.getContentType());
    assertEquals(reblogedPosting.getExposure(), testMixedPosting1.getExposure());
    assertEquals(reblogedPosting.getTags(), testMixedPosting1.getTags());
    assertEquals(reblogedPosting.getPostingType(), testMixedPosting1.getPostingType());
    assertEquals(reblogedPosting.getReblogOption(), testMixedPosting1.getReblogOption());

    postingService.removePosting("first_blog", 1);
    postingService.removePosting("third_blog", 1);
  }
  @Test(expected = DataNotFoundException.class)
  public void testPostingWriteFindDelete() throws DataNotFoundException {
    postingService.writePosting("first_blog", testMixedPosting1);
    postingService.writePosting("first_blog", testTextPosting1);
    postingService.writePosting("first_blog", testSinglePosting1);
    postingService.writePosting("second_blog", testMixedPosting3);
    postingService.writePosting("second_blog", testTextPosting3);
    postingService.writePosting("second_blog", testSinglePosting3);

    Posting tempPosting = postingService.findPosting("first_blog", 1);

    assertEquals(testMixedPosting1.getWriter(), tempPosting.getWriter());
    assertEquals(testMixedPosting1.getTitle(), tempPosting.getTitle());
    assertEquals(testMixedPosting1.getContentType(), tempPosting.getContentType());
    assertEquals(testMixedPosting1.getExposure(), tempPosting.getExposure());
    assertEquals(testMixedPosting1.getTags(), tempPosting.getTags());
    assertEquals(testMixedPosting1.getPostingType(), tempPosting.getPostingType());
    assertEquals(testMixedPosting1.getReblogOption(), tempPosting.getReblogOption());

    PostingContent originContent = testMixedPosting1.getContents();
    PostingContent compareContent = tempPosting.getContents();
    assertEquals(originContent.getTextContent(), compareContent.getTextContent());

    String[] originFiles = originContent.getFilePaths();
    String[] compareFiles = compareContent.getFilePaths();
    for (int i = 0; i < originFiles.length; i++) {
      assertEquals(originFiles[i], compareFiles[i]);
    }

    postingService.removePosting("first_blog", 1);
    postingService.removePosting("first_blog", 2);
    postingService.removePosting("first_blog", 3);
    postingService.removePosting("second_blog", 1);
    postingService.removePosting("second_blog", 2);
    postingService.removePosting("second_blog", 3);

    tempPosting = postingService.findPosting("second_blog", 2);
  }