Search in sources :

Example 56 with Category

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

the class ViewAtomLink method getPage.

public static Forum getPage(WebDriver driver, Forum forum) {
    VerifyForum.goTo(driver, forum);
    goTo(driver);
    Forum result = new Forum();
    result.setName(driver.findElement(id(FEED_TITLE_TEXT)).getText().split(": ")[1]);
    result.setCategory(new Category(driver.findElement(id(FEED_SUBTITLE_TEXT)).getText().split(" in category ")[1]));
    Map<String, Topic> topics = new HashMap<String, Topic>();
    int entriesSize = driver.findElements(className(ENTRY_LINK)).size();
    DateFormat dateFormat = new SimpleDateFormat("d MMM yyyy, HH:mm");
    for (int i = 0; i < entriesSize; i++) {
        WebElement entry = driver.findElements(className(ENTRY_LINK)).get(i);
        String[] entryText = entry.getText().split(BY);
        String lastUpdated = entry.findElement(className(LAST_UPDATED)).getText();
        String topicTitle = entryText[0].replace(RE, "");
        Topic topic = topics.get(topicTitle);
        if (topic == null) {
            topic = new Topic(topicTitle);
            topics.put(topicTitle, topic);
        }
        Post post = new Post(entry.findElement(className(FEED_ENTRY_CONTENT)).getText());
        post.setPoster(new Poster(entryText[1].split("\n")[0]));
        try {
            post.setCreateDate(dateFormat.parse(lastUpdated));
        } catch (ParseException e) {
        }
        post.getMessage().setSubject(entryText[0]);
        topic.getPosts().add(post);
        WebElement entryLink = driver.findElement(linkText(entry.getText().split("\n")[0]));
        entryLink.click();
        List<Attachment> attachments = getAttachmentsOfCurrentPostInPage(driver, post);
        post.setAttachments(attachments);
        if (topic.getPoll() == null) {
            Poll poll = getPollOfCurrentTopic(driver);
            topic.setPoll(poll);
        }
        VerifyForum.goTo(driver, forum);
        goTo(driver);
    }
    result.setTopics(new ArrayList<Topic>(topics.values()));
    returnToHome(driver);
    return result;
}
Also used : Category(it.vige.rubia.model.Category) HashMap(java.util.HashMap) Post(it.vige.rubia.model.Post) Attachment(it.vige.rubia.model.Attachment) WebElement(org.openqa.selenium.WebElement) Forum(it.vige.rubia.model.Forum) VerifyForum(it.vige.rubia.selenium.forum.action.VerifyForum) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Poster(it.vige.rubia.model.Poster) Poll(it.vige.rubia.model.Poll) ParseException(java.text.ParseException) VerifyTopic(it.vige.rubia.selenium.forum.action.VerifyTopic) Topic(it.vige.rubia.model.Topic) VerifyPoll.getPollOfCurrentTopic(it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic) SimpleDateFormat(java.text.SimpleDateFormat)

Example 57 with Category

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

the class AdminPanelForumTest method verifyUpdateForum.

@Test
public void verifyUpdateForum() {
    String message = updateForum(driver, new Forum("Second Test Forum"), new Forum("Third Test Forum", "Third Test Description", new Category("Second Test Category")));
    assertTrue(message.equals(UPDATED_FORUM_1_MESSAGE));
    message = updateForum(driver, new Forum("Third Test Forum"), new Forum("Second Test Forum", "First Test Description", new Category("First Test Category")));
    assertTrue(message.equals(UPDATED_FORUM_0_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) 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) MoveForum.moveForum(it.vige.rubia.selenium.adminpanel.action.MoveForum.moveForum) UpdateForum.updateForum(it.vige.rubia.selenium.adminpanel.action.UpdateForum.updateForum) LockForum.lockForum(it.vige.rubia.selenium.adminpanel.action.LockForum.lockForum) Test(org.junit.Test)

Example 58 with Category

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

the class AdminPanelForumTest method stop.

@AfterClass
public static void stop() {
    String 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"), AdminPanelCategoryTest.SELECT_CATEGORY_TYPE);
    assertTrue(message.equals(REMOVED_CATEGORY_0_MESSAGE));
    message = removeCategory(driver, new Category("Second Test Category"), AdminPanelCategoryTest.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) 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) MoveForum.moveForum(it.vige.rubia.selenium.adminpanel.action.MoveForum.moveForum) UpdateForum.updateForum(it.vige.rubia.selenium.adminpanel.action.UpdateForum.updateForum) LockForum.lockForum(it.vige.rubia.selenium.adminpanel.action.LockForum.lockForum) AfterClass(org.junit.AfterClass)

Example 59 with Category

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

the class AdminPanelForumTest 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 = createForum(driver, new Forum("Second Test Forum", "Second Test Description", new Category("First Test Category")));
    assertTrue(message.equals(CREATED_FORUM_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) 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) MoveForum.moveForum(it.vige.rubia.selenium.adminpanel.action.MoveForum.moveForum) UpdateForum.updateForum(it.vige.rubia.selenium.adminpanel.action.UpdateForum.updateForum) LockForum.lockForum(it.vige.rubia.selenium.adminpanel.action.LockForum.lockForum) BeforeClass(org.junit.BeforeClass)

Example 60 with Category

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

the class VerifyTopic method addParents.

private static void addParents(WebDriver driver, Topic topic) {
    Forum forum = new Forum();
    forum.setName(driver.findElement(linkText(driver.findElement(FORUM_TEMPLATE_LINK.getValue()).getText())).getText());
    topic.setForum(forum);
    Category category = new Category();
    category.setTitle(driver.findElement(CATEGORY_TEMPLATE_LINK.getValue()).getText());
    forum.setCategory(category);
}
Also used : Category(it.vige.rubia.model.Category) Forum(it.vige.rubia.model.Forum)

Aggregations

Category (it.vige.rubia.model.Category)71 Forum (it.vige.rubia.model.Forum)50 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)48 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)48 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)40 Topic (it.vige.rubia.model.Topic)36 Post (it.vige.rubia.model.Post)34 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)32 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)30 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)24 AfterClass (org.junit.AfterClass)16 BeforeClass (org.junit.BeforeClass)16 Attachment (it.vige.rubia.model.Attachment)15 Poll (it.vige.rubia.model.Poll)14 PollOption (it.vige.rubia.model.PollOption)12 Test (org.junit.Test)11 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)8 Poster (it.vige.rubia.model.Poster)7 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)7 ModuleException (it.vige.rubia.ModuleException)6