Package cn.edu.zju.acm.onlinejudge.bean

Examples of cn.edu.zju.acm.onlinejudge.bean.Post


            try {
                ps = conn.prepareStatement(ForumPersistenceImpl.GET_POST);
                ps.setLong(1, id);
                ResultSet rs = ps.executeQuery();
                if (rs.next()) {
                    Post post = new Post();
                    post.setId(rs.getLong(DatabaseConstants.POST_POST_ID));
                    post.setThreadId(rs.getLong(DatabaseConstants.POST_THREAD_ID));
                    post.setUserProfileId(rs.getLong(DatabaseConstants.POST_USER_PROFILE_ID));
                    post.setContent(rs.getString(DatabaseConstants.POST_CONTENT));
                    return post;
                } else {
                    return null;
                }
            } finally {
View Full Code Here


                List<Post> posts = new ArrayList<Post>();
                int index = 0;
                while (rs.next() && index - offset < count) {
                    ++index;
                    if (index > offset) {
                        Post post = new Post();
                        post.setId(rs.getLong(DatabaseConstants.POST_POST_ID));
                        post.setThreadId(rs.getLong(DatabaseConstants.POST_THREAD_ID));
                        post.setUserProfileId(rs.getLong(DatabaseConstants.POST_USER_PROFILE_ID));
                        post.setContent(rs.getString(DatabaseConstants.POST_CONTENT));
                        posts.add(post);
                    }
                }
                return posts;
            } finally {
View Full Code Here

    persistence.createPost(post2, 1);
    persistence.createPost(post3, 1);

    thread3Posts = new ArrayList();
    for (int i = 1; i <= 10; ++i) {
      Post post = newPost(i, thread3.getId(), profile.getId());
      thread3Posts.add(post);
      persistence.createPost(post, 1);
    }
  }
View Full Code Here

   * Tests getPost method
   * @throws Exception to JUnit
   */
  public void testGetPost() throws Exception {   
   
    Post post = persistence.getPost(post1.getId());
    checkPost(post1, post);   
  }
View Full Code Here

   * @throws Exception to JUnit
   */
  public void testCreatePost1() throws Exception {   
   
   
    Post post = newPost(-1, thread1.getId(), profile.getId());
    persistence.createPost(post, 1);
   
    Post newPost = persistence.getPost(post.getId());
    checkPost(post, newPost);   

  }
View Full Code Here

   */
  public void testUpdatePost1() throws Exception {
    post1.setId(post2.getId());
    persistence.updatePost(post1, 1);
       
    Post post = persistence.getPost(post1.getId());
    checkPost(post1, post)
   
  }
View Full Code Here

   * @param count the count
   */
  private void checkPostList(List posts1, int offset1, List posts2, int offset2, int count) {
   
    for (int i = 0; i < count; ++i) {
      Post post1 = (Post) posts1.get(offset1 + i);
      Post post2 = (Post) posts2.get(offset2 + i);
      checkPost(post1, post2);
    }     
  }
View Full Code Here

   * @param threadId the thread id
   * @param userId the user id
   * @return a new post instance
   */
  private Post newPost(long id, long threadId, long userId) {
    Post post = new Post();
    post.setId(id);
    post.setThreadId(threadId);
    post.setUserProfileId(userId);
    post.setContent("post content" + id);   
    return post;
  }
View Full Code Here

    persistence.createPost(post2, 1);
    persistence.createPost(post3, 1);

    thread3Posts = new ArrayList();
    for (int i = 1; i <= 10; ++i) {
      Post post = newPost(i, thread3.getId(), profile.getId());
      thread3Posts.add(post);
      persistence.createPost(post, 1);
    }
  }
View Full Code Here

   * Tests getPost method
   * @throws Exception to JUnit
   */
  public void testGetPost() throws Exception {   
   
    Post post = persistence.getPost(post1.getId());
    checkPost(post1, post);   
  }
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.bean.Post

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.