Search in sources :

Example 21 with Vote

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

the class VotingMachineTest method should_substitute_vote_and_decrease_count.

@Test
public void should_substitute_vote_and_decrease_count() {
    Vote previousVote = vote(voter, VoteType.UP, 1l);
    votingMachine.register(votable, previousVote, Question.class);
    when(votes.previousVoteFor(votable.getId(), voter, Question.class)).thenReturn(previousVote);
    Vote newVote = new Vote(voter, VoteType.DOWN);
    votingMachine.register(votable, newVote, Question.class);
    assertEquals(-1, votable.getVoteCount());
}
Also used : Vote(org.mamute.model.Vote) MassiveVote(org.mamute.model.vote.MassiveVote) Test(org.junit.Test)

Aggregations

Vote (org.mamute.model.Vote)21 Test (org.junit.Test)13 MassiveVote (org.mamute.model.vote.MassiveVote)10 VotedAtSomethingEvent (org.mamute.reputation.rules.VotedAtSomethingEvent)4 SuspectMassiveVote (org.mamute.dto.SuspectMassiveVote)3 Question (org.mamute.model.Question)3 Answer (org.mamute.model.Answer)2 ReputationEvent (org.mamute.model.ReputationEvent)2 ReputationEventContext (org.mamute.model.ReputationEventContext)2 User (org.mamute.model.User)2 Votable (org.mamute.model.interfaces.Votable)2 ReceivedVoteEvent (org.mamute.reputation.rules.ReceivedVoteEvent)2 ArrayList (java.util.ArrayList)1 Query (org.hibernate.Query)1 DateTime (org.joda.time.DateTime)1 AnswerAndVotes (org.mamute.model.AnswerAndVotes)1 Comment (org.mamute.model.Comment)1 CommentsAndVotes (org.mamute.model.CommentsAndVotes)1