Search in sources :

Example 6 with Comment

use of org.mamute.model.Comment in project mamute by caelum.

the class VoteDAOTest method should_return_right_comments_and_currentUser_votes_map.

@Test
public void should_return_right_comments_and_currentUser_votes_map() {
    Question question = question(currentUser, tags);
    Answer answer = answer("blablablablablablablablablablbalblabla", question, currentUser);
    Comment answerComment1 = comment(otherUser, "comentariocomentariocomentariocomentariocomentario", DateTime.now().minusHours(1));
    Comment answerComment2 = comment(currentUser, "comentariocomentariocomentariocomentariocomentario", DateTime.now().minusHours(2));
    Comment answerComment3 = comment(otherUser, "comentariocomentariocomentariocomentariocomentario", DateTime.now().minusHours(3));
    answer.add(answerComment1);
    answer.add(answerComment2);
    answer.add(answerComment3);
    Comment questionComment1 = comment(otherUser, "comentariocomentariocomentariocomentariocomentario", DateTime.now().minusHours(4));
    Comment questionComment2 = comment(currentUser, "comentariocomentariocomentariocomentariocomentario", DateTime.now().minusHours(5));
    Comment questionComment3 = comment(otherUser, "comentariocomentariocomentariocomentariocomentario", DateTime.now().minusHours(6));
    question.add(questionComment1);
    question.add(questionComment2);
    question.add(questionComment3);
    Vote currentUserUpVote1 = upvote(answerComment1, currentUser);
    Vote currentUserUpVote2 = upvote(questionComment1, currentUser);
    upvote(answerComment2, otherUser);
    upvote(questionComment2, otherUser);
    session.save(question);
    session.save(answer);
    session.save(answerComment1);
    session.save(answerComment2);
    session.save(answerComment3);
    CommentsAndVotes commentsAndVotes = votes.previousVotesForComments(question, currentUser);
    assertEquals(currentUserUpVote1, commentsAndVotes.getVotes(answerComment1));
    assertEquals(currentUserUpVote2, commentsAndVotes.getVotes(questionComment1));
    assertEquals(null, commentsAndVotes.getVotes(questionComment2));
    assertEquals(null, commentsAndVotes.getVotes(answerComment2));
    assertEquals(null, commentsAndVotes.getVotes(questionComment3));
    assertEquals(null, commentsAndVotes.getVotes(answerComment3));
}
Also used : Answer(org.mamute.model.Answer) Comment(org.mamute.model.Comment) CommentsAndVotes(org.mamute.model.CommentsAndVotes) Vote(org.mamute.model.Vote) MassiveVote(org.mamute.model.vote.MassiveVote) SuspectMassiveVote(org.mamute.dto.SuspectMassiveVote) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 7 with Comment

use of org.mamute.model.Comment in project mamute by caelum.

the class FlagDaoTest method should_verify_that_user_flagged_comment.

@Test
public void should_verify_that_user_flagged_comment() {
    FlagDao flags = new FlagDao(session);
    User author = user("user user", "chico@brutal.com");
    User other = user("user user", "other@brutal.com");
    session.save(author);
    session.save(other);
    Comment commentFromAuthor = createCommentWithFlag(author);
    Comment commentFromOther = createCommentWithFlag(other);
    assertFalse(flags.alreadyFlagged(author, commentFromOther.getId(), Comment.class));
    assertTrue(flags.alreadyFlagged(author, commentFromAuthor.getId(), Comment.class));
}
Also used : Comment(org.mamute.model.Comment) User(org.mamute.model.User) Test(org.junit.Test)

Example 8 with Comment

use of org.mamute.model.Comment in project mamute by caelum.

the class FlagDaoTest method createCommentWithFlag.

private Comment createCommentWithFlag(User author) {
    Comment comment = new Comment(author, notMarked("my comment my comment my comment"));
    Flag flag = new Flag(FlagType.RUDE, author);
    comment.add(flag);
    session.save(flag);
    session.save(comment);
    return comment;
}
Also used : Comment(org.mamute.model.Comment) Flag(org.mamute.model.Flag)

Example 9 with Comment

use of org.mamute.model.Comment in project mamute by caelum.

the class VisibleCommentListTest method setup.

@Before
public void setup() {
    commentList = new VisibleCommentList();
    author = user("leonardo", "leo@leo.com");
    leo = user("leonardo", "leo@leo.com");
    moderatorLeo = user("moderator", "moderator@leo.com").asModerator();
    Comment comment = comment(author, "meu teste de visibilidade de comentarios :)");
    comment.remove();
    invisibleComments = asList(comment);
    session.save(leo);
    session.save(moderatorLeo);
    session.save(author);
    session.save(comment);
}
Also used : Comment(org.mamute.model.Comment) VisibleCommentList(org.mamute.model.VisibleCommentList) Before(org.junit.Before)

Example 10 with Comment

use of org.mamute.model.Comment in project mamute by caelum.

the class RetrieveKarmaTest method should_not_handle_comment.

@Test
public void should_not_handle_comment() {
    Comment comment = comment(null, null);
    assertFalse(retrieveKarma.shouldHandle(comment));
}
Also used : Comment(org.mamute.model.Comment) Test(org.junit.Test)

Aggregations

Comment (org.mamute.model.Comment)14 Test (org.junit.Test)9 Question (org.mamute.model.Question)4 Answer (org.mamute.model.Answer)3 LoggedUser (org.mamute.model.LoggedUser)3 User (org.mamute.model.User)3 RemoveAnythingFlaggedByModerator (org.mamute.model.flag.RemoveAnythingFlaggedByModerator)3 Flag (org.mamute.model.Flag)2 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)1 Get (br.com.caelum.vraptor.Get)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 FlaggableAndFlagCount (org.mamute.dto.FlaggableAndFlagCount)1 SuspectMassiveVote (org.mamute.dto.SuspectMassiveVote)1 CommentsAndVotes (org.mamute.model.CommentsAndVotes)1 ReputationEventContext (org.mamute.model.ReputationEventContext)1 VisibleCommentList (org.mamute.model.VisibleCommentList)1 Vote (org.mamute.model.Vote)1 MassiveVote (org.mamute.model.vote.MassiveVote)1