use of it.vige.rubia.model.Message in project rubia-forums by flashboss.
the class ViewPageTopicSearch method getTopic.
private static Topic getTopic(WebDriver driver, WebElement element) {
Topic topic = new Topic();
topic.setSubject(element.findElement(xpath(TOPIC_SUBJECT)).getText());
topic.setPoster(new Poster(element.findElement(xpath(TOPIC_POSTER)).getText()));
Post lastPost = new Post();
Message message = new Message();
message.setSubject(element.findElement(xpath(LAST_POST_SUBJECT)).getText());
lastPost.setMessage(message);
lastPost.setPoster(new Poster(element.findElement(xpath(LAST_POST_POSTER)).getText()));
String createdDate = element.findElement(xpath(LAST_POST_CREATED_DATE)).getText().split("\n")[2];
try {
Date date = dateFormat.parse(createdDate);
lastPost.setCreateDate(date);
topic.setLastPostDate(date);
} catch (ParseException e) {
}
topic.getPosts().add(lastPost);
topic.setReplies(new Integer(element.findElement(xpath(TOPIC_REPLIES)).getText()));
topic.setViewCount(new Integer(element.findElement(xpath(TOPIC_VIEWS)).getText()));
return topic;
}
use of it.vige.rubia.model.Message 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;
}
use of it.vige.rubia.model.Message in project rubia-forums by flashboss.
the class MyForumsForumTest method verifyAllForumsPost.
@Test
public void verifyAllForumsPost() {
Post post = new Post();
Message message = new Message();
message.setSubject("Second Test Topic");
post.setMessage(message);
Topic result = ViewAllForumsSelectPost.selectAllForumsPost(driver, post);
assertTrue(result != null);
assertEquals(message.getSubject(), result.getSubject());
assertEquals("root", result.getPoster().getUserId());
assertEquals(1, result.getPosts().size());
assertEquals(message.getSubject(), result.getPosts().get(0).getMessage().getSubject());
assertEquals("Second Test Body", result.getPosts().get(0).getMessage().getText());
assertEquals("Second Test Question", result.getPoll().getTitle());
}
use of it.vige.rubia.model.Message in project rubia-forums by flashboss.
the class MyForumsTopicTest method verifyPost.
@Test
public void verifyPost() {
Post post = new Post();
Message message = new Message();
message.setSubject("First Test Topic");
post.setMessage(message);
Topic result = ViewAllTopicsSelectPost.selectPost(driver, post);
assertTrue(result != null);
assertEquals(1, result.getPosts().size());
assertEquals("root", result.getPosts().get(0).getPoster().getUserId());
assertEquals(message.getSubject(), result.getPosts().get(0).getMessage().getSubject());
assertEquals("First Test Body", result.getPosts().get(0).getMessage().getText());
assertEquals(message.getSubject(), result.getSubject());
}
use of it.vige.rubia.model.Message in project rubia-forums by flashboss.
the class ReplyTopic method execute.
/**
* Execute
*
* @return the navigation state of the application
*/
public String execute() {
String navState = null;
boolean success = false;
try {
Message message = createMessage();
message.setText(this.message);
message.setSubject(subject);
// setup the forum and the corresponding poster
Forum forum = forumsModule.findForumById(forumId);
topic = forumsModule.findTopicById(topicId);
Poster poster = getPoster(forumsModule, userModule);
// make sure this topic is not locked
if (topic.getStatus() == TOPIC_LOCKED) {
// should not allow posting a reply since the topic is locked
throw new Exception(getBundleMessage(BUNDLE_NAME, TOPIC_LOCKED_ERR_KEY));
}
// actually post a reply to this topic in the forum
poster.incrementPostCount();
// attachments
forumsModule.createPost(// attachments
topic, // attachments
forum, // attachments
message, // attachments
new Date(), // attachments
poster, // attachments
attachments);
currentTopicPage.setPage(viewTopic.getLastPageNumber());
// setup the navigation state
navState = SUCCESS;
success = true;
} catch (MessageValidationException e) {
// handle proper validation error with a proper message...not just a
// generic message..
// just use generic error page for the proof of concept
// set the custom exception such that e.toString() results in the
// proper message
handleException(e);
} catch (PollValidationException e) {
// handle proper validation error with a proper message...not just a
// generic message..
// just use generic error page for the proof of concept
// set the custom exception such that e.toString() results in the
// proper message
handleException(e);
} catch (Exception e) {
handleException(e);
} finally {
// cleanup if necessary
if (success) {
cleanup();
}
}
return navState;
}
Aggregations