ForumService { public void removePost(int postId){ Post post = postDao.get(postId); postDao.remove(post); Topic topic = topicDao.get(post.getTopic().getTopicId()); topic.setReplies(topic.getReplies() - 1); User user =post.getUser(); user.setCredit(user.getCredit() - 20); }  @Autowired void setTopicDao(TopicDao topicDao); @Autowired void setUserDao(UserDao userDao); @Autowired void setBoardDao(BoardDao boardDao); @Autowired void setPostDao(PostDao postDao); void addTopic(Topic topic); void removeTopic(int topicId); void addPost(Post post); void removePost(int postId); void addBoard(Board board); void removeBoard(int boardId); void makeDigestTopic(int topicId); List<Board> getAllBoards(); Page getPagedTopics(int boardId,int pageNo,int pageSize); Page getPagedPosts(int topicId,int pageNo,int pageSize); Page queryTopicByTitle(String title,int pageNo,int pageSize); Board getBoardById(int boardId); Topic getTopicByTopicId(int topicId); Post getPostByPostId(int postId); void addBoardManager(int boardId,String userName); void updateTopic(Topic topic); void updatePost(Post post);  }
@Test @DataSet("XiaoChun.DataSet.xls") public void removePost() { forumService.removePost(1); Post postDb = forumService.getPostByPostId(1); User userDb = userService.getUserByUserName("tom"); Topic topicDb = forumService.getTopicByTopicId(1); assertNull(postDb); assertEquals(userDb.getCredit(), 80); assertEquals(topicDb.getReplies(), 0); }