@Test @DataSet("BaobaoTao.DataSet.xls") public void addBoardManager(){ forumService.addBoardManager(1,"tom"); User userDb = userService.getUserByUserName("tom"); assertThat(userDb.getManBoards().size(), greaterThan(0)); }
public void addBoardManager(int boardId,String userName){ User user = userDao.getUserByUserName(userName); if(user == null){ throw new RuntimeException("用户名为"+userName+"的用户不存在。"); }else{ Board board = boardDao.get(boardId); user.getManBoards().add(board); userDao.update(user); } }
ForumService { public void addBoardManager(int boardId,String userName){ User user = userDao.getUserByUserName(userName); if(user == null){ throw new RuntimeException("用户名为"+userName+"的用户不存在。"); }else{ Board board = boardDao.get(boardId); user.getManBoards().add(board); userDao.update(user); } } }
ForumService { public void addBoardManager(int boardId,String userName){ User user = userDao.getUserByUserName(userName); if(user == null){ throw new RuntimeException("用户名为"+userName+"的用户不存在。"); }else{ Board board = boardDao.get(boardId); user.getManBoards().add(board); userDao.update(user); } }  }
ForumService { public void addBoardManager(int boardId,String userName){ User user = userDao.getUserByUserName(userName); if(user == null){ throw new RuntimeException("用户名为"+userName+"的用户不存在。"); }else{ Board board = boardDao.get(boardId); user.getManBoards().add(board); userDao.update(user); } }  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 addBoardManager(int boardId,String userName){ User user = userDao.getUserByUserName(userName); if(user == null){ throw new RuntimeException("用户名为"+userName+"的用户不存在。"); }else{ Board board = boardDao.get(boardId); user.getManBoards().add(board); userDao.update(user); } }  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);  }