use of org.mamute.model.Vote in project mamute by caelum.
the class VotingMachineTest method should_add_vote.
@Test
public void should_add_vote() {
votingMachine.register(votable, new Vote(voter, VoteType.UP), Question.class);
assertEquals(1, votable.getVoteCount());
}
use of org.mamute.model.Vote in project mamute by caelum.
the class VotedAtSomethingEventTest method should_calculate_karma_for_downvote.
@Test
public void should_calculate_karma_for_downvote() {
VotedAtSomethingEvent votedAtSomething = new VotedAtSomethingEvent(new Vote(null, VoteType.DOWN), null);
assertEquals(KarmaCalculator.DOWNVOTED_QUESTION_OR_ANSWER, votedAtSomething.reward());
}
use of org.mamute.model.Vote in project mamute by caelum.
the class VotedAtSomethingEventTest method should_calculate_karma_for_upvote.
@Test
public void should_calculate_karma_for_upvote() {
VotedAtSomethingEvent votedAtSomething = new VotedAtSomethingEvent(new Vote(null, VoteType.UP), null);
assertEquals(0, votedAtSomething.reward());
}
use of org.mamute.model.Vote in project mamute by caelum.
the class AnswerAndVotesTest method should_fill_value_with_null_only_answers_that_has_no_currentUserVote.
@Test
public void should_fill_value_with_null_only_answers_that_has_no_currentUserVote() {
Question q = question.build();
Object[] first = new Object[] { answerFor(q, 1), mock(Vote.class) };
Object[] second = new Object[] { answerFor(q, 2), mock(Vote.class) };
Answer third = answerFor(q, 3);
List<Object[]> voteList = new ArrayList<>();
voteList.add(first);
voteList.add(second);
List<Answer> answers = new ArrayList<>();
answers.add((Answer) first[0]);
answers.add((Answer) second[0]);
answers.add(third);
AnswerAndVotes votes = new AnswerAndVotes(q, answers, voteList);
Map<Answer, Vote> map = votes.getVotes();
assertEquals(first[1], map.get(first[0]));
assertEquals(second[1], map.get(second[0]));
assertEquals(null, map.get(third));
assertTrue(map.containsKey(third));
}
use of org.mamute.model.Vote in project mamute by caelum.
the class MassiveVoteTest method should_count_karma_if_vote_was_created_before_min_date.
@Test
public void should_count_karma_if_vote_was_created_before_min_date() throws Exception {
DateTime antantonte = new DateTime().minusDays(3);
TimeMachine.goTo(antantonte).andExecute(new Block<Vote>() {
@Override
public Vote run() {
for (int i = 0; i < massiveVote.getMaxVotesAllowed(); i++) {
massiveVote.shouldCountKarma(massiveVoter, author, vote(massiveVoter, VoteType.DOWN, 1l));
}
return null;
}
});
Vote acceptedVote = vote(massiveVoter, VoteType.DOWN, 1l);
assertTrue(massiveVote.shouldCountKarma(massiveVoter, author, acceptedVote));
}
Aggregations