@Test @DataSet("BaobaoTao.DataSet.xls") public void addPost() throws Exception { Post post = XlsDataSetBeanFactory.createBean(ForumServiceTest.class, "BaobaoTao.DataSet.xls", "t_post", Post.class); User user = XlsDataSetBeanFactory.createBean(ForumServiceTest.class, "BaobaoTao.DataSet.xls", "t_user", User.class); Topic topic = new Topic(); topic.setTopicId(1); post.setUser(user); post.setTopic(topic); forumService.addPost(post); User userDb = userService.getUserByUserName("tom"); Topic topicDb = forumService.getTopicByTopicId(1); assertThat(post.getPostId(), greaterThan(1)); assertThat(userDb.getCredit(), equalTo(105)); assertThat(topicDb.getReplies(), equalTo(2)); }
public void addPost(Post post){ postDao.save(post); User user = post.getUser(); user.setCredit(user.getCredit() + 5); userDao.update(user); Topic topic = topicDao.get(post.getTopic().getTopicId()); topic.setReplies(topic.getReplies() + 1); topic.setLastPost(new Date()); }
ForumService { public void addPost(Post post){ postDao.save(post); User user = post.getUser(); user.setCredit(user.getCredit() + 5); userDao.update(user); Topic topic = topicDao.get(post.getTopic().getTopicId()); topic.setReplies(topic.getReplies() + 1); topic.setLastPost(new Date()); } }
ForumService { public void addPost(Post post){ postDao.save(post); User user = post.getUser(); user.setCredit(user.getCredit() + 5); userDao.update(user); Topic topic = topicDao.get(post.getTopic().getTopicId()); topic.setReplies(topic.getReplies() + 1); topic.setLastPost(new Date()); }  }
ForumService { public void addPost(Post post){ postDao.save(post); User user = post.getUser(); user.setCredit(user.getCredit() + 5); userDao.update(user); Topic topic = topicDao.get(post.getTopic().getTopicId()); topic.setReplies(topic.getReplies() + 1); topic.setLastPost(new Date()); }  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); }
ForumService { public void addPost(Post post){ postDao.save(post); User user = post.getUser(); user.setCredit(user.getCredit() + 5); userDao.update(user); Topic topic = topicDao.get(post.getTopic().getTopicId()); topic.setReplies(topic.getReplies() + 1); topic.setLastPost(new Date()); }  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);  }