@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());
  }
  @Test
  public void getForumsByUserId() {
    User user = new User();
    user.setPassword("1");
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    Site site = new Site();
    site.getSitePaymentSettings().setUserId(-1);
    site.setSubDomain("$");
    site.getThemeId().setTemplateDirectory("f");
    site.getThemeId().setThemeCss("G");
    site.setTitle("F");
    persistance.putSite(site);

    UserOnSiteRight userOnUserRight = new UserOnSiteRight();
    userOnUserRight.setActive(true);
    userOnUserRight.setSiteAccessType(SiteAccessLevel.ADMINISTRATOR);
    user.addUserOnSiteRight(userOnUserRight);
    site.addUserOnSiteRight(userOnUserRight);
    persistance.putUserOnSiteRight(userOnUserRight);

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

    List<DraftItem> userForums =
        persistance.getDraftItemsByUserId(user.getUserId(), ItemType.FORUM);
    Assert.assertEquals(forum, userForums.get(0));
  }
  @Test
  public void getForumPostsByUserIdWithOther() {
    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() + 9);
    Assert.assertEquals(0, forumPosts.size());
  }
  @Test
  public void getForumsByUserIdWithoutActive() {
    User user = new User();
    user.setPassword("1");
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    Site site = new Site();
    site.getSitePaymentSettings().setUserId(-1);
    site.setSubDomain("$");
    site.getThemeId().setTemplateDirectory("f");
    site.getThemeId().setThemeCss("G");
    site.setTitle("F");
    persistance.putSite(site);

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

    List<DraftItem> userForums =
        persistance.getDraftItemsByUserId(user.getUserId(), ItemType.FORUM);
    Assert.assertEquals(0, userForums.size());
  }
  @Test
  public void getForumsByUserIdForEmpty() {
    User user = new User();
    user.setPassword("1");
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    List<DraftItem> userForums =
        persistance.getDraftItemsByUserId(user.getUserId(), ItemType.FORUM);
    Assert.assertEquals(0, userForums.size());
  }
  @Test
  public void getFormFiltersByUserId_and_getFormFilterByNameAndUserId() {
    User user = new User();
    user.setPassword("1");
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    Site site = new Site();
    site.getSitePaymentSettings().setUserId(-1);
    site.setSubDomain("$");
    site.getThemeId().setTemplateDirectory("f");
    site.getThemeId().setThemeCss("G");
    site.setTitle("F");
    persistance.putSite(site);

    UserOnSiteRight userOnUserRight = new UserOnSiteRight();
    userOnUserRight.setActive(true);
    userOnUserRight.setSiteAccessType(SiteAccessLevel.ADMINISTRATOR);
    user.addUserOnSiteRight(userOnUserRight);
    site.addUserOnSiteRight(userOnUserRight);
    persistance.putUserOnSiteRight(userOnUserRight);

    DraftForm form = new DraftCustomForm();
    form.setSiteId(site.getSiteId());
    form.setName("name");
    persistance.putItem(form);

    DraftFormFilter filter = new DraftFormFilter();
    filter.setForm(form);
    String filterName = "filter name " + System.currentTimeMillis();
    filter.setName(filterName);
    persistance.putFormFilter(filter);

    List<DraftFormFilter> userFitlers = persistance.getFormFiltersByUserId(user.getUserId());
    Assert.assertEquals(filter, userFitlers.get(0));

    DraftFormFilter namedUserFilter =
        persistance.getFormFilterByNameAndUserId(filterName, user.getUserId());
    Assert.assertEquals(filter, namedUserFilter);
  }
  @Test
  public void getLastSubForumPost() {
    User account = new User();
    account.setEmail("a");
    account.setRegistrationDate(new Date());
    persistance.putUser(account);

    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.getLastSubForumPost(subForum.getSubForumId());
    Assert.assertEquals(lastForumPost, forumPost1);
  }