コード例 #1
0
  @Test
  public void getForumThreadsByUserIdWithNotFound() {
    final User user = new User();
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    DraftForum forum = new DraftForum();
    forum.setName("name");
    persistance.putItem(forum);

    SubForum subForum = new SubForum();
    subForum.setSubForumName("ffff");
    subForum.setSubForumDescription("ffff1");
    forum.addSubForum(subForum);
    persistance.putSubForum(subForum);

    ForumThread forumThread1 = new ForumThread();
    forumThread1.setThreadName("f");
    forumThread1.setThreadDescription("f2");
    forumThread1.setUpdateDate(new Date());
    forumThread1.setAuthor(user);
    subForum.addForumThread(forumThread1);
    persistance.putForumThread(forumThread1);

    List<ForumThread> forumThreads = persistance.getForumThreadsByUserId(user.getUserId() + 90);
    Assert.assertEquals(0, forumThreads.size());
  }
コード例 #2
0
  @Test
  public void getForumPostsByUserId() {
    final User user = new User();
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    DraftForum forum = new DraftForum();
    forum.setName("name");
    persistance.putItem(forum);

    SubForum subForum = new SubForum();
    subForum.setSubForumName("ffff");
    subForum.setSubForumDescription("ffff1");
    forum.addSubForum(subForum);
    persistance.putSubForum(subForum);

    ForumThread forumThread = new ForumThread();
    forumThread.setThreadName("f");
    forumThread.setThreadDescription("f2");
    forumThread.setUpdateDate(new Date());
    subForum.addForumThread(forumThread);
    persistance.putForumThread(forumThread);

    ForumPost forumPost = new ForumPost();
    forumPost.setText("bbb");
    forumPost.setAuthor(user);
    forumPost.setDateCreated(new Date(System.currentTimeMillis() * 2));
    forumThread.addForumPost(forumPost);
    persistance.putForumPost(forumPost);

    List<ForumPost> forumPosts = persistance.getForumPostsByUserId(user.getUserId());
    Assert.assertEquals(1, forumPosts.size());
    Assert.assertEquals(forumPost, forumPosts.get(0));
  }
コード例 #3
0
  @Test
  public void getForumPostsByUserIdWithoutUser() {
    DraftForum forum = new DraftForum();
    forum.setName("name");
    persistance.putItem(forum);

    SubForum subForum = new SubForum();
    subForum.setSubForumName("ffff");
    subForum.setSubForumDescription("ffff1");
    forum.addSubForum(subForum);
    persistance.putSubForum(subForum);

    ForumThread forumThread = new ForumThread();
    forumThread.setThreadName("f");
    forumThread.setThreadDescription("f2");
    forumThread.setUpdateDate(new Date());
    subForum.addForumThread(forumThread);
    persistance.putForumThread(forumThread);

    ForumPost forumPost = new ForumPost();
    forumPost.setText("bbb");
    forumPost.setDateCreated(new Date(System.currentTimeMillis() * 2));
    forumThread.addForumPost(forumPost);
    persistance.putForumPost(forumPost);

    List<ForumPost> forumPosts = persistance.getForumPostsByUserId(1);
    Assert.assertEquals(0, forumPosts.size());
  }
コード例 #4
0
  @Test
  public void getLastPostThreadPost() {
    DraftForum forum = new DraftForum();
    forum.setName("name");
    persistance.putItem(forum);

    SubForum subForum = new SubForum();
    subForum.setSubForumName("ffff");
    subForum.setSubForumDescription("ffff1");
    forum.addSubForum(subForum);
    persistance.putSubForum(subForum);

    ForumThread forumThread1 = new ForumThread();
    forumThread1.setThreadName("f");
    forumThread1.setThreadDescription("f2");
    forumThread1.setUpdateDate(new Date());
    subForum.addForumThread(forumThread1);
    persistance.putForumThread(forumThread1);

    ForumPost forumPost1 = new ForumPost();
    forumPost1.setText("bbb");
    forumPost1.setDateCreated(new Date(System.currentTimeMillis() * 2));
    forumThread1.addForumPost(forumPost1);
    persistance.putForumPost(forumPost1);

    ForumPost forumPost2 = new ForumPost();
    forumPost2.setText("bbb");
    forumPost2.setDateCreated(new Date());
    forumThread1.addForumPost(forumPost2);
    persistance.putForumPost(forumPost2);

    ForumPost lastForumPost = persistance.getLastThreadPost(forumThread1.getThreadId());
    Assert.assertEquals(lastForumPost, forumPost1);
  }
コード例 #5
0
  @Test
  public void getForumThreadsByUserIdWithoutAuthor() {
    DraftForum forum = new DraftForum();
    forum.setName("name");
    persistance.putItem(forum);

    SubForum subForum = new SubForum();
    subForum.setSubForumName("ffff");
    subForum.setSubForumDescription("ffff1");
    forum.addSubForum(subForum);
    persistance.putSubForum(subForum);

    ForumThread forumThread1 = new ForumThread();
    forumThread1.setThreadName("f");
    forumThread1.setThreadDescription("f2");
    forumThread1.setUpdateDate(new Date());
    subForum.addForumThread(forumThread1);
    persistance.putForumThread(forumThread1);

    List<ForumThread> forumThreads = persistance.getForumThreadsByUserId(1);
    Assert.assertEquals(0, forumThreads.size());
  }