Search in sources :

Example 11 with Forum

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

the class ModerateForumTest method lock.

@Test
public void lock() {
    Forum forum = new Forum("Third Test Forum");
    forum.setTopics(asList(new Topic[] { new Topic("Fifth Test with Truncation over 25 characters Topic") }));
    goToModerate(driver, forum);
    String message = lockForum(driver, null);
    assertTrue(message.equals(NOT_SELECTED_MESSAGE));
    message = lockForum(driver, forum);
    assertTrue(message.equals(LOCKED_FORUM_MESSAGE));
    message = unlockForum(driver, forum);
    assertTrue(message.equals(NOT_SELECTED_MESSAGE));
    message = unlockForum(driver, forum);
    assertTrue(message.equals(UNLOCKED_FORUM_MESSAGE));
}
Also used : CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) VerifyTopic.verifyTopic(it.vige.rubia.selenium.moderate.action.VerifyTopic.verifyTopic) Forum(it.vige.rubia.model.Forum) LockForum.lockForum(it.vige.rubia.selenium.moderate.action.LockForum.lockForum) MoveForum.moveForum(it.vige.rubia.selenium.moderate.action.MoveForum.moveForum) CreateForum.createForum(it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum) RemoveForum.removeForum(it.vige.rubia.selenium.moderate.action.RemoveForum.removeForum) LockForum.unlockForum(it.vige.rubia.selenium.moderate.action.LockForum.unlockForum) Test(org.junit.Test)

Example 12 with Forum

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

the class ModerateForumTest method move.

@Test
public void move() {
    Forum forum = new Forum("First Test Forum");
    forum.setTopics(asList(new Topic[] { new Topic("Second Test Topic") }));
    goToModerate(driver, forum);
    String message = moveForum(driver, CONFIRM, null, null);
    assertTrue(message.equals(NOT_SELECTED_MESSAGE));
    message = moveForum(driver, CANCEL, forum, null);
    assertTrue(message.equals(""));
    message = moveForum(driver, CONFIRM, forum, null);
    assertTrue(message.equals(NOT_SELECTED_MESSAGE));
    message = moveForum(driver, CONFIRM, forum, null);
    assertTrue(message.equals(NO_DEST_FORUM_MESSAGE));
    message = moveForum(driver, CONFIRM, forum, null);
    assertTrue(message.equals(NOT_SELECTED_MESSAGE));
    Forum destForum = new Forum("Second Test Forum");
    message = moveForum(driver, CONFIRM, forum, destForum);
    assertTrue(message.equals(MOVED_FORUM_MESSAGE));
    goToModerate(driver, destForum);
    destForum.setTopics(asList(new Topic[] { new Topic("Second Test Topic") }));
    Topic verifiedTopic = verifyTopic(driver, destForum.getTopics().get(0));
    assertNotNull(verifiedTopic);
    assertEquals("Second Test Topic", verifiedTopic.getSubject());
    assertEquals("root", verifiedTopic.getPoster().getUserId());
    assertEquals(1, verifiedTopic.getPosts().size());
    assertEquals("Second Test Topic", verifiedTopic.getPosts().get(0).getMessage().getSubject());
    assertEquals("Second Test Body", verifiedTopic.getPosts().get(0).getMessage().getText());
    assertEquals("Second Test Question", verifiedTopic.getPoll().getTitle());
    goToModerate(driver, destForum);
    message = moveForum(driver, CONFIRM, destForum, forum);
    assertTrue(message.equals(MOVED_FORUM_MESSAGE));
    goToModerate(driver, forum);
    verifiedTopic = verifyTopic(driver, forum.getTopics().get(0));
    assertNotNull(verifiedTopic);
    assertEquals("Second Test Topic", verifiedTopic.getSubject());
    assertEquals("root", verifiedTopic.getPoster().getUserId());
    assertEquals(1, verifiedTopic.getPosts().size());
    assertEquals("Second Test Topic", verifiedTopic.getPosts().get(0).getMessage().getSubject());
    assertEquals("Second Test Body", verifiedTopic.getPosts().get(0).getMessage().getText());
    assertEquals("Second Test Question", verifiedTopic.getPoll().getTitle());
}
Also used : CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) VerifyTopic.verifyTopic(it.vige.rubia.selenium.moderate.action.VerifyTopic.verifyTopic) Forum(it.vige.rubia.model.Forum) LockForum.lockForum(it.vige.rubia.selenium.moderate.action.LockForum.lockForum) MoveForum.moveForum(it.vige.rubia.selenium.moderate.action.MoveForum.moveForum) CreateForum.createForum(it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum) RemoveForum.removeForum(it.vige.rubia.selenium.moderate.action.RemoveForum.removeForum) LockForum.unlockForum(it.vige.rubia.selenium.moderate.action.LockForum.unlockForum) Test(org.junit.Test)

Example 13 with Forum

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

the class SearchPostTest 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") }));
    String message = unregisterTopic(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") }));
    message = unregisterTopic(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") }));
    message = unregisterTopic(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") }));
    message = viewAllTopicsRemoveTopic(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    topic = new Topic(new Forum("Third Test Forum"), "Fifth Test with Truncation over 25 characters Topic", asList(new Post[] { new Post("Fifth Test with Truncation over 25 characters Body") }));
    message = viewAllTopicsRemoveTopic(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    topic = new Topic(new Forum("Third Test Forum"), "Sixth Test Topic", asList(new Post[] { new Post("Sixth Test Body") }));
    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 = removeForum(driver, new Forum("Third Test Forum"), SELECT_FORUM_TYPE);
    assertTrue(message.equals(REMOVED_FORUM_2_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) ViewPagePostSearch.searchPost(it.vige.rubia.selenium.search.action.ViewPagePostSearch.searchPost) Post(it.vige.rubia.model.Post) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) 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) AfterClass(org.junit.AfterClass)

Example 14 with Forum

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

the class VerifyForum method getForumsOfCategories.

public static List<Forum> getForumsOfCategories(WebDriver driver, Category... categories) {
    List<Forum> forums = new ArrayList<Forum>();
    for (Category category : categories) {
        WebElement home = driver.findElement(linkText(HOME_LINK));
        home.click();
        WebElement categoryEl = driver.findElement(linkText(category.getTitle()));
        categoryEl.click();
        WebElement tableComponent = driver.findElement(className(FORUM_TABLE));
        List<WebElement> trComponents = tableComponent.findElements(xpath(FORUM_TR));
        int trComponentSize = trComponents.size();
        for (int i = 2; i < trComponentSize; i++) {
            tableComponent = driver.findElement(className(FORUM_TABLE));
            trComponents = tableComponent.findElements(xpath(FORUM_TR));
            WebElement trComponent = trComponents.get(i);
            Forum forum = getForum(driver, trComponent);
            forums.add(forum);
            driver.findElement(linkText(category.getTitle())).click();
        }
    }
    return forums;
}
Also used : Category(it.vige.rubia.model.Category) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement) Forum(it.vige.rubia.model.Forum)

Example 15 with Forum

use of it.vige.rubia.model.Forum 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

Forum (it.vige.rubia.model.Forum)100 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)65 Topic (it.vige.rubia.model.Topic)63 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)55 Post (it.vige.rubia.model.Post)52 Category (it.vige.rubia.model.Category)50 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)49 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)40 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)40 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)34 Test (org.junit.Test)33 Poll (it.vige.rubia.model.Poll)23 Attachment (it.vige.rubia.model.Attachment)21 PollOption (it.vige.rubia.model.PollOption)21 SecureActionForum (it.vige.rubia.auth.SecureActionForum)16 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)15 Poster (it.vige.rubia.model.Poster)14 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)14 BeforeClass (org.junit.BeforeClass)14 AfterClass (org.junit.AfterClass)13