Search in sources :

Example 1 with TestUser

use of it.vige.rubia.selenium.forum.model.TestUser 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)

Aggregations

User (it.vige.rubia.auth.User)1 Forum (it.vige.rubia.model.Forum)1 Message (it.vige.rubia.model.Message)1 Post (it.vige.rubia.model.Post)1 Poster (it.vige.rubia.model.Poster)1 TestUser (it.vige.rubia.selenium.forum.model.TestUser)1 ParseException (java.text.ParseException)1 WebElement (org.openqa.selenium.WebElement)1