use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class SearchPostTest method verifyPostProfileFromTopicPageButton.
@Test
public void verifyPostProfileFromTopicPageButton() {
goTo(driver);
SearchCriteria searchTopicCriteria = new SearchCriteria();
searchTopicCriteria.setAuthor("root");
searchTopicCriteria.setCategory(null);
searchTopicCriteria.setDisplayAs(POSTS.name());
searchTopicCriteria.setForum(null);
searchTopicCriteria.setKeywords("Body");
searchTopicCriteria.setPageNumber(0);
searchTopicCriteria.setPageSize(0);
searchTopicCriteria.setSearching(null);
searchTopicCriteria.setSortBy(null);
searchTopicCriteria.setSortOrder(null);
searchTopicCriteria.setTimePeriod(null);
List<Post> posts = searchPost(driver, searchTopicCriteria);
Post post = posts.get(3);
Poster poster = getPosterFromButton(driver, post);
assertTrue(poster != null);
assertEquals("root", poster.getUserId());
assertTrue(poster.getPostCount() >= 6);
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class SearchPostTest method verifyPostProfileFromTopicPage.
@Test
public void verifyPostProfileFromTopicPage() {
goTo(driver);
SearchCriteria searchTopicCriteria = new SearchCriteria();
searchTopicCriteria.setAuthor("root");
searchTopicCriteria.setCategory(null);
searchTopicCriteria.setDisplayAs(POSTS.name());
searchTopicCriteria.setForum(null);
searchTopicCriteria.setKeywords("Body");
searchTopicCriteria.setPageNumber(0);
searchTopicCriteria.setPageSize(0);
searchTopicCriteria.setSearching(null);
searchTopicCriteria.setSortBy(null);
searchTopicCriteria.setSortOrder(null);
searchTopicCriteria.setTimePeriod(null);
List<Post> posts = searchPost(driver, searchTopicCriteria);
Post post = posts.get(2);
Poster poster = getPosterFromLink(driver, post);
assertTrue(poster != null);
assertEquals("root", poster.getUserId());
assertTrue(poster.getPostCount() >= 6);
}
use of it.vige.rubia.model.Poster 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.Poster in project rubia-forums by flashboss.
the class MyForumsTopicTest method verifyProfile.
@Test
public void verifyProfile() {
Topic topic = new Topic(new Forum("First Test Forum"), "First Test Topic", asList(new Post[] { new Post("First Test Body") }));
Poster poster = ViewAllTopicsSelectTopic.selectProfile(driver, topic);
assertTrue(poster != null);
assertEquals("root", poster.getUserId());
assertTrue(poster.getPostCount() >= 6);
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class PollController method vote.
/**
* accepts a vote and processes it
*
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String vote() {
String navState = null;
try {
String t = getParameter(p_topicId);
String vote = getParameter(p_vote);
if (t != null && t.trim().length() > 0) {
// setup the data needed for this process
int topicId, voteIndex;
try {
topicId = parseInt(t);
voteIndex = parseInt(vote);
} catch (NumberFormatException e) {
// dont process a vote
return null;
}
Topic topic = forumsModule.findTopicById(topicId);
Poll poll = topic.getPoll();
PollOption selectedOption = poll.getOptions().get(voteIndex);
Poster poster = getPoster(userModule, forumsModule);
// perform the voting on the selected option
if (poster != null) {
poll.getVoted().add(poster.getUserId());
}
selectedOption.incVotes();
forumsModule.update(selectedOption);
}
} catch (Exception e) {
handleException(e);
}
return navState;
}
Aggregations