use of org.mamute.model.Question in project mamute by caelum.
the class AnswerTest method return_true_if_answer_has_pending_edits.
@Test
public void return_true_if_answer_has_pending_edits() throws Exception {
Question myQuestion = question.withTitle("question title").withDescription("description").withAuthor(author).build();
Answer answer = answer("blablablab", myQuestion, author);
assertFalse(answer.hasPendingEdits());
AnswerInformation approved = new AnswerInformation(notMarked("blablabalblab"), new LoggedUser(editUser, null), answer, "");
answer.enqueueChange(approved, PENDING);
assertTrue(answer.hasPendingEdits());
}
use of org.mamute.model.Question in project mamute by caelum.
the class AnswerTest method should_mark_question_as_solved.
@Test
public void should_mark_question_as_solved() {
Question canILiveForever = question.build();
Answer yes = answer("Yes", canILiveForever, null);
assertEquals(null, canILiveForever.getSolution());
yes.markAsSolution();
assertEquals(yes, canILiveForever.getSolution());
}
use of org.mamute.model.Question in project mamute by caelum.
the class FlagController method topFlagged.
@CustomBrutauthRules(ModeratorOnlyRule.class)
@Get
public void topFlagged() {
List<FlaggableAndFlagCount> flaggedQuestions = flaggables.flaggedButVisible(Question.class);
List<FlaggableAndFlagCount> flaggedAnswers = flaggables.flaggedButVisible(Answer.class);
List<FlaggableAndFlagCount> flaggedComments = flaggables.flaggedButVisible(Comment.class);
List<Question> commentQuestions = new ArrayList<>();
Iterator<FlaggableAndFlagCount> iterator = flaggedComments.iterator();
while (iterator.hasNext()) {
Comment comment = (Comment) iterator.next().getFlaggable();
Question q = questions.fromCommentId(comment.getId());
if (q != null) {
commentQuestions.add(q);
continue;
}
Answer answerFromComment = answers.fromCommentId(comment.getId());
if (answerFromComment != null) {
commentQuestions.add(answerFromComment.getQuestion());
continue;
}
// some flags may be related to news (not questions nor answers)
iterator.remove();
}
result.include("questions", flaggedQuestions);
result.include("answers", flaggedAnswers);
result.include("comments", flaggedComments);
result.include("commentQuestions", commentQuestions);
}
use of org.mamute.model.Question in project mamute by caelum.
the class VoteUpDownTest method login.
@Before
public void login() {
DaoManager manager = new DaoManager();
User author = manager.randomUser();
Question question = manager.createQuestion(author);
manager.answerQuestion(author, question);
loginWithALotOfKarma();
questionPage = home().toFirstQuestionPage();
}
use of org.mamute.model.Question in project mamute by caelum.
the class CommentAnswerTest method should_comment_answer_after_login.
@Test
public void should_comment_answer_after_login() throws Exception {
User moderator = moderator();
Question question = createQuestionWithDao(moderator, "Should comment answer after login", "Yeah, definitely should, who're you to say otherwise?", tag("java"));
Answer answer = answerQuestionWithDao(karmaNigga(), question, "I'm de guy with lots of karma, nigga! So get over here!", false);
String comment = "Oh, right, then I can't do a thing about it.";
UserFlow navigation = login(navigate(), moderator.getEmail());
navigation = commentWithFlow(navigation, answer, comment, false);
VRaptorTestResult commentResult = navigation.followRedirect().execute();
// COULD NOT COMPILE JSP
commentResult.wasStatus(200).isValid();
navigation = login(navigate(), moderator.getEmail());
navigation = goToQuestionPage(navigation, question);
VRaptorTestResult commentedAnswer = navigation.followRedirect().execute();
commentedAnswer.wasStatus(200).isValid();
Elements commentElement = getElementsByClass(commentedAnswer.getResponseBody(), "comment-container");
Elements commentSpan = getElementsByTag(commentElement.html(), "span");
Elements commentParagraph = getElementsByTag(commentSpan.html(), "p");
assertEquals(comment, commentParagraph.html());
}
Aggregations