use of org.mamute.model.Comment in project mamute by caelum.
the class RemoveAnythingFlaggedByModeratorTest method should_not_handle_not_logged_user.
@Test
public void should_not_handle_not_logged_user() throws Exception {
RemoveAnythingFlaggedByModerator removeFlaggedByModerator = new RemoveAnythingFlaggedByModerator(new LoggedUser(null, null));
Comment comment = comment(author, "blablablablba");
assertFalse(removeFlaggedByModerator.shouldHandle(comment));
assertTrue(comment.isVisible());
}
use of org.mamute.model.Comment in project mamute by caelum.
the class RemoveAnythingFlaggedByModeratorTest method should_remove_comment_after_moderator_flag.
@Test
public void should_remove_comment_after_moderator_flag() {
RemoveAnythingFlaggedByModerator removeFlaggedByModerator = new RemoveAnythingFlaggedByModerator(new LoggedUser(user, null));
Comment comment = comment(author, "blablablablba");
removeFlaggedByModerator.fire(comment);
assertFalse(comment.isVisible());
}
use of org.mamute.model.Comment in project mamute by caelum.
the class RemoveAnythingFlaggedByModeratorTest method should_not_handle_normal_user.
@Test
public void should_not_handle_normal_user() throws Exception {
User normal = user("normal", "normal@brutal.com");
RemoveAnythingFlaggedByModerator removeFlaggedByModerator = new RemoveAnythingFlaggedByModerator(new LoggedUser(normal, null));
Comment comment = comment(author, "blablablablba");
assertFalse(removeFlaggedByModerator.shouldHandle(comment));
assertTrue(comment.isVisible());
}
use of org.mamute.model.Comment 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.Comment in project mamute by caelum.
the class AnswerDAO method delete.
public void delete(Answer answer) {
answer.getQuestion().subtractAnswer();
session.delete(answer);
for (Comment comment : answer.getAllComments()) {
session.delete(comment);
}
}
Aggregations