Search in sources :

Example 1 with Message

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

the class ViewPageTopicSearch method getTopic.

private static Topic getTopic(WebDriver driver, WebElement element) {
    Topic topic = new Topic();
    topic.setSubject(element.findElement(xpath(TOPIC_SUBJECT)).getText());
    topic.setPoster(new Poster(element.findElement(xpath(TOPIC_POSTER)).getText()));
    Post lastPost = new Post();
    Message message = new Message();
    message.setSubject(element.findElement(xpath(LAST_POST_SUBJECT)).getText());
    lastPost.setMessage(message);
    lastPost.setPoster(new Poster(element.findElement(xpath(LAST_POST_POSTER)).getText()));
    String createdDate = element.findElement(xpath(LAST_POST_CREATED_DATE)).getText().split("\n")[2];
    try {
        Date date = dateFormat.parse(createdDate);
        lastPost.setCreateDate(date);
        topic.setLastPostDate(date);
    } catch (ParseException e) {
    }
    topic.getPosts().add(lastPost);
    topic.setReplies(new Integer(element.findElement(xpath(TOPIC_REPLIES)).getText()));
    topic.setViewCount(new Integer(element.findElement(xpath(TOPIC_VIEWS)).getText()));
    return topic;
}
Also used : Message(it.vige.rubia.model.Message) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) ParseException(java.text.ParseException) VerifyPost.getPostsOfCurrentTopic(it.vige.rubia.selenium.forum.action.VerifyPost.getPostsOfCurrentTopic) VerifyTopic(it.vige.rubia.selenium.forum.action.VerifyTopic) Topic(it.vige.rubia.model.Topic) Date(java.util.Date)

Example 2 with Message

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

the class VerifyForum method getForum.

public static Forum getForum(WebDriver driver, WebElement trComponent) {
    Forum forum = new Forum();
    WebElement forumNameComponent = trComponent.findElement(xpath(FORUM_NAME_LINK));
    String forumNameText = forumNameComponent.getText();
    addParents(driver, forum);
    forum.setName(forumNameText);
    forum.setDescription(trComponent.findElement(xpath(DESCRIPTION_OUTPUT_TEXT)).getText().split("\n")[1]);
    WebElement lastPostElement = trComponent.findElement(xpath(LAST_POST));
    if (!lastPostElement.getText().equals(NO_POSTS)) {
        Post lastPost = new Post();
        try {
            lastPost.setCreateDate(dateFormat.parse(lastPostElement.getText().split("\n")[2]));
        } catch (ParseException e) {
            log.error(e);
        }
        String userIdLastPost = lastPostElement.findElement(xpath(LAST_POST_USER_LINK)).getText();
        Poster poster = new Poster();
        poster.setUserId(userIdLastPost);
        lastPost.setPoster(poster);
        User user = new TestUser();
        user.setId(userIdLastPost);
        user.setUserName(userIdLastPost);
        lastPost.setUser(user);
        Message message = new Message();
        message.setSubject(lastPostElement.findElement(xpath(LAST_POST_MESSAGE_LINK)).getText());
        lastPost.setMessage(message);
        forum.setLastPost(lastPost);
    }
    forum.setTopicCount(new Integer(trComponent.findElement(xpath(TOPICS_COUNT_OUTPUT_TEXT)).getText()));
    forum.setPostCount(new Integer(trComponent.findElement(xpath(POSTS_COUNT_OUTPUT_TEXT)).getText()));
    return forum;
}
Also used : TestUser(it.vige.rubia.selenium.forum.model.TestUser) User(it.vige.rubia.auth.User) Message(it.vige.rubia.model.Message) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) ParseException(java.text.ParseException) WebElement(org.openqa.selenium.WebElement) TestUser(it.vige.rubia.selenium.forum.model.TestUser) Forum(it.vige.rubia.model.Forum)

Example 3 with Message

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

the class MyForumsForumTest method verifyAllForumsPost.

@Test
public void verifyAllForumsPost() {
    Post post = new Post();
    Message message = new Message();
    message.setSubject("Second Test Topic");
    post.setMessage(message);
    Topic result = ViewAllForumsSelectPost.selectAllForumsPost(driver, post);
    assertTrue(result != null);
    assertEquals(message.getSubject(), result.getSubject());
    assertEquals("root", result.getPoster().getUserId());
    assertEquals(1, result.getPosts().size());
    assertEquals(message.getSubject(), result.getPosts().get(0).getMessage().getSubject());
    assertEquals("Second Test Body", result.getPosts().get(0).getMessage().getText());
    assertEquals("Second Test Question", result.getPoll().getTitle());
}
Also used : Message(it.vige.rubia.model.Message) ViewAllForumsSelectPost(it.vige.rubia.selenium.myforums.action.ViewAllForumsSelectPost) Post(it.vige.rubia.model.Post) 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) Test(org.junit.Test)

Example 4 with Message

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

the class MyForumsTopicTest method verifyPost.

@Test
public void verifyPost() {
    Post post = new Post();
    Message message = new Message();
    message.setSubject("First Test Topic");
    post.setMessage(message);
    Topic result = ViewAllTopicsSelectPost.selectPost(driver, post);
    assertTrue(result != null);
    assertEquals(1, result.getPosts().size());
    assertEquals("root", result.getPosts().get(0).getPoster().getUserId());
    assertEquals(message.getSubject(), result.getPosts().get(0).getMessage().getSubject());
    assertEquals("First Test Body", result.getPosts().get(0).getMessage().getText());
    assertEquals(message.getSubject(), result.getSubject());
}
Also used : Message(it.vige.rubia.model.Message) ViewAllTopicsSelectPost(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectPost) Post(it.vige.rubia.model.Post) ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) ViewAllTopicsSelectTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectTopic) ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) SubscriptionTopic.registerTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.registerTopic) SubscriptionTopic.unregisterTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.unregisterTopic) Test(org.junit.Test)

Example 5 with Message

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

the class ReplyTopic method execute.

/**
 * Execute
 *
 * @return the navigation state of the application
 */
public String execute() {
    String navState = null;
    boolean success = false;
    try {
        Message message = createMessage();
        message.setText(this.message);
        message.setSubject(subject);
        // setup the forum and the corresponding poster
        Forum forum = forumsModule.findForumById(forumId);
        topic = forumsModule.findTopicById(topicId);
        Poster poster = getPoster(forumsModule, userModule);
        // make sure this topic is not locked
        if (topic.getStatus() == TOPIC_LOCKED) {
            // should not allow posting a reply since the topic is locked
            throw new Exception(getBundleMessage(BUNDLE_NAME, TOPIC_LOCKED_ERR_KEY));
        }
        // actually post a reply to this topic in the forum
        poster.incrementPostCount();
        // attachments
        forumsModule.createPost(// attachments
        topic, // attachments
        forum, // attachments
        message, // attachments
        new Date(), // attachments
        poster, // attachments
        attachments);
        currentTopicPage.setPage(viewTopic.getLastPageNumber());
        // setup the navigation state
        navState = SUCCESS;
        success = true;
    } catch (MessageValidationException e) {
        // handle proper validation error with a proper message...not just a
        // generic message..
        // just use generic error page for the proof of concept
        // set the custom exception such that e.toString() results in the
        // proper message
        handleException(e);
    } catch (PollValidationException e) {
        // handle proper validation error with a proper message...not just a
        // generic message..
        // just use generic error page for the proof of concept
        // set the custom exception such that e.toString() results in the
        // proper message
        handleException(e);
    } catch (Exception e) {
        handleException(e);
    } finally {
        // cleanup if necessary
        if (success) {
            cleanup();
        }
    }
    return navState;
}
Also used : PortalUtil.createMessage(it.vige.rubia.PortalUtil.createMessage) JSFUtil.getBundleMessage(it.vige.rubia.ui.JSFUtil.getBundleMessage) Message(it.vige.rubia.model.Message) PortalUtil.getPoster(it.vige.rubia.PortalUtil.getPoster) Poster(it.vige.rubia.model.Poster) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Date(java.util.Date) Forum(it.vige.rubia.model.Forum) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Aggregations

Message (it.vige.rubia.model.Message)16 Post (it.vige.rubia.model.Post)14 Poster (it.vige.rubia.model.Poster)11 Topic (it.vige.rubia.model.Topic)9 Forum (it.vige.rubia.model.Forum)7 ParseException (java.text.ParseException)6 Date (java.util.Date)6 Test (org.junit.Test)6 ViewAllForumsSelectPost (it.vige.rubia.selenium.myforums.action.ViewAllForumsSelectPost)4 WebElement (org.openqa.selenium.WebElement)4 PortalUtil.createMessage (it.vige.rubia.PortalUtil.createMessage)3 SecureActionForum (it.vige.rubia.auth.SecureActionForum)3 Category (it.vige.rubia.model.Category)3 Poll (it.vige.rubia.model.Poll)3 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)3 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)3 VerifyTopic (it.vige.rubia.selenium.forum.action.VerifyTopic)3 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)3 ArrayList (java.util.ArrayList)3 PortalUtil.createPoll (it.vige.rubia.PortalUtil.createPoll)2