class 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);
		
		//topic处于Hibernate受管状态，无须显示更新
		//topicDao.update(topic);
		//userDao.update(user);
	}

}

class ForumServiceTest  {

    @SpringBean("forumService")
	private ForumService forumService;
    @SpringBean("userService")
	private UserService userService;

    @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);
    }

}