Search in sources :

Example 36 with Post

use of it.vige.rubia.model.Post in project rubia-forums by flashboss.

the class OperationPostTest method verifyPostFromForumPageLastPost.

@Test
public void verifyPostFromForumPageLastPost() {
    Forum forum = new Forum("Second Test Forum", "Second Test Description", new Category("First Test Category"));
    goTo(driver, forum);
    Topic topic = new Topic(forum, "Third Test Topic");
    Poster poster = getPosterLastPost(driver, topic);
    goTo(driver, forum);
    Post post = getLastPostOfCurrentForum(driver, topic);
    assertTrue(post != null);
    assertEquals(RE + "Third Test Topic", post.getMessage().getSubject());
    assertTrue(poster != null);
    assertEquals("root", poster.getUserId());
    assertTrue(poster.getPostCount() >= 14);
}
Also used : CreateCategory.createCategory(it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory) RemoveCategory.removeCategory(it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory) Category(it.vige.rubia.model.Category) RemovePost.removePost(it.vige.rubia.selenium.forum.action.RemovePost.removePost) VerifyTopic.getPosterLastPost(it.vige.rubia.selenium.forum.action.VerifyTopic.getPosterLastPost) CreatePost.createPost(it.vige.rubia.selenium.forum.action.CreatePost.createPost) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) VerifyTopic.getPoster(it.vige.rubia.selenium.forum.action.VerifyTopic.getPoster) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) Forum(it.vige.rubia.model.Forum) VerifyPost.getLastPostOfCurrentForum(it.vige.rubia.selenium.forum.action.VerifyPost.getLastPostOfCurrentForum) RemoveForum.removeForum(it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum) CreateForum.createForum(it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum) Test(org.junit.Test)

Example 37 with Post

use of it.vige.rubia.model.Post in project rubia-forums by flashboss.

the class ViewAtomLink method getPage.

public static Topic getPage(WebDriver driver, Topic topic) {
    VerifyTopic.goTo(driver, topic);
    goTo(driver);
    Topic result = new Topic();
    result.setSubject(driver.findElement(id(FEED_TITLE_TEXT)).getText().split(": ")[1]);
    String[] splittedText = driver.findElement(id(FEED_SUBTITLE_TEXT)).getText().split(" in topic | in forum | in category ");
    result.setForum(new Forum(splittedText[2]));
    result.getForum().setCategory(new Category(splittedText[3]));
    List<Post> posts = new ArrayList<Post>();
    int entriesSize = driver.findElements(className(ENTRY_LINK)).size();
    DateFormat dateFormat = new SimpleDateFormat("d MMM yyyy, HH:mm");
    for (int i = 0; i < entriesSize; i++) {
        WebElement entry = driver.findElements(className(ENTRY_LINK)).get(i);
        String[] entryText = entry.getText().split(BY);
        String lastUpdated = entry.findElement(className(LAST_UPDATED)).getText();
        Post post = new Post(entryText[0]);
        post.setPoster(new Poster(entryText[1].split("\n")[0]));
        try {
            post.setCreateDate(dateFormat.parse(lastUpdated));
        } catch (ParseException e) {
        }
        post.setMessage(new Message(entry.findElement(className(FEED_ENTRY_CONTENT)).getText()));
        post.getMessage().setSubject(entryText[0]);
        posts.add(post);
        WebElement entryLink = driver.findElement(linkText(entry.getText().split("\n")[0]));
        entryLink.click();
        List<Attachment> attachments = getAttachmentsOfCurrentPostInPage(driver, post);
        post.setAttachments(attachments);
        if (topic.getPoll() == null) {
            Poll poll = getPollOfCurrentTopic(driver);
            result.setPoll(poll);
        }
        VerifyTopic.goTo(driver, result);
        goTo(driver);
    }
    result.setPosts(posts);
    returnToHome(driver);
    return result;
}
Also used : Category(it.vige.rubia.model.Category) Message(it.vige.rubia.model.Message) Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) Attachment(it.vige.rubia.model.Attachment) WebElement(org.openqa.selenium.WebElement) Forum(it.vige.rubia.model.Forum) VerifyForum(it.vige.rubia.selenium.forum.action.VerifyForum) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Poster(it.vige.rubia.model.Poster) Poll(it.vige.rubia.model.Poll) ParseException(java.text.ParseException) VerifyTopic(it.vige.rubia.selenium.forum.action.VerifyTopic) Topic(it.vige.rubia.model.Topic) VerifyPoll.getPollOfCurrentTopic(it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic) SimpleDateFormat(java.text.SimpleDateFormat)

Example 38 with Post

use of it.vige.rubia.model.Post in project rubia-forums by flashboss.

the class ViewCategory method processCategory.

/**
 * @return
 */
private void processCategory(Category category) throws Exception {
    Date userLastLogin = getUserLastLoginDate(userModule, userProfileModule);
    if (category != null) {
        getCategories().add(category);
        // process the forums associated with this category
        Collection<Forum> forums = forumsModule.findForumsByCategory(category);
        Collection<Forum> categoryForums = new ArrayList<Forum>();
        for (Forum currentForum : forums) {
            categoryForums.add(currentForum);
            // setup folderLook based on whats specified in the theme
            String folderImage = themeHelper.getResourceForumURL();
            // bundle key
            String folderAlt = "No_new_posts";
            if (this.forumLastPosts != null && forumLastPosts.containsKey(currentForum.getId())) {
                Post lastPost = forumLastPosts.get(currentForum.getId());
                Date lastPostDate = lastPost.getCreateDate();
                if (lastPostDate != null && userLastLogin != null && lastPostDate.compareTo(userLastLogin) > 0) {
                    // bundle key
                    folderAlt = "New_posts";
                    folderImage = themeHelper.getResourceForumNewURL();
                }
            }
            if (currentForum.getStatus() == FORUM_LOCKED) {
                folderImage = themeHelper.getResourceForumLockedURL();
                // bundle key
                folderAlt = "Forum_locked";
            }
            getForumImages().put(currentForum.getId(), folderImage);
            getForumImageDescriptions().put(currentForum.getId(), folderAlt);
        }
        getForums().put(category.getId(), categoryForums);
    }
}
Also used : Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) Date(java.util.Date) JSFUtil.getUserLastLoginDate(it.vige.rubia.ui.JSFUtil.getUserLastLoginDate) Forum(it.vige.rubia.model.Forum) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 39 with Post

use of it.vige.rubia.model.Post in project rubia-forums by flashboss.

the class ViewMyForumsMain method execute.

/**
 */
@PostConstruct
public void execute() {
    try {
        super.execute();
        Collection<Forum> forums = getWatchedForums();
        Date userLastLogin = getUserLastLoginDate(userModule, userProfileModule);
        for (Forum currentForum : forums) {
            // setup folderLook based on whats specified in the theme
            String folderImage = themeHelper.getResourceForumURL();
            // bundle key
            String folderAlt = "No_new_posts";
            if (forumsLastPosts != null && forumsLastPosts.containsKey(currentForum.getId())) {
                Post lastPost = forumsLastPosts.get(currentForum.getId());
                Date lastPostDate = lastPost.getCreateDate();
                if (lastPostDate != null && userLastLogin != null && lastPostDate.compareTo(userLastLogin) > 0) {
                    // bundle key
                    folderAlt = "New_posts";
                    folderImage = themeHelper.getResourceForumNewURL();
                }
            }
            if (currentForum.getStatus() == Constants.FORUM_LOCKED) {
                folderImage = themeHelper.getResourceForumLockedURL();
                // bundle key
                folderAlt = "Forum_locked";
            }
            getForumImages().put(currentForum.getId(), folderImage);
            getForumImageDescriptions().put(currentForum.getId(), folderAlt);
        }
    } catch (Exception e) {
        log.error(e);
    }
}
Also used : Post(it.vige.rubia.model.Post) Date(java.util.Date) JSFUtil.getUserLastLoginDate(it.vige.rubia.ui.JSFUtil.getUserLastLoginDate) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Forum(it.vige.rubia.model.Forum) SecureActionForum(it.vige.rubia.auth.SecureActionForum) PostConstruct(javax.annotation.PostConstruct)

Example 40 with Post

use of it.vige.rubia.model.Post in project rubia-forums by flashboss.

the class ViewTopic method execute.

/**
 * This method gets topicId from parameters and tries to find topic with
 * that id.
 */
@PostConstruct
public void execute() {
    // parse input data
    int topicId = -1;
    Integer postId = -1;
    String t = getParameter(p_topicId);
    String p = getParameter(p_postId);
    if (t != null && t.trim().length() > 0) {
        topicId = parseInt(t);
    }
    try {
        if (p != null && p.trim().length() > 0) {
            postId = new Integer(p);
            Post post = forumsModule.findPostById(postId);
            topicId = post.getTopic().getId().intValue();
            topic = post.getTopic();
        }
        refreshTopic(topicId);
    } catch (Exception e) {
        log.error(e);
    }
}
Also used : Post(it.vige.rubia.model.Post) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Post (it.vige.rubia.model.Post)98 Topic (it.vige.rubia.model.Topic)62 Forum (it.vige.rubia.model.Forum)52 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)43 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)38 Category (it.vige.rubia.model.Category)34 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)32 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)31 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)28 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)28 Attachment (it.vige.rubia.model.Attachment)25 Test (org.junit.Test)25 Poll (it.vige.rubia.model.Poll)21 Poster (it.vige.rubia.model.Poster)20 PollOption (it.vige.rubia.model.PollOption)19 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)17 Message (it.vige.rubia.model.Message)14 Date (java.util.Date)14 BeforeClass (org.junit.BeforeClass)12 WebElement (org.openqa.selenium.WebElement)12