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));
}
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());
}
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));
}
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;
}
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;
}
Aggregations