Search in sources :

Example 11 with Message

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

the class VerifyPost method getPostsOfCurrentTopic.

public static List<Post> getPostsOfCurrentTopic(WebDriver driver) {
    List<WebElement> postComponents = driver.findElements(className(BODY_OUTPUT_TEXT));
    int postComponentsSize = postComponents.size();
    List<Post> posts = new ArrayList<Post>();
    for (int i = 0; i < postComponentsSize; i++) {
        Post post = new Post();
        WebElement postComponent = driver.findElements(className(BODY_OUTPUT_TEXT)).get(i);
        String body = postComponent.findElement(xpath("p")).getText();
        String post_subject = postComponent.findElement(xpath(POST_SUBJECT_OUTPUT_TEXT)).getText().split(POST_SUBJECT_TEXT)[1];
        String createDateStr = postComponent.findElement(xpath(CREATE_DATE_OUTPUT_TEXT)).getText().split(CREATE_DATE_TEXT)[1];
        Date createDate = null;
        try {
            createDate = dateFormat.parse(createDateStr);
        } catch (ParseException e) {
            log.error(e);
        }
        Message message = new Message();
        message.setSubject(post_subject);
        message.setText(body);
        post.setMessage(message);
        post.setCreateDate(createDate);
        WebElement topicEl = driver.findElement(TOPIC_TEMPLATE_LINK.getValue());
        Topic topic = new Topic(topicEl.getText());
        post.setTopic(topic);
        WebElement forumEl = driver.findElement(FORUM_TEMPLATE_LINK.getValue());
        topic.setForum(new Forum(forumEl.getText()));
        post.setAttachments(getAttachmentsOfCurrentPostInPage(driver, post));
        addParents(driver, post);
        Poster poster = new Poster();
        postComponent = driver.findElements(className(BODY_OUTPUT_TEXT)).get(i);
        poster.setUserId(postComponent.findElement(xpath(USER_LINK)).getText());
        post.setPoster(poster);
        posts.add(post);
    }
    return posts;
}
Also used : Message(it.vige.rubia.model.Message) Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement) Date(java.util.Date) Forum(it.vige.rubia.model.Forum) Poster(it.vige.rubia.model.Poster) ParseException(java.text.ParseException) Topic(it.vige.rubia.model.Topic)

Example 12 with Message

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

the class MyForumsTopicTest method verifyPostProfile.

@Test
public void verifyPostProfile() {
    Post post = new Post();
    Message message = new Message();
    message.setSubject("Fourth Test Topic");
    post.setMessage(message);
    Poster poster = ViewAllTopicsSelectPost.selectProfile(driver, post);
    assertTrue(poster != null);
    assertEquals("root", poster.getUserId());
    assertTrue(poster.getPostCount() >= 6);
}
Also used : Message(it.vige.rubia.model.Message) ViewAllTopicsSelectPost(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectPost) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) Test(org.junit.Test)

Example 13 with Message

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

the class MyForumsForumTest method verifyProfile.

@Test
public void verifyProfile() {
    Post post = new Post();
    Message message = new Message();
    message.setSubject("Second Test Topic");
    post.setMessage(message);
    Poster poster = ViewAllForumsSelectForum.selectProfile(driver, post);
    assertTrue(poster != null);
    assertEquals("root", poster.getUserId());
    assertTrue(poster.getPostCount() >= 12);
}
Also used : Message(it.vige.rubia.model.Message) ViewAllForumsSelectPost(it.vige.rubia.selenium.myforums.action.ViewAllForumsSelectPost) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) Test(org.junit.Test)

Example 14 with Message

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

the class MyForumsForumTest method verifyPost.

@Test
public void verifyPost() {
    Post post = new Post();
    Message message = new Message();
    message.setSubject("Second Test Topic");
    post.setMessage(message);
    Topic result = ViewAllForumsSelectPost.selectPost(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 15 with Message

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

the class MyForumsForumTest method verifyAllForumsProfile.

@Test
public void verifyAllForumsProfile() {
    Post post = new Post();
    Message message = new Message();
    message.setSubject("Fourth Test Topic");
    post.setMessage(message);
    Poster poster = ViewAllForumsSelectForum.selectAllForumsProfile(driver, post);
    assertTrue(poster != null);
    assertEquals("root", poster.getUserId());
    assertTrue(poster.getPostCount() >= 16);
}
Also used : Message(it.vige.rubia.model.Message) ViewAllForumsSelectPost(it.vige.rubia.selenium.myforums.action.ViewAllForumsSelectPost) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) Test(org.junit.Test)

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