Search in sources :

Example 66 with Post

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

the class VerifyAttachment method addParents.

private static void addParents(WebDriver driver, Attachment attachment) {
    Post post = new Post();
    Message message = new Message();
    message.setSubject(driver.findElement(POST_TEMPLATE_LINK.getValue()).getText());
    post.setMessage(message);
    Topic topic = new Topic();
    topic.setSubject(driver.findElement(TOPIC_TEMPLATE_LINK.getValue()).getText());
    post.setTopic(topic);
    Forum forum = new Forum();
    forum.setName(driver.findElement(FORUM_TEMPLATE_LINK.getValue()).getText());
    topic.setForum(forum);
    Category category = new Category();
    category.setTitle(driver.findElement(CATEGORY_TEMPLATE_LINK.getValue()).getText());
    forum.setCategory(category);
    attachment.setPost(post);
}
Also used : Category(it.vige.rubia.model.Category) Message(it.vige.rubia.model.Message) Post(it.vige.rubia.model.Post) Topic(it.vige.rubia.model.Topic) Forum(it.vige.rubia.model.Forum)

Example 67 with Post

use of it.vige.rubia.model.Post 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 68 with Post

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

the class VerifyPost method getPostsOfTopics.

public static List<Post> getPostsOfTopics(WebDriver driver, Topic... topics) {
    List<Post> posts = new ArrayList<Post>();
    WebElement home = driver.findElement(linkText(HOME_LINK));
    home.click();
    WebElement tableComponent = driver.findElement(className(FORUM_TABLE));
    List<WebElement> forumSubjectComponents = tableComponent.findElements(xpath(FORUM_SUBJECT));
    int forumComponentSize = forumSubjectComponents.size();
    for (int j = 0; j < forumComponentSize; j++) {
        home = driver.findElement(linkText(HOME_LINK));
        home.click();
        tableComponent = driver.findElement(className(FORUM_TABLE));
        forumSubjectComponents = tableComponent.findElements(xpath(FORUM_SUBJECT));
        WebElement forumEl = forumSubjectComponents.get(j);
        forumEl.click();
        List<WebElement> subjectComponents = driver.findElements(xpath(SUBJECT_LINK));
        int subjectComponentsSize = subjectComponents.size();
        for (int i = 0; i < subjectComponentsSize; i++) {
            subjectComponents = driver.findElements(xpath(SUBJECT_LINK));
            List<String> topicNames = findTopicNames(topics);
            if (topicNames.contains(subjectComponents.get(i).getText())) {
                subjectComponents = driver.findElements(xpath(SUBJECT_LINK));
                WebElement subjectComponent = subjectComponents.get(i);
                subjectComponent.click();
                posts.addAll(getPostsOfCurrentTopic(driver));
                String forumLinkText = driver.findElement(id(FORUM_LINK)).getText();
                driver.findElement(linkText(forumLinkText)).click();
            }
        }
    }
    return posts;
}
Also used : Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement)

Example 69 with Post

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

the class VerifyPost method getLastPostOfCurrentForum.

public static Post getLastPostOfCurrentForum(WebDriver driver, Topic topic) {
    WebElement postComponent = driver.findElements(className(PROFILE_LINK)).get(0).findElement(xpath("../tr/td/a[contains(text(),'" + topic.getSubject() + "')]")).findElement(xpath("../a"));
    postComponent.click();
    List<Post> posts = getPostsOfCurrentTopic(driver);
    return posts.get(posts.size() - 1);
}
Also used : Post(it.vige.rubia.model.Post) WebElement(org.openqa.selenium.WebElement)

Example 70 with Post

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

the class OperationPollTest method stop.

@AfterClass
public static void stop() {
    Topic topic = new Topic(new Forum("First Test Forum"), "First Test Topic", asList(new Post[] { new Post("First Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), NORMAL, new Poll("First Test Question", asList(new PollOption[] { new PollOption("First Test Answer"), new PollOption("Second Test Answer") }), 4));
    String message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    topic = new Topic(new Forum("First Test Forum"), "Second Test Topic", asList(new Post[] { new Post("Second Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), IMPORTANT, new Poll("Second Test Question", asList(new PollOption[] { new PollOption("Third Test Answer"), new PollOption("Fourth Test Answer") }), 8));
    message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    topic = new Topic(new Forum("Second Test Forum"), "Third Test Topic", asList(new Post[] { new Post("Third Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), ADVICE, new Poll("Third Test Question", asList(new PollOption[] { new PollOption("Fifth Test with Truncation over 25 characters Answer"), new PollOption("Sixth Test Answer") }), 9));
    message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    topic = new Topic(new Forum("Second Test Forum"), "Fourth Test Topic", asList(new Post[] { new Post("Fourth Test Body", asList(new Attachment("fourth", "Fourth Test File"), new Attachment("fifth", "Fifth Test with Truncation over 25 characters File"), new Attachment("sixth", "Sixth Test File"))) }), IMPORTANT, new Poll("Fourth Test Question", asList(new PollOption[] { new PollOption("Seventh Test Answer"), new PollOption("Eight Test Answer") }), 0));
    message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    message = removeForum(driver, new Forum("First Test Forum"), "Second Test Forum");
    assertTrue(message.equals(REMOVED_FORUM_0_MESSAGE));
    message = removeForum(driver, new Forum("Second Test Forum"), SELECT_FORUM_TYPE);
    assertTrue(message.equals(REMOVED_FORUM_1_MESSAGE));
    message = removeCategory(driver, new Category("First Test Category"), SELECT_CATEGORY_TYPE);
    assertTrue(message.equals(REMOVED_CATEGORY_0_MESSAGE));
    message = removeCategory(driver, new Category("Second Test Category"), SELECT_CATEGORY_TYPE);
    assertTrue(message.equals(REMOVED_CATEGORY_1_MESSAGE));
}
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) Post(it.vige.rubia.model.Post) UpdatePoll.updatePoll(it.vige.rubia.selenium.forum.action.UpdatePoll.updatePoll) Poll(it.vige.rubia.model.Poll) RemovePoll.removePoll(it.vige.rubia.selenium.forum.action.RemovePoll.removePoll) CreatePoll.addPoll(it.vige.rubia.selenium.forum.action.CreatePoll.addPoll) Attachment(it.vige.rubia.model.Attachment) PollOption(it.vige.rubia.model.PollOption) 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) VerifyPoll.getPollOfCurrentTopic(it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic) Forum(it.vige.rubia.model.Forum) RemoveForum.removeForum(it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum) CreateForum.createForum(it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum) AfterClass(org.junit.AfterClass)

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