Search in sources :

Example 6 with Poster

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

the class SearchPostTest method verifyPostProfileFromTopicPageButton.

@Test
public void verifyPostProfileFromTopicPageButton() {
    goTo(driver);
    SearchCriteria searchTopicCriteria = new SearchCriteria();
    searchTopicCriteria.setAuthor("root");
    searchTopicCriteria.setCategory(null);
    searchTopicCriteria.setDisplayAs(POSTS.name());
    searchTopicCriteria.setForum(null);
    searchTopicCriteria.setKeywords("Body");
    searchTopicCriteria.setPageNumber(0);
    searchTopicCriteria.setPageSize(0);
    searchTopicCriteria.setSearching(null);
    searchTopicCriteria.setSortBy(null);
    searchTopicCriteria.setSortOrder(null);
    searchTopicCriteria.setTimePeriod(null);
    List<Post> posts = searchPost(driver, searchTopicCriteria);
    Post post = posts.get(3);
    Poster poster = getPosterFromButton(driver, post);
    assertTrue(poster != null);
    assertEquals("root", poster.getUserId());
    assertTrue(poster.getPostCount() >= 6);
}
Also used : ViewPagePostSearch.searchPost(it.vige.rubia.selenium.search.action.ViewPagePostSearch.searchPost) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) SearchCriteria(it.vige.rubia.search.SearchCriteria) Test(org.junit.Test)

Example 7 with Poster

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

the class SearchPostTest method verifyPostProfileFromTopicPage.

@Test
public void verifyPostProfileFromTopicPage() {
    goTo(driver);
    SearchCriteria searchTopicCriteria = new SearchCriteria();
    searchTopicCriteria.setAuthor("root");
    searchTopicCriteria.setCategory(null);
    searchTopicCriteria.setDisplayAs(POSTS.name());
    searchTopicCriteria.setForum(null);
    searchTopicCriteria.setKeywords("Body");
    searchTopicCriteria.setPageNumber(0);
    searchTopicCriteria.setPageSize(0);
    searchTopicCriteria.setSearching(null);
    searchTopicCriteria.setSortBy(null);
    searchTopicCriteria.setSortOrder(null);
    searchTopicCriteria.setTimePeriod(null);
    List<Post> posts = searchPost(driver, searchTopicCriteria);
    Post post = posts.get(2);
    Poster poster = getPosterFromLink(driver, post);
    assertTrue(poster != null);
    assertEquals("root", poster.getUserId());
    assertTrue(poster.getPostCount() >= 6);
}
Also used : ViewPagePostSearch.searchPost(it.vige.rubia.selenium.search.action.ViewPagePostSearch.searchPost) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) SearchCriteria(it.vige.rubia.search.SearchCriteria) Test(org.junit.Test)

Example 8 with Poster

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

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

the class MyForumsTopicTest method verifyProfile.

@Test
public void verifyProfile() {
    Topic topic = new Topic(new Forum("First Test Forum"), "First Test Topic", asList(new Post[] { new Post("First Test Body") }));
    Poster poster = ViewAllTopicsSelectTopic.selectProfile(driver, topic);
    assertTrue(poster != null);
    assertEquals("root", poster.getUserId());
    assertTrue(poster.getPostCount() >= 6);
}
Also used : ViewAllTopicsSelectPost(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectPost) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) 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) 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) Test(org.junit.Test)

Example 10 with Poster

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

the class PollController method vote.

/**
 * accepts a vote and processes it
 *
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String vote() {
    String navState = null;
    try {
        String t = getParameter(p_topicId);
        String vote = getParameter(p_vote);
        if (t != null && t.trim().length() > 0) {
            // setup the data needed for this process
            int topicId, voteIndex;
            try {
                topicId = parseInt(t);
                voteIndex = parseInt(vote);
            } catch (NumberFormatException e) {
                // dont process a vote
                return null;
            }
            Topic topic = forumsModule.findTopicById(topicId);
            Poll poll = topic.getPoll();
            PollOption selectedOption = poll.getOptions().get(voteIndex);
            Poster poster = getPoster(userModule, forumsModule);
            // perform the voting on the selected option
            if (poster != null) {
                poll.getVoted().add(poster.getUserId());
            }
            selectedOption.incVotes();
            forumsModule.update(selectedOption);
        }
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : JSFUtil.getPoster(it.vige.rubia.ui.JSFUtil.getPoster) Poster(it.vige.rubia.model.Poster) Poll(it.vige.rubia.model.Poll) PollOption(it.vige.rubia.model.PollOption) Topic(it.vige.rubia.model.Topic) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Aggregations

Poster (it.vige.rubia.model.Poster)46 Post (it.vige.rubia.model.Post)20 WebElement (org.openqa.selenium.WebElement)18 Topic (it.vige.rubia.model.Topic)17 Forum (it.vige.rubia.model.Forum)14 Test (org.junit.Test)13 Message (it.vige.rubia.model.Message)11 ParseException (java.text.ParseException)10 Category (it.vige.rubia.model.Category)7 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)7 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)7 Date (java.util.Date)7 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)6 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)6 NoResultException (javax.persistence.NoResultException)6 NonUniqueResultException (javax.persistence.NonUniqueResultException)6 VerifyPost.getLastPostOfCurrentForum (it.vige.rubia.selenium.forum.action.VerifyPost.getLastPostOfCurrentForum)5 VerifyTopic (it.vige.rubia.selenium.forum.action.VerifyTopic)5 VerifyTopic.getPoster (it.vige.rubia.selenium.forum.action.VerifyTopic.getPoster)5 DateFormat (java.text.DateFormat)5