@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)); }
@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()); }
@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); }
@Test public void testExecute_WithExpiredSettings() throws Exception { User user = TestUtil.createUser(); user.setActiveted(null); Site parentSite = TestUtil.createSite(); DraftChildSiteRegistration registration = TestUtil.createChildSiteRegistration(parentSite); ChildSiteSettings settings = TestUtil.createChildSiteSettings(registration, parentSite); settings.setCreatedDate( new Date((System.currentTimeMillis() - TimeInterval.TEN_DAYS.getMillis() * 2) + 1)); settings.setUserId(user.getUserId()); settings.setConfirmCode("confirm"); action.setSettingsId(settings.getChildSiteSettingsId()); action.setConfirmCode("confirm"); ForwardResolution resolutionMock = (ForwardResolution) action.show(); Assert.assertEquals( "/account/registration/registrationLinkExpired.jsp", resolutionMock.getPath()); }
@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); }