Search in sources :

Example 31 with PollOption

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

the class SearchPostTest method setUp.

@BeforeClass
public static void setUp() {
    driver.get(HOME_URL);
    String message = createCategory(driver, new Category("First Test Category"));
    assertTrue(message.equals(CREATED_CATEGORY_1_MESSAGE));
    message = createCategory(driver, new Category("Second Test Category"));
    assertTrue(message.equals(CREATED_CATEGORY_2_MESSAGE));
    message = createForum(driver, new Forum("First Test Forum", "First Test Description", new Category("First Test Category")));
    assertTrue(message.equals(CREATED_FORUM_0_MESSAGE));
    message = createTopic(driver, 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)));
    assertTrue(message.equals("First Test Topic"));
    message = registerTopic(driver, new Topic("First Test Topic"), EMAIL_LINKED_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("First Test Topic"));
    message = createTopic(driver, 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)));
    assertTrue(message.equals("Second Test Topic"));
    message = registerTopic(driver, new Topic("Second Test Topic"), EMAIL_EMBEDED_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("Second Test Topic"));
    message = createForum(driver, new Forum("Second Test Forum", "Second Test Description", new Category("First Test Category")));
    assertTrue(message.equals(CREATED_FORUM_1_MESSAGE));
    message = createTopic(driver, 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)));
    assertTrue(message.equals("Third Test Topic"));
    message = registerTopic(driver, new Topic("Third Test Topic"), EMAIL_NO_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("Third Test Topic"));
    message = createTopic(driver, 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)));
    assertTrue(message.equals("Fourth Test Topic"));
    message = registerTopic(driver, new Topic("Fourth Test Topic"), EMAIL_EMBEDED_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("Fourth Test Topic"));
    message = createForum(driver, new Forum("Third Test Forum", "Third Test Description", new Category("Second Test Category")));
    assertTrue(message.equals(CREATED_FORUM_2_MESSAGE));
    message = createTopic(driver, 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", asList(new Attachment("seventh", "Seventh Test File"), new Attachment("eight", "Eight Test File"), new Attachment("ninth", "Ninth Test File"))) }), IMPORTANT, new Poll("Third Test Question", asList(new PollOption[] { new PollOption("Seventh Test Answer"), new PollOption("Eight Test Answer") }), 8)));
    assertTrue(message.equals("Fifth Test with Truncation over 25 characters Topic"));
    message = registerTopic(driver, new Topic("Fifth Test with Truncation over 25 characters Topic"), EMAIL_EMBEDED_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("Fifth Test with Truncation over 25 characters Topic"));
    message = createTopic(driver, new Topic(new Forum("Third Test Forum"), "Sixth Test Topic", asList(new Post[] { new Post("Sixth Test Body", asList(new Attachment("ten", "Ten Test File"), new Attachment("eleven", "Eleven Test File"), new Attachment("twelve", "Twelve Test File"))) }), IMPORTANT, new Poll("Fourth Test Question", asList(new PollOption[] { new PollOption("Ninth Test Answer"), new PollOption("Ten Test Answer") }), 8)));
    assertTrue(message.equals("Sixth Test Topic"));
}
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) Poll(it.vige.rubia.model.Poll) Attachment(it.vige.rubia.model.Attachment) PollOption(it.vige.rubia.model.PollOption) 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) BeforeClass(org.junit.BeforeClass)

Example 32 with PollOption

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

the class CreatePoll method createOptions.

public static String[] createOptions(WebDriver driver, Poll poll) {
    WebElement questionInput = driver.findElement(id(QUESTION_INPUT_TEXT));
    questionInput.sendKeys(poll.getTitle());
    sleepThread();
    List<PollOption> options = poll.getOptions();
    if (options != null)
        for (int i = 0; i < options.size(); i++) {
            WebElement optionInput = null;
            WebElement optionButton = null;
            optionInput = driver.findElement(id(NEW_OPTION_INPUT_TEXT));
            optionInput.sendKeys(options.get(i).getQuestion());
            optionButton = driver.findElements(className(ADD_OPTION_BUTTON)).get(i * 2);
            optionButton.click();
            sleepThread();
        }
    WebElement[] updatedElements = new WebElement[options.size()];
    for (int i = 0; i < options.size(); i++) updatedElements[i] = driver.findElement(xpath("//input[@value='" + options.get(i).getQuestion() + "']"));
    String[] results = new String[updatedElements.length];
    for (int i = 0; i < updatedElements.length; i++) results[i] = updatedElements[i].getAttribute("value");
    return results;
}
Also used : PollOption(it.vige.rubia.model.PollOption) WebElement(org.openqa.selenium.WebElement)

Example 33 with PollOption

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

the class UpdatePoll method deleteOptions.

public static Poll deleteOptions(WebDriver driver, Poll poll) {
    WebElement updateTopicButton = driver.findElements(xpath("//tbody")).get(2).findElement(id(UPDATE_TOPIC_BUTTON)).findElement(xpath("ul/a[1]"));
    updateTopicButton.click();
    List<PollOption> options = poll.getOptions();
    if (options != null)
        for (int i = 0; i < options.size(); i++) {
            WebElement optionButton = null;
            optionButton = driver.findElement(xpath("//input[@value='" + options.get(i).getQuestion() + "']/../input[@value='" + DELETE_OPTION_BUTTON + "']"));
            optionButton.click();
        }
    WebElement submitTopicButton = driver.findElement(id(SUBMIT_TOPIC_BUTTON));
    submitTopicButton.click();
    Poll updatedPoll = getPollOfCurrentTopic(driver);
    return updatedPoll;
}
Also used : Poll(it.vige.rubia.model.Poll) PollOption(it.vige.rubia.model.PollOption) WebElement(org.openqa.selenium.WebElement)

Aggregations

PollOption (it.vige.rubia.model.PollOption)33 Poll (it.vige.rubia.model.Poll)29 Topic (it.vige.rubia.model.Topic)24 Forum (it.vige.rubia.model.Forum)21 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)21 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)20 Post (it.vige.rubia.model.Post)19 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)19 Attachment (it.vige.rubia.model.Attachment)18 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)14 Category (it.vige.rubia.model.Category)12 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)12 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)12 BeforeClass (org.junit.BeforeClass)11 Test (org.junit.Test)9 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)7 CreatePoll.addPoll (it.vige.rubia.selenium.forum.action.CreatePoll.addPoll)6 RemovePoll.removePoll (it.vige.rubia.selenium.forum.action.RemovePoll.removePoll)6 UpdatePoll.updatePoll (it.vige.rubia.selenium.forum.action.UpdatePoll.updatePoll)6 VerifyPoll.getPollOfCurrentTopic (it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic)6